Changeset 382

Show
Ignore:
Timestamp:
Mon Mar 10 17:22:27 2008
Author:
Brian
Message:

Updated the xslt that creates html reports. It is now much closer to the html export script. I added 'list' and most of 'path' access, day and week time scales, and gantt. Also made a change to the xml export to make time scale processing easier.

Files:

Legend:

Unmodified
Added
Removed
Modified
  • scripts/trunk/_Transforms/ganttpv_report.xslt

    r378 r382  
    22 22  
    23 23 # 080225 - completed mostly working first draft (only access 'd' and 'i', no timescales)  
    24    
      24 # 080310 - Brian - brought it much closer to the html expport (added 'list' and most of 'path' access, timescales, and gantt)  
    24 24 -->  
    25   <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">  
      25 <xsl:stylesheet version="1.0"  
      26         xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  
      27         xmlns:exsl="http://exslt.org/common"  
      28         >  
    26 29         <xsl:output method="html"/>  
    27 30         <xsl:param name="reportid" select="4" />  
      31         <xsl:variable name="database" select="/" />  
    28 32  
    29 33         <xsl:template match="/">  
     
    70 74                                                                 <h3>Gantt Chart (Task)&#160;(New Project)</h3>  
    71 75                                                                 <table border="1" cellspacing="0" cellpadding="1">  
      76                                                                         <xsl:variable name="rowspan">  
      77                                                                                 <xsl:choose>  
      78                                                                                 <xsl:when test="$clist/TimeScaleDates">  
      79                                                                                         <xsl:value-of select="'3'"/>  
      80                                                                                 </xsl:when>  
      81                                                                                         <xsl:otherwise>  
      82                                                                                                 <xsl:value-of select="'2'"/>  
      83                                                                                         </xsl:otherwise>  
      84                                                                                 </xsl:choose>  
      85                                                                         </xsl:variable>  
      86                                                                         <tr>  
      87                                                                                 <xsl:apply-templates select="$clist" mode="colhead">  
      88                                                                                         <xsl:sort select="@seq" data-type="number" />  
      89                                                                                         <xsl:with-param name="rowspan" select="$rowspan"/>  
      90                                                                                 </xsl:apply-templates>  
      91                                                                         </tr>  
    72 92                                                                         <tr>  
    73                                                   <xsl:apply-templates select="$clist" mode="colhead">  
    74                                                           <xsl:sort select="@seq"/>  
    75                                                   </xsl:apply-templates>  
    76                                           </tr>  
    77                                           <xsl:apply-templates select="$rlist" mode="reportrow">  
      93                                                                                 <xsl:apply-templates select="$clist" mode="colhead2">  
      94                                                                                         <xsl:sort select="@seq" data-type="number" />  
      95                                                                                 </xsl:apply-templates>  
      96                                                                         </tr>  
      97                                                                         <tr>  
      98                                                                                 <xsl:apply-templates select="$clist" mode="colhead3">  
      99                                                                                         <xsl:sort select="@seq" data-type="number" />  
      100                                                                                 </xsl:apply-templates>  
      101                                                                         </tr>  
      102                                                                         <xsl:apply-templates select="$rlist" mode="reportrow">  
    78 103                                                 <xsl:sort select="@seq" data-type="number"/>  
    79 104                                                 <xsl:with-param name="clist" select="$clist"/>  
     
    99 124  
    100 125         <xsl:template match="row" mode="colhead">  
    101                   <td class="head"> <!--  
    102                           colspan="1" rowspan="1" > -->  
      126                 <xsl:param name="rowspan" select="'2'" />  
      127                 <xsl:variable name="span">  
      128                         <xsl:choose>  
      129                                 <xsl:when test="Periods">  
      130                                         <xsl:value-of select="Periods"/>  
      131                                 </xsl:when>  
      132                                 <xsl:otherwise>  
      133                                         <xsl:value-of select="1"/>  
      134                                 </xsl:otherwise>  
      135                         </xsl:choose>  
      136                 </xsl:variable>  
      137                 <td class="head" colspan="{$span}">  
      138                         <xsl:attribute name="rowspan">  
      139                                 <xsl:choose>  
      140                                         <xsl:when test="Periods">  
      141                                                 <xsl:value-of select="'1'"/>  
      142                                         </xsl:when>  
      143                                         <xsl:when test="$rowspan=2">  
      144                                                 <xsl:value-of select="'2'"/>  
      145                                         </xsl:when>  
      146                                         <xsl:otherwise>  
      147                                                 <xsl:value-of select="'3'"/>  
      148                                         </xsl:otherwise>  
      149                                 </xsl:choose>  
      150                         </xsl:attribute>  
      151                         <!-- rowspan="1" > -->  
    103 152                         <xsl:call-template name="getlabel">  
    104 153                                 <xsl:with-param name="column" select="." />  
     
    107 156         </xsl:template>  
    108 157  
      158         <xsl:template match="row" mode="colhead2">  
      159                 <xsl:choose>  
      160                         <xsl:when test="Periods">  
      161                                 <xsl:variable name="Dates" select="TimeScaleDates" />  
      162                                 <xsl:variable name="result">  
      163                                         <xsl:call-template name="MonthSpan">  
      164                                                 <xsl:with-param name="DateList" select="$Dates"/>  
      165                                                 <xsl:with-param name="Month" select="substring($Dates,1,7)"/>  
      166                                                 <xsl:with-param name="Count" select="1"/>  
      167                                         </xsl:call-template>  
      168                                 </xsl:variable>  
      169                                 <xsl:copy-of select="$result"/>  
      170                         </xsl:when>  
      171                 </xsl:choose>  
      172         </xsl:template>  
      173  
      174         <xsl:template name="MonthSpan">  
      175                 <xsl:param name="DateList"/>  
      176                 <xsl:param name="Month" />  
      177                 <xsl:param name="Count" select="0"/>  
      178                 <xsl:variable name="first" select="substring-before(concat($DateList,','),',')"/>  
      179                 <xsl:variable name="rest" select="substring-after($DateList,',')"/>  
      180                 <xsl:choose>  
      181                         <xsl:when test="substring($rest,1,7) = $Month">  
      182                                 <xsl:call-template name="MonthSpan">  
      183                                         <xsl:with-param name="DateList" select="$rest"/>  
      184                                         <xsl:with-param name="Month" select="$Month"/>  
      185                                         <xsl:with-param name="Count" select="$Count+1"/>  
      186                                 </xsl:call-template>  
      187                         </xsl:when>  
      188                         <xsl:otherwise>  
      189                                 <td class="head" colspan="{$Count}">  
      190                                         <xsl:choose>  
      191                                                 <xsl:when test="$Count>2">  
      192                                                         <xsl:value-of select="$Month"/>  
      193                                                 </xsl:when>  
      194                                                 <!-- doesn't fit without going onto the next row - bcc 080310  
      195                                                 <xsl:when test="$Count>1">  
      196                                                         <xsl:value-of select="substring($Month,3)"/>  
      197                                                 </xsl:when>  
      198                                                 -->  
      199                                                 <xsl:otherwise>  
      200                                                         <xsl:value-of select="substring($Month,6)"/>  
      201                                                 </xsl:otherwise>  
      202                                         </xsl:choose>  
      203                                 </td>  
      204                                 <xsl:if test="$rest">  
      205                                         <xsl:call-template name="MonthSpan">  
      206                                                 <xsl:with-param name="DateList" select="$rest"/>  
      207                                                 <xsl:with-param name="Month" select="substring($rest,1,7)"/>  
      208                                                 <xsl:with-param name="Count" select="1"/>  
      209                                         </xsl:call-template>  
      210                                 </xsl:if>  
      211                         </xsl:otherwise>  
      212                 </xsl:choose>  
      213         </xsl:template>  
      214  
      215         <xsl:template match="row" mode="colhead3">  
      216                 <xsl:choose>  
      217                         <xsl:when test="Periods">  
      218                                 <xsl:variable name="Dates" select="TimeScaleDates" />  
      219                                 <xsl:variable name="result">  
      220                                         <xsl:call-template name="PeriodDate">  
      221                                                 <xsl:with-param name="DateList" select="$Dates"/>  
      222                                         </xsl:call-template>  
      223                                 </xsl:variable>  
      224                                 <xsl:copy-of select="$result"/>  
      225                         </xsl:when>  
      226                 </xsl:choose>  
      227         </xsl:template>  
      228  
      229         <xsl:template name="PeriodDate">  
      230                 <xsl:param name="DateList"/>  
      231                 <xsl:variable name="first" select="substring-before(concat($DateList,','),',')"/>  
      232                 <xsl:variable name="rest" select="substring-after($DateList,',')"/>  
      233                                 <td class="head" >  
      234                                         <xsl:value-of select="substring($first,9,2)"/>  
      235                                 </td>  
      236                                 <xsl:if test="$rest">  
      237                                         <xsl:call-template name="PeriodDate">  
      238                                                 <xsl:with-param name="DateList" select="$rest"/>  
      239                                         </xsl:call-template>  
      240                                 </xsl:if>  
      241         </xsl:template>  
      242  
    109 243         <xsl:template match="row" mode="reportrow">  
    110 244                 <xsl:param name="clist"/>  
    111 245                 <tr>  
    112 246                         <xsl:apply-templates select="$clist" mode="colcell">  
    113                                   <xsl:sort select="@seq"/>  
      247                                 <xsl:sort select="@seq" data-type="number"/>  
    113 247                                 <xsl:with-param name="thisrow" select="." />  
    114 248                         </xsl:apply-templates>  
     
    127 261                 </xsl:variable>  
    128 262                 <xsl:variable name="width">  
      263                         <xsl:if test="$thisrow/@seq=1">  
    129 264                         <xsl:call-template name="getwidth">  
    130 265                                 <xsl:with-param name="column" select="." />  
    131 266                         </xsl:call-template>  
      267                         </xsl:if>  
    132 268                 </xsl:variable>  
    133                           <td class="body"  width="{$width}"  nowrap=""  >  
    134                           <xsl:value-of select="$cellcontents" />  
    135                   </td>  
    136                   </xsl:template>  
      269                 <xsl:variable name="cellcontentsN" select="exsl:node-set($cellcontents)" />  
      270                 <xsl:choose>  
      271                         <xsl:when test="count($cellcontentsN//time)=0">  
      272                         <td class="body"  nowrap=""  >  
      273                                 <xsl:if test="string($width)">  
      274                                         <xsl:attribute name="width">  
      275                                                 <xsl:value-of select="$width"/>  
      276                                         </xsl:attribute>  
      277                                 </xsl:if>  
      278                                 <xsl:value-of select="$cellcontentsN[1]" />  
      279                         </td>  
      280                         </xsl:when>  
      281                         <xsl:when test="$cellcontentsN//task">  
      282                                 <xsl:for-each select="$cellcontentsN/*">  
      283                                         <xsl:variable name="temp" select="."/>  
      284                                         <xsl:variable name="class">  
      285                                                 <xsl:choose>  
      286                                                         <xsl:when test=".//task">  
      287                                                                 <xsl:text>task</xsl:text>  
      288                                                         </xsl:when>  
      289                                                         <xsl:otherwise>  
      290                                                                 <xsl:text>non</xsl:text>  
      291                                                         </xsl:otherwise>  
      292                                                 </xsl:choose>  
      293                                         </xsl:variable>  
      294                                         <xsl:variable name="x">  
      295                                                 <xsl:choose>  
      296                                                         <xsl:when test="$class='task'">  
      297                                                                 <xsl:text>X</xsl:text>  
      298                                                         </xsl:when>  
      299                                                         <xsl:otherwise>  
      300                                                                 <xsl:text>&#160;</xsl:text>  
      301                                                         </xsl:otherwise>  
      302                                                 </xsl:choose>  
      303                                         </xsl:variable>  
      304                                         <td class="{$class}" >  
      305                                                 <xsl:if test="$thisrow/@seq=1">  
      306                                                         <xsl:attribute name="width">  
      307                                                                 <xsl:value-of select="'24'"/>  
      308                                                         </xsl:attribute>  
      309                                                 </xsl:if>  
      310                                                 <xsl:value-of select="$x" />  
      311                                         </td>  
      312                                 </xsl:for-each>  
      313                         </xsl:when>  
      314                         <xsl:otherwise>  
      315                                 <xsl:for-each select="$cellcontentsN/*">  
      316                                         <td class="body"  >  
      317                                                 <xsl:if test="string($width)">  
      318                                                         <xsl:attribute name="width">  
      319                                                                 <xsl:value-of select="$width"/>  
      320                                                         </xsl:attribute>  
      321                                                 </xsl:if>  
      322                                                 <xsl:value-of select="." />  
      323                                         </td>  
      324                                 </xsl:for-each>                                   
      325                         </xsl:otherwise>  
      326                 </xsl:choose>  
      327         </xsl:template>  
    137 328  
    138 329         <!-- column width defaults to column type width -->  
     
    163 354                                 <xsl:variable name="columntypeid" select="$column/ColumnTypeID" />  
    164 355                                 <xsl:variable name="columntype" select="//table[@name='ColumnType']/rows/row[@id=$columntypeid]" />  
      356                                 <xsl:choose>  
      357                                         <xsl:when test="$columntype/Label">  
    165 358                                 <xsl:value-of select="$columntype/Label"/>  
      359                                 </xsl:when>  
      360                                         <xsl:otherwise>  
      361                                                 <xsl:value-of select="$columntype/Name"/>  
      362                                         </xsl:otherwise>  
      363                                 </xsl:choose>  
    166 364                         </xsl:otherwise>  
    167 365                 </xsl:choose>  
     
    220 418                         <xsl:when test="$accesstype='d'">  
    221 419                                 <xsl:variable name="target" select="//table[@name=$row/TableName]/rows/row[@id=$row/TableID]" />  
    222                                           <xsl:variable name="result" select="$target/*[local-name(.)=$rowcolname]"/>  
      420                                 <xsl:variable name="result" select="$target/*[local-name(.)=$rowcolname]"/>  
    222 420                                 <xsl:choose>  
    223 421                                         <xsl:when test="$result">  
     
    235 433                         <xsl:when test="$accesstype='i'">  
    236 434                                 <!-- foreign table name -->  
    237                                   <xsl:variable name="rawtname" select="substring-before($rowcolname, '/')" />  
    238                                   <xsl:variable name="alttname" select="/tablealiases/alias/*[local-name(.)=$rawtname]" />  
    239 435                                 <xsl:variable name="tname">  
    240                                           <xsl:choose>  
    241                                                   <xsl:when test="$alttname">  
    242                                                           <xsl:value-of select="$alttname" />  
    243                                                   </xsl:when>  
    244                                                   <xsl:otherwise>  
    245                                                           <xsl:value-of select="$rawtname" />  
    246                                                   </xsl:otherwise>  
    247                                           </xsl:choose>  
      436                                         <xsl:call-template name="ConvertAlias">  
      437                                                 <xsl:with-param name="name" select="substring-before($rowcolname, '/')" />  
      438                                         </xsl:call-template>  
    248 439                                 </xsl:variable>  
    249 440                                 <xsl:variable name="tcol" select="substring-after($rowcolname, '/')" />  
     
    265 456                         <!-- time scale -->  
    266 457                         <xsl:when test="$accesstype='s'">  
    267                                   <xsl:variable name="period" select="substring-before($rowcolname, '/')" />  
    268                                   <xsl:variable name="data" select="substring-after($rowcolname, '/')" />  
      458                                 <xsl:variable name="timeunit" select="substring-before($rowcolname, '/')" />  
      459                                 <xsl:variable name="targetcolumn" select="substring-after($rowcolname, '/')" />  
    269 460                                 <xsl:choose>  
    270                                           <xsl:when test="$data = 'Gantt'">  
    271                                                   <xsl:text>&#160;</xsl:text>  
      461                                         <xsl:when test="$targetcolumn = 'Gantt'">  
      462                                                 <xsl:variable name="target" select="//table[@name=$row/TableName]/rows/row[@id=$row/TableID]" />  
      463                                                 <!-- <xsl:variable name="target" select="$database//table[@name=$row/TableName]/rows/row[@rowid=$row/TableID]" /> -->  
      464                                                 <xsl:call-template name="GetGanttList">  
      465                                                         <xsl:with-param name="row" select="$row" />  
      466                                                         <xsl:with-param name="target" select="$target" />  
      467                                                         <xsl:with-param name="timeunit" select="$timeunit" />  
      468                                                         <xsl:with-param name="dates" select="TimeScaleDates" />  
      469                                                 </xsl:call-template>  
    272 470                                         </xsl:when>  
    273 471                                         <xsl:otherwise>  
    274                                                   <xsl:text>&#160;</xsl:text>  
      472                                                 <xsl:call-template name="GetTimeList">  
      473                                                         <xsl:with-param name="tablename" select="$row/TableName" />  
      474                                                         <xsl:with-param name="tableid" select="$row/TableID" />  
      475                                                         <xsl:with-param name="timeunit" select="$timeunit" />  
      476                                                         <xsl:with-param name="targetcolumn" select="$targetcolumn" />  
      477                                                         <xsl:with-param name="dates" select="TimeScaleDates" />  
      478                                                 </xsl:call-template>  
    275 479                                         </xsl:otherwise>  
    276 480                                 </xsl:choose>  
     
    278 482                         <!-- create list using list path -->  
    279 483                         <xsl:when test="$accesstype='list'">  
      484                                 <xsl:variable name="path">  
      485                                         <xsl:call-template name="ConvertListToPath">  
      486                                                 <xsl:with-param name="path" select="$columntype/Path"/>  
      487                                         </xsl:call-template>  
      488                                 </xsl:variable>  
      489                                 <xsl:variable name="result">  
      490                                         <xsl:call-template name="FollowPath">  
      491                                                 <xsl:with-param name="rowset" select="/Database/tables/table[@name=$row/TableName]/rows/row[@id=$row/TableID]" />  
      492                                                 <xsl:with-param name="path" select="$path"/>  
      493                                         </xsl:call-template>  
      494                                 </xsl:variable>  
      495                                 <xsl:value-of select="$result"/>  
    280 496                                 <xsl:text>&#160;</xsl:text>  
    281 497                         </xsl:when>  
    282 498                         <!-- create list using new path format -->  
    283 499                         <xsl:when test="$accesstype='path'">  
      500                                 <xsl:variable name="result">  
      501                                         <xsl:call-template name="FollowPath">  
      502                                                 <xsl:with-param name="rowset" select="/Database/tables/table[@name=$row/TableName]/rows/row[@id=$row/TableID]" />  
      503                                                 <xsl:with-param name="path" select="$columntype/Path"/>  
      504                                         </xsl:call-template>  
      505                                         </xsl:variable>  
    284 506                                 <xsl:text>&#160;</xsl:text>  
    285 507                         </xsl:when>  
     
    292 514                 </xsl:choose>  
    293 515         </xsl:template>  
    294   </xsl:stylesheet>  
      516  
      517         <xsl:template name="GetGanttList">  
      518                 <!--  
      519                 Parameter values:  
      520                 row = report row  
      521                 target = pointed to by row  
      522                 timeunit is taken from the ColumnType  
      523                 dates are taken from the ReportColumn  
      524                 How they are used:  
      525                 different values are returnd from the row and target  
      526                 -->  
      527                 <xsl:param name="row" />  
      528                 <xsl:param name="target" />  
      529                 <xsl:param name="timeunit" />  
      530                 <xsl:param name="dates" />  
      531                 <xsl:variable name="thisdate" select="substring-before(concat($dates,','),',')" />  
      532                 <xsl:variable name="remainingdates" select="substring-after($dates,',')" />  
      533                 <xsl:element name="time">  
      534                         <xsl:copy-of select="$row/GanttBarColor" />  
      535                         <xsl:variable name="start" select="string($target/CalculatedStartDate/text())" />  
      536                         <xsl:variable name="end" select="string($target/CalculatedEndDate/text())" />  
      537                         <xsl:variable name="thisdatenum" select="concat(substring($thisdate,1,4),substring($thisdate,6,2),substring($thisdate,9,2))" />  
      538                         <xsl:variable name="startnum" select="concat(substring($start,1,4),substring($start,6,2),substring($start,9,2))" />  
      539                         <xsl:variable name="endnum" select="concat(substring($end,1,4),substring($end,6,2),substring($end,9,2))" />  
      540                         <xsl:choose>  
      541                                 <xsl:when test="$startnum &lt;= $thisdatenum and $endnum &gt; $thisdatenum">  
      542                                         <xsl:copy-of select="$row/PlanBarColor" />  
      543                                         <xsl:element name="task">yes</xsl:element>  
      544                                 </xsl:when>  
      545                         </xsl:choose>  
      546                 </xsl:element>  
      547                 <xsl:if test="$remainingdates">  
      548                         <xsl:call-template name="GetGanttList">  
      549                                 <xsl:with-param name="row" select="$row" />  
      550                                 <xsl:with-param name="target" select="$target" />  
      551                                 <xsl:with-param name="timeunit" select="$timeunit" />  
      552                                 <xsl:with-param name="dates" select="$remainingdates" />  
      553                         </xsl:call-template>  
      554                 </xsl:if>  
      555         </xsl:template>  
      556  
      557         <xsl:template name="GetTimeList">  
      558                 <!--  
      559                 Parameter values:  
      560                 tablename, tableid are take from the ReportRow  
      561                 timeunit, targetcolumn are taken from the ColumnType  
      562                 dates are taken from the ReportColumn  
      563                 How they are used:  
      564                 tablename + timeunit = target table name  
      565                 (tablename+'ID')(tableid) & 'Period'(date) = select correct row  
      566                 targetcolumn = contains data returned  
      567                 -->  
      568                 <xsl:param name="tablename" />  
      569                 <xsl:param name="tableid" />  
      570                 <xsl:param name="timeunit" />  
      571                 <xsl:param name="targetcolumn" />  
      572                 <xsl:param name="dates" />  
      573                 <xsl:variable name="targettable" select="concat($tablename, $timeunit)" />  
      574                 <xsl:variable name="thisdate" select="substring-before(concat($dates,','),',')" />  
      575                 <xsl:variable name="remainingdates" select="substring-after($dates,',')" />  
      576                 <xsl:variable name="selectcolumn" select="concat($tablename, 'ID')" />  
      577                 <xsl:variable name="target" select="$database//table[@name=$targettable]/rows/row[(*[local-name(.)=$selectcolumn])=$tableid and Period=$thisdate]" />  
      578                 <xsl:variable name="result" select="$target/*[local-name(.)=$targetcolumn]" />  
      579                 <xsl:element name="time">  
      580                         <xsl:choose>  
      581                                 <xsl:when test="$result">  
      582                                         <xsl:copy-of select="$result" />  
      583                                 </xsl:when>  
      584                                 <xsl:otherwise>  
      585                                         <xsl:text>&#160;</xsl:text>