home *** CD-ROM | disk | FTP | other *** search
/ Internet Magazine 2003 October / INTERNET108.ISO / pc / software / windows / building / xmlspy / xmlspyentcomplete5.exe / Data1.cab / _17A0C1C2C61442189E54D98B44DF5457 < prev    next >
Encoding:
Extensible Markup Language  |  2002-09-04  |  33.5 KB  |  979 lines

  1. <?xml version='1.0'?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3.                 xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
  4.                 xmlns:stbl="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.Table"
  5.                 xmlns:xtbl="com.nwalsh.xalan.Table"
  6.                 xmlns:ptbl="http://nwalsh.com/xslt/ext/xsltproc/python/Table"
  7.                 xmlns:lxslt="http://xml.apache.org/xslt"
  8.                 exclude-result-prefixes="doc stbl xtbl lxslt ptbl"
  9.                 version='1.0'>
  10.  
  11. <xsl:include href="../common/table.xsl"/>
  12.  
  13. <!-- ********************************************************************
  14.      $Id: table.xsl,v 1.1.2.1 2002/09/04 13:51:04 jdj Exp $
  15.      ********************************************************************
  16.  
  17.      This file is part of the XSL DocBook Stylesheet distribution.
  18.      See ../README or http://nwalsh.com/docbook/xsl/ for copyright
  19.      and other information.
  20.  
  21.      ******************************************************************** -->
  22.  
  23. <lxslt:component prefix="xtbl"
  24.                  functions="adjustColumnWidths"/>
  25.  
  26. <xsl:template name="empty.table.cell">
  27.   <xsl:param name="colnum" select="0"/>
  28.  
  29.   <xsl:variable name="rowsep">
  30.     <xsl:call-template name="inherited.table.attribute">
  31.       <xsl:with-param name="entry" select="NOT-AN-ELEMENT-NAME"/>
  32.       <xsl:with-param name="row" select="ancestor-or-self::row[1]"/>
  33.       <xsl:with-param name="colnum" select="$colnum"/>
  34.       <xsl:with-param name="attribute" select="'rowsep'"/>
  35.     </xsl:call-template>
  36.   </xsl:variable>
  37.  
  38.   <xsl:variable name="colsep">
  39.     <xsl:call-template name="inherited.table.attribute">
  40.       <xsl:with-param name="entry" select="NOT-AN-ELEMENT-NAME"/>
  41.       <xsl:with-param name="row" select="ancestor-or-self::row[1]"/>
  42.       <xsl:with-param name="colnum" select="$colnum"/>
  43.       <xsl:with-param name="attribute" select="'colsep'"/>
  44.     </xsl:call-template>
  45.   </xsl:variable>
  46.  
  47.   <td class="auto-generated">
  48.     <xsl:if test="$table.borders.with.css != 0">
  49.       <xsl:attribute name="style">
  50.         <xsl:if test="$colsep > 0">
  51.           <xsl:call-template name="border">
  52.             <xsl:with-param name="side" select="'right'"/>
  53.           </xsl:call-template>
  54.         </xsl:if>
  55.         <xsl:if test="$rowsep > 0">
  56.           <xsl:call-template name="border">
  57.             <xsl:with-param name="side" select="'bottom'"/>
  58.           </xsl:call-template>
  59.         </xsl:if>
  60.       </xsl:attribute>
  61.     </xsl:if>
  62.     <xsl:text> </xsl:text>
  63.   </td>
  64. </xsl:template>
  65.  
  66. <!-- ==================================================================== -->
  67.  
  68. <xsl:template name="border">
  69.   <xsl:param name="side" select="'left'"/>
  70.   <xsl:param name="padding" select="0"/>
  71.  
  72.   <!-- Note: Some browsers (mozilla) require at least a width and style. -->
  73.  
  74.   <xsl:choose>
  75.     <xsl:when test="($table.border.thickness != ''
  76.                      and $table.border.style != ''
  77.                      and $table.border.color != '')
  78.                     or ($table.border.thickness != ''
  79.                         and $table.border.style != '')
  80.                     or ($table.border.thickness != '')">
  81.       <!-- use the compound property if we can: -->
  82.       <!-- it saves space and probably works more reliably -->
  83.       <xsl:text>border-</xsl:text>
  84.       <xsl:value-of select="$side"/>
  85.       <xsl:text>: </xsl:text>
  86.       <xsl:value-of select="$table.border.thickness"/>
  87.       <xsl:text> </xsl:text>
  88.       <xsl:value-of select="$table.border.style"/>
  89.       <xsl:text> </xsl:text>
  90.       <xsl:value-of select="$table.border.color"/>
  91.       <xsl:text>; </xsl:text>
  92.     </xsl:when>
  93.     <xsl:otherwise>
  94.       <!-- we need to specify the styles individually -->
  95.       <xsl:if test="$table.border.thickness != ''">
  96.         <xsl:text>border-</xsl:text>
  97.         <xsl:value-of select="$side"/>
  98.         <xsl:text>-width: </xsl:text>
  99.         <xsl:value-of select="$table.border.thickness"/>
  100.         <xsl:text>; </xsl:text>
  101.       </xsl:if>
  102.  
  103.       <xsl:if test="$table.border.style != ''">
  104.         <xsl:text>border-</xsl:text>
  105.         <xsl:value-of select="$side"/>
  106.         <xsl:text>-style: </xsl:text>
  107.         <xsl:value-of select="$table.border.style"/>
  108.         <xsl:text>; </xsl:text>
  109.       </xsl:if>
  110.  
  111.       <xsl:if test="$table.border.color != ''">
  112.         <xsl:text>border-</xsl:text>
  113.         <xsl:value-of select="$side"/>
  114.         <xsl:text>-color: </xsl:text>
  115.         <xsl:value-of select="$table.border.color"/>
  116.         <xsl:text>; </xsl:text>
  117.       </xsl:if>
  118.     </xsl:otherwise>
  119.   </xsl:choose>
  120. </xsl:template>
  121.  
  122. <!-- ==================================================================== -->
  123.  
  124. <xsl:template match="tgroup">
  125.   <xsl:variable name="summary">
  126.     <xsl:call-template name="dbhtml-attribute">
  127.       <xsl:with-param name="pis"
  128.                       select="processing-instruction('dbhtml')"/>
  129.       <xsl:with-param name="attribute" select="'table-summary'"/>
  130.     </xsl:call-template>
  131.   </xsl:variable>
  132.  
  133.   <xsl:variable name="cellspacing">
  134.     <xsl:call-template name="dbhtml-attribute">
  135.       <xsl:with-param name="pis"
  136.                       select="processing-instruction('dbhtml')"/>
  137.       <xsl:with-param name="attribute" select="'cellspacing'"/>
  138.     </xsl:call-template>
  139.   </xsl:variable>
  140.  
  141.   <xsl:variable name="cellpadding">
  142.     <xsl:call-template name="dbhtml-attribute">
  143.       <xsl:with-param name="pis"
  144.                       select="processing-instruction('dbhtml')[1]"/>
  145.       <xsl:with-param name="attribute" select="'cellpadding'"/>
  146.     </xsl:call-template>
  147.   </xsl:variable>
  148.  
  149.   <table>
  150.     <xsl:choose>
  151.       <!-- If there's a textobject/phrase for the table summary, use it -->
  152.       <xsl:when test="../textobject/phrase">
  153.         <xsl:attribute name="summary">
  154.           <xsl:value-of select="../textobject/phrase"/>
  155.         </xsl:attribute>
  156.       </xsl:when>
  157.  
  158.       <!-- If there's a <?dbhtml table-summary="foo"?> PI, use it for
  159.            the HTML table summary attribute -->
  160.       <xsl:when test="$summary != ''">
  161.         <xsl:attribute name="summary">
  162.           <xsl:value-of select="$summary"/>
  163.         </xsl:attribute>
  164.       </xsl:when>
  165.  
  166.       <!-- Otherwise, if there's a title, use that -->
  167.       <xsl:when test="../title">
  168.         <xsl:attribute name="summary">
  169.           <xsl:value-of select="string(../title)"/>
  170.         </xsl:attribute>
  171.       </xsl:when>
  172.  
  173.       <!-- Otherwise, forget the whole idea -->
  174.       <xsl:otherwise><!-- nevermind --></xsl:otherwise>
  175.     </xsl:choose>
  176.  
  177.     <xsl:if test="$cellspacing != '' or $html.cellspacing != ''">
  178.       <xsl:attribute name="cellspacing">
  179.         <xsl:choose>
  180.           <xsl:when test="$cellspacing != ''">
  181.             <xsl:value-of select="$cellspacing"/>
  182.           </xsl:when>
  183.           <xsl:otherwise>
  184.             <xsl:value-of select="$html.cellspacing"/>
  185.           </xsl:otherwise>
  186.         </xsl:choose>
  187.       </xsl:attribute>
  188.     </xsl:if>
  189.  
  190.     <xsl:if test="$cellpadding != '' or $html.cellpadding != ''">
  191.       <xsl:attribute name="cellpadding">
  192.         <xsl:choose>
  193.           <xsl:when test="$cellpadding != ''">
  194.             <xsl:value-of select="$cellpadding"/>
  195.           </xsl:when>
  196.           <xsl:otherwise>
  197.             <xsl:value-of select="$html.cellpadding"/>
  198.           </xsl:otherwise>
  199.         </xsl:choose>
  200.       </xsl:attribute>
  201.     </xsl:if>
  202.  
  203.     <xsl:if test="../@pgwide=1">
  204.       <xsl:attribute name="width">100%</xsl:attribute>
  205.     </xsl:if>
  206.  
  207.     <xsl:choose>
  208.       <xsl:when test="$table.borders.with.css != 0">
  209.         <xsl:attribute name="border">0</xsl:attribute>
  210.         <xsl:choose>
  211.           <xsl:when test="../@frame='all'">
  212.             <xsl:attribute name="style">
  213.               <xsl:text>border-collapse: collapse;</xsl:text>
  214.               <xsl:call-template name="border">
  215.                 <xsl:with-param name="side" select="'top'"/>
  216.               </xsl:call-template>
  217.               <xsl:call-template name="border">
  218.                 <xsl:with-param name="side" select="'bottom'"/>
  219.               </xsl:call-template>
  220.               <xsl:call-template name="border">
  221.                 <xsl:with-param name="side" select="'left'"/>
  222.               </xsl:call-template>
  223.               <xsl:call-template name="border">
  224.                 <xsl:with-param name="side" select="'right'"/>
  225.               </xsl:call-template>
  226.             </xsl:attribute>
  227.           </xsl:when>
  228.           <xsl:when test="../@frame='topbot'">
  229.             <xsl:attribute name="style">
  230.               <xsl:text>border-collapse: collapse;</xsl:text>
  231.               <xsl:call-template name="border">
  232.                 <xsl:with-param name="side" select="'top'"/>
  233.               </xsl:call-template>
  234.               <xsl:call-template name="border">
  235.                 <xsl:with-param name="side" select="'bottom'"/>
  236.               </xsl:call-template>
  237.             </xsl:attribute>
  238.           </xsl:when>
  239.           <xsl:when test="../@frame='top'">
  240.             <xsl:attribute name="style">
  241.               <xsl:text>border-collapse: collapse;</xsl:text>
  242.               <xsl:call-template name="border">
  243.                 <xsl:with-param name="side" select="'top'"/>
  244.               </xsl:call-template>
  245.             </xsl:attribute>
  246.           </xsl:when>
  247.           <xsl:when test="../@frame='bottom'">
  248.             <xsl:attribute name="style">
  249.               <xsl:text>border-collapse: collapse;</xsl:text>
  250.               <xsl:call-template name="border">
  251.                 <xsl:with-param name="side" select="'bottom'"/>
  252.               </xsl:call-template>
  253.             </xsl:attribute>
  254.           </xsl:when>
  255.           <xsl:when test="../@frame='sides'">
  256.             <xsl:attribute name="style">
  257.               <xsl:text>border-collapse: collapse;</xsl:text>
  258.               <xsl:call-template name="border">
  259.                 <xsl:with-param name="side" select="'left'"/>
  260.               </xsl:call-template>
  261.               <xsl:call-template name="border">
  262.                 <xsl:with-param name="side" select="'right'"/>
  263.               </xsl:call-template>
  264.             </xsl:attribute>
  265.           </xsl:when>
  266.           <xsl:otherwise>
  267.             <xsl:attribute name="style">
  268.               <xsl:text>border-collapse: collapse;</xsl:text>
  269.             </xsl:attribute>
  270.           </xsl:otherwise>
  271.         </xsl:choose>
  272.       </xsl:when>
  273.       <xsl:when test="../@frame='none'">
  274.         <xsl:attribute name="border">0</xsl:attribute>
  275.       </xsl:when>
  276.       <xsl:otherwise>
  277.         <xsl:attribute name="border">1</xsl:attribute>
  278.       </xsl:otherwise>
  279.     </xsl:choose>
  280.  
  281.     <xsl:variable name="colgroup">
  282.       <colgroup>
  283.         <xsl:call-template name="generate.colgroup">
  284.           <xsl:with-param name="cols" select="@cols"/>
  285.         </xsl:call-template>
  286.       </colgroup>
  287.     </xsl:variable>
  288.  
  289.     <xsl:variable name="explicit.table.width">
  290.       <xsl:call-template name="dbhtml-attribute">
  291.         <xsl:with-param name="pis"
  292.                         select="../processing-instruction('dbhtml')[1]"/>
  293.         <xsl:with-param name="attribute" select="'table-width'"/>
  294.       </xsl:call-template>
  295.     </xsl:variable>
  296.  
  297.     <xsl:variable name="table.width">
  298.       <xsl:choose>
  299.         <xsl:when test="$explicit.table.width != ''">
  300.           <xsl:value-of select="$explicit.table.width"/>
  301.         </xsl:when>
  302.         <xsl:when test="$default.table.width = ''">
  303.           <xsl:text>100%</xsl:text>
  304.         </xsl:when>
  305.         <xsl:otherwise>
  306.           <xsl:value-of select="$default.table.width"/>
  307.         </xsl:otherwise>
  308.       </xsl:choose>
  309.     </xsl:variable>
  310.  
  311.     <xsl:if test="$default.table.width != ''
  312.                   or $explicit.table.width != ''">
  313.       <xsl:attribute name="width">
  314.         <xsl:choose>
  315.           <xsl:when test="contains($table.width, '%')">
  316.             <xsl:value-of select="$table.width"/>
  317.           </xsl:when>
  318.           <xsl:when test="$use.extensions != 0
  319.                           and $tablecolumns.extension != 0">
  320.             <xsl:choose>
  321.               <xsl:when test="function-available('stbl:convertLength')">
  322.                 <xsl:value-of select="stbl:convertLength($table.width)"/>
  323.               </xsl:when>
  324.               <xsl:when test="function-available('xtbl:convertLength')">
  325.                 <xsl:value-of select="xtbl:convertLength($table.width)"/>
  326.               </xsl:when>
  327.               <xsl:otherwise>
  328.                 <xsl:message terminate="yes">
  329.                   <xsl:text>No convertLength function available.</xsl:text>
  330.                 </xsl:message>
  331.               </xsl:otherwise>
  332.             </xsl:choose>
  333.           </xsl:when>
  334.           <xsl:otherwise>
  335.             <xsl:value-of select="$table.width"/>
  336.           </xsl:otherwise>
  337.         </xsl:choose>
  338.       </xsl:attribute>
  339.     </xsl:if>
  340.  
  341.     <xsl:choose>
  342.       <xsl:when test="$use.extensions != 0
  343.                       and $tablecolumns.extension != 0">
  344.         <xsl:choose>
  345.           <xsl:when test="function-available('stbl:adjustColumnWidths')">
  346.             <xsl:copy-of select="stbl:adjustColumnWidths($colgroup)"/>
  347.           </xsl:when>
  348.           <xsl:when test="function-available('xtbl:adjustColumnWidths')">
  349.             <xsl:copy-of select="xtbl:adjustColumnWidths($colgroup)"/>
  350.           </xsl:when>
  351.           <xsl:when test="function-available('ptbl:adjustColumnWidths')">
  352.             <xsl:copy-of select="ptbl:adjustColumnWidths($colgroup)"/>
  353.           </xsl:when>
  354.           <xsl:otherwise>
  355.             <xsl:message terminate="yes">
  356.               <xsl:text>No adjustColumnWidths function available.</xsl:text>
  357.             </xsl:message>
  358.           </xsl:otherwise>
  359.         </xsl:choose>
  360.       </xsl:when>
  361.       <xsl:otherwise>
  362.         <xsl:copy-of select="$colgroup"/>
  363.       </xsl:otherwise>
  364.     </xsl:choose>
  365.  
  366.     <xsl:apply-templates select="thead"/>
  367.     <xsl:apply-templates select="tfoot"/>
  368.     <xsl:apply-templates select="tbody"/>
  369.  
  370.     <xsl:if test=".//footnote">
  371.       <tbody class="footnotes">
  372.         <tr>
  373.           <td colspan="{@cols}">
  374.             <xsl:apply-templates select=".//footnote" mode="table.footnote.mode"/>
  375.           </td>
  376.         </tr>
  377.       </tbody>
  378.     </xsl:if>
  379.   </table>
  380. </xsl:template>
  381.  
  382. <xsl:template match="tgroup/processing-instruction('dbhtml')">
  383.   <xsl:variable name="summary">
  384.     <xsl:call-template name="dbhtml-attribute">
  385.       <xsl:with-param name="pis" select="."/>
  386.       <xsl:with-param name="attribute" select="'table-summary'"/>
  387.     </xsl:call-template>
  388.   </xsl:variable>
  389.  
  390.   <!-- Suppress the table-summary PI -->
  391.   <xsl:if test="$summary = ''">
  392.     <xsl:processing-instruction name="dbhtml">
  393.       <xsl:value-of select="."/>
  394.     </xsl:processing-instruction>
  395.   </xsl:if>
  396. </xsl:template>
  397.  
  398. <xsl:template match="colspec"></xsl:template>
  399.  
  400. <xsl:template match="spanspec"></xsl:template>
  401.  
  402. <xsl:template match="thead|tfoot">
  403.   <xsl:element name="{name(.)}">
  404.     <xsl:if test="@align">
  405.       <xsl:attribute name="align">
  406.         <xsl:value-of select="@align"/>
  407.       </xsl:attribute>
  408.     </xsl:if>
  409.     <xsl:if test="@char">
  410.       <xsl:attribute name="char">
  411.         <xsl:value-of select="@char"/>
  412.       </xsl:attribute>
  413.     </xsl:if>
  414.     <xsl:if test="@charoff">
  415.       <xsl:attribute name="charoff">
  416.         <xsl:value-of select="@charoff"/>
  417.       </xsl:attribute>
  418.     </xsl:if>
  419.     <xsl:if test="@valign">
  420.       <xsl:attribute name="valign">
  421.         <xsl:value-of select="@valign"/>
  422.       </xsl:attribute>
  423.     </xsl:if>
  424.  
  425.     <xsl:apply-templates select="row[1]">
  426.       <xsl:with-param name="spans">
  427.         <xsl:call-template name="blank.spans">
  428.           <xsl:with-param name="cols" select="../@cols"/>
  429.         </xsl:call-template>
  430.       </xsl:with-param>
  431.     </xsl:apply-templates>
  432.  
  433.   </xsl:element>
  434. </xsl:template>
  435.  
  436. <xsl:template match="tbody">
  437.   <tbody>
  438.     <xsl:if test="@align">
  439.       <xsl:attribute name="align">
  440.         <xsl:value-of select="@align"/>
  441.       </xsl:attribute>
  442.     </xsl:if>
  443.     <xsl:if test="@char">
  444.       <xsl:attribute name="char">
  445.         <xsl:value-of select="@char"/>
  446.       </xsl:attribute>
  447.     </xsl:if>
  448.     <xsl:if test="@charoff">
  449.       <xsl:attribute name="charoff">
  450.         <xsl:value-of select="@charoff"/>
  451.       </xsl:attribute>
  452.     </xsl:if>
  453.     <xsl:if test="@valign">
  454.       <xsl:attribute name="valign">
  455.         <xsl:value-of select="@valign"/>
  456.       </xsl:attribute>
  457.     </xsl:if>
  458.  
  459.     <xsl:apply-templates select="row[1]">
  460.       <xsl:with-param name="spans">
  461.         <xsl:call-template name="blank.spans">
  462.           <xsl:with-param name="cols" select="../@cols"/>
  463.         </xsl:call-template>
  464.       </xsl:with-param>
  465.     </xsl:apply-templates>
  466.  
  467.   </tbody>
  468. </xsl:template>
  469.  
  470. <xsl:template match="row">
  471.   <xsl:param name="spans"/>
  472.  
  473.   <xsl:variable name="row-height">
  474.     <xsl:if test="processing-instruction('dbhtml')">
  475.       <xsl:call-template name="dbhtml-attribute">
  476.         <xsl:with-param name="pis" select="processing-instruction('dbhtml')"/>
  477.         <xsl:with-param name="attribute" select="'row-height'"/>
  478.       </xsl:call-template>
  479.     </xsl:if>
  480.   </xsl:variable>
  481.  
  482.   <tr>
  483.     <xsl:call-template name="tr.attributes">
  484.       <xsl:with-param name="rownum">
  485.         <xsl:number from="tgroup" count="row"/>
  486.       </xsl:with-param>
  487.     </xsl:call-template>
  488.  
  489.     <xsl:if test="$row-height != ''">
  490.       <xsl:attribute name="height">
  491.         <xsl:value-of select="$row-height"/>
  492.       </xsl:attribute>
  493.     </xsl:if>
  494.  
  495.     <xsl:if test="$table.borders.with.css != 0">
  496.       <xsl:if test="@rowsep = 1">
  497.         <xsl:attribute name="style">
  498.           <xsl:call-template name="border">
  499.             <xsl:with-param name="side" select="'bottom'"/>
  500.           </xsl:call-template>
  501.         </xsl:attribute>
  502.       </xsl:if>
  503.     </xsl:if>
  504.  
  505.     <xsl:if test="@align">
  506.       <xsl:attribute name="align">
  507.         <xsl:value-of select="@align"/>
  508.       </xsl:attribute>
  509.     </xsl:if>
  510.     <xsl:if test="@char">
  511.       <xsl:attribute name="char">
  512.         <xsl:value-of select="@char"/>
  513.       </xsl:attribute>
  514.     </xsl:if>
  515.     <xsl:if test="@charoff">
  516.       <xsl:attribute name="charoff">
  517.         <xsl:value-of select="@charoff"/>
  518.       </xsl:attribute>
  519.     </xsl:if>
  520.     <xsl:if test="@valign">
  521.       <xsl:attribute name="valign">
  522.         <xsl:value-of select="@valign"/>
  523.       </xsl:attribute>
  524.     </xsl:if>
  525.  
  526.     <xsl:apply-templates select="entry[1]">
  527.       <xsl:with-param name="spans" select="$spans"/>
  528.     </xsl:apply-templates>
  529.   </tr>
  530.  
  531.   <xsl:if test="following-sibling::row">
  532.     <xsl:variable name="nextspans">
  533.       <xsl:apply-templates select="entry[1]" mode="span">
  534.         <xsl:with-param name="spans" select="$spans"/>
  535.       </xsl:apply-templates>
  536.     </xsl:variable>
  537.  
  538.     <xsl:apply-templates select="following-sibling::row[1]">
  539.       <xsl:with-param name="spans" select="$nextspans"/>
  540.     </xsl:apply-templates>
  541.   </xsl:if>
  542. </xsl:template>
  543.  
  544. <xsl:template match="entry" name="entry">
  545.   <xsl:param name="col" select="1"/>
  546.   <xsl:param name="spans"/>
  547.  
  548.   <xsl:variable name="cellgi">
  549.     <xsl:choose>
  550.       <xsl:when test="ancestor::thead">th</xsl:when>
  551.       <xsl:when test="ancestor::tfoot">th</xsl:when>
  552.       <xsl:otherwise>td</xsl:otherwise>
  553.     </xsl:choose>
  554.   </xsl:variable>
  555.  
  556.   <xsl:variable name="empty.cell" select="count(node()) = 0"/>
  557.  
  558.   <xsl:variable name="named.colnum">
  559.     <xsl:call-template name="entry.colnum"/>
  560.   </xsl:variable>
  561.  
  562.   <xsl:variable name="entry.colnum">
  563.     <xsl:choose>
  564.       <xsl:when test="$named.colnum > 0">
  565.         <xsl:value-of select="$named.colnum"/>
  566.       </xsl:when>
  567.       <xsl:otherwise>
  568.         <xsl:value-of select="$col"/>
  569.       </xsl:otherwise>
  570.     </xsl:choose>
  571.   </xsl:variable>
  572.  
  573.   <xsl:variable name="entry.colspan">
  574.     <xsl:choose>
  575.       <xsl:when test="@spanname or @namest">
  576.         <xsl:call-template name="calculate.colspan"/>
  577.       </xsl:when>
  578.       <xsl:otherwise>1</xsl:otherwise>
  579.     </xsl:choose>
  580.   </xsl:variable>
  581.  
  582.   <xsl:variable name="following.spans">
  583.     <xsl:call-template name="calculate.following.spans">
  584.       <xsl:with-param name="colspan" select="$entry.colspan"/>
  585.       <xsl:with-param name="spans" select="$spans"/>
  586.     </xsl:call-template>
  587.   </xsl:variable>
  588.  
  589.   <xsl:variable name="rowsep">
  590.     <xsl:call-template name="inherited.table.attribute">
  591.       <xsl:with-param name="entry" select="."/>
  592.       <xsl:with-param name="colnum" select="$entry.colnum"/>
  593.       <xsl:with-param name="attribute" select="'rowsep'"/>
  594.     </xsl:call-template>
  595.   </xsl:variable>
  596.  
  597.   <xsl:variable name="colsep">
  598.     <xsl:call-template name="inherited.table.attribute">
  599.       <xsl:with-param name="entry" select="."/>
  600.       <xsl:with-param name="colnum" select="$entry.colnum"/>
  601.       <xsl:with-param name="attribute" select="'colsep'"/>
  602.     </xsl:call-template>
  603.   </xsl:variable>
  604.  
  605.   <xsl:variable name="valign">
  606.     <xsl:call-template name="inherited.table.attribute">
  607.       <xsl:with-param name="entry" select="."/>
  608.       <xsl:with-param name="colnum" select="$entry.colnum"/>
  609.       <xsl:with-param name="attribute" select="'valign'"/>
  610.     </xsl:call-template>
  611.   </xsl:variable>
  612.  
  613.   <xsl:variable name="align">
  614.     <xsl:call-template name="inherited.table.attribute">
  615.       <xsl:with-param name="entry" select="."/>
  616.       <xsl:with-param name="colnum" select="$entry.colnum"/>
  617.       <xsl:with-param name="attribute" select="'align'"/>
  618.     </xsl:call-template>
  619.   </xsl:variable>
  620.  
  621.   <xsl:variable name="char">
  622.     <xsl:call-template name="inherited.table.attribute">
  623.       <xsl:with-param name="entry" select="."/>
  624.       <xsl:with-param name="colnum" select="$entry.colnum"/>
  625.       <xsl:with-param name="attribute" select="'char'"/>
  626.     </xsl:call-template>
  627.   </xsl:variable>
  628.  
  629.   <xsl:variable name="charoff">
  630.     <xsl:call-template name="inherited.table.attribute">
  631.       <xsl:with-param name="entry" select="."/>
  632.       <xsl:with-param name="colnum" select="$entry.colnum"/>
  633.       <xsl:with-param name="attribute" select="'charoff'"/>
  634.     </xsl:call-template>
  635.   </xsl:variable>
  636.  
  637.   <xsl:choose>
  638.     <xsl:when test="$spans != '' and not(starts-with($spans,'0:'))">
  639.       <xsl:call-template name="entry">
  640.         <xsl:with-param name="col" select="$col+1"/>
  641.         <xsl:with-param name="spans" select="substring-after($spans,':')"/>
  642.       </xsl:call-template>
  643.     </xsl:when>
  644.  
  645.     <xsl:when test="$entry.colnum > $col">
  646.       <xsl:call-template name="empty.table.cell"/>
  647.       <xsl:call-template name="entry">
  648.         <xsl:with-param name="col" select="$col+1"/>
  649.         <xsl:with-param name="spans" select="substring-after($spans,':')"/>
  650.       </xsl:call-template>
  651.     </xsl:when>
  652.  
  653.     <xsl:otherwise>
  654.       <xsl:variable name="entry-bgcolor">
  655.         <xsl:if test="processing-instruction('dbhtml')">
  656.           <xsl:call-template name="dbhtml-attribute">
  657.             <xsl:with-param name="pis" select="processing-instruction('dbhtml')"/>
  658.             <xsl:with-param name="attribute" select="'entry-bgcolor'"/>
  659.           </xsl:call-template>
  660.         </xsl:if>
  661.       </xsl:variable>
  662.  
  663.       <xsl:element name="{$cellgi}">
  664.         <xsl:if test="$entry-bgcolor != ''">
  665.           <xsl:attribute name="bgcolor">
  666.             <xsl:value-of select="$entry-bgcolor"/>
  667.           </xsl:attribute>
  668.         </xsl:if>
  669.  
  670.         <xsl:if test="$show.revisionflag and @revisionflag">
  671.           <xsl:attribute name="class">
  672.             <xsl:value-of select="@revisionflag"/>
  673.           </xsl:attribute>
  674.         </xsl:if>
  675.  
  676.         <xsl:if test="$table.borders.with.css != 0">
  677.           <xsl:attribute name="style">
  678.             <xsl:if test="$colsep > 0">
  679.               <xsl:call-template name="border">
  680.                 <xsl:with-param name="side" select="'right'"/>
  681.               </xsl:call-template>
  682.             </xsl:if>
  683.             <xsl:if test="$rowsep > 0">
  684.               <xsl:call-template name="border">
  685.                 <xsl:with-param name="side" select="'bottom'"/>
  686.               </xsl:call-template>
  687.             </xsl:if>
  688.           </xsl:attribute>
  689.         </xsl:if>
  690.  
  691.         <xsl:if test="@morerows > 0">
  692.           <xsl:attribute name="rowspan">
  693.             <xsl:value-of select="1+@morerows"/>
  694.           </xsl:attribute>
  695.         </xsl:if>
  696.  
  697.         <xsl:if test="$entry.colspan > 1">
  698.           <xsl:attribute name="colspan">
  699.             <xsl:value-of select="$entry.colspan"/>
  700.           </xsl:attribute>
  701.         </xsl:if>
  702.  
  703.         <xsl:if test="$align != ''">
  704.           <xsl:attribute name="align">
  705.             <xsl:value-of select="$align"/>
  706.           </xsl:attribute>
  707.         </xsl:if>
  708.  
  709.         <xsl:if test="$valign != ''">
  710.           <xsl:attribute name="valign">
  711.             <xsl:value-of select="$valign"/>
  712.           </xsl:attribute>
  713.         </xsl:if>
  714.  
  715.         <xsl:if test="$char != ''">
  716.           <xsl:attribute name="char">
  717.             <xsl:value-of select="$char"/>
  718.           </xsl:attribute>
  719.         </xsl:if>
  720.  
  721.         <xsl:if test="$charoff != ''">
  722.           <xsl:attribute name="charoff">
  723.             <xsl:value-of select="$charoff"/>
  724.           </xsl:attribute>
  725.         </xsl:if>
  726.  
  727.         <xsl:if test="not(preceding-sibling::*) and ancestor::row/@id">
  728.           <xsl:call-template name="anchor">
  729.             <xsl:with-param name="node" select="ancestor::row[1]"/>
  730.           </xsl:call-template>
  731.         </xsl:if>
  732.  
  733.         <xsl:call-template name="anchor"/>
  734.  
  735.         <xsl:choose>
  736.           <xsl:when test="$empty.cell">
  737.             <xsl:text> </xsl:text>
  738.           </xsl:when>
  739.           <xsl:otherwise>
  740.             <xsl:apply-templates/>
  741.           </xsl:otherwise>
  742.         </xsl:choose>
  743.       </xsl:element>
  744.  
  745.       <xsl:choose>
  746.         <xsl:when test="following-sibling::entry">
  747.           <xsl:apply-templates select="following-sibling::entry[1]">
  748.             <xsl:with-param name="col" select="$col+$entry.colspan"/>
  749.             <xsl:with-param name="spans" select="$following.spans"/>
  750.           </xsl:apply-templates>
  751.         </xsl:when>
  752.         <xsl:otherwise>
  753.           <xsl:call-template name="finaltd">
  754.             <xsl:with-param name="spans" select="$following.spans"/>
  755.             <xsl:with-param name="col" select="$col+$entry.colspan"/>
  756.           </xsl:call-template>
  757.         </xsl:otherwise>
  758.       </xsl:choose>
  759.     </xsl:otherwise>
  760.   </xsl:choose>
  761. </xsl:template>
  762.  
  763. <xsl:template match="entry" name="sentry" mode="span">
  764.   <xsl:param name="col" select="1"/>
  765.   <xsl:param name="spans"/>
  766.  
  767.   <xsl:variable name="entry.colnum">
  768.     <xsl:call-template name="entry.colnum"/>
  769.   </xsl:variable>
  770.  
  771.   <xsl:variable name="entry.colspan">
  772.     <xsl:choose>
  773.       <xsl:when test="@spanname or @namest">
  774.         <xsl:call-template name="calculate.colspan"/>
  775.       </xsl:when>
  776.       <xsl:otherwise>1</xsl:otherwise>
  777.     </xsl:choose>
  778.   </xsl:variable>
  779.  
  780.   <xsl:variable name="following.spans">
  781.     <xsl:call-template name="calculate.following.spans">
  782.       <xsl:with-param name="colspan" select="$entry.colspan"/>
  783.       <xsl:with-param name="spans" select="$spans"/>
  784.     </xsl:call-template>
  785.   </xsl:variable>
  786.  
  787.   <xsl:choose>
  788.     <xsl:when test="$spans != '' and not(starts-with($spans,'0:'))">
  789.       <xsl:value-of select="substring-before($spans,':')-1"/>
  790.       <xsl:text>:</xsl:text>
  791.       <xsl:call-template name="sentry">
  792.         <xsl:with-param name="col" select="$col+1"/>
  793.         <xsl:with-param name="spans" select="substring-after($spans,':')"/>
  794.       </xsl:call-template>
  795.     </xsl:when>
  796.  
  797.     <xsl:when test="$entry.colnum > $col">
  798.       <xsl:text>0:</xsl:text>
  799.       <xsl:call-template name="sentry">
  800.         <xsl:with-param name="col" select="$col+$entry.colspan"/>
  801.         <xsl:with-param name="spans" select="$following.spans"/>
  802.       </xsl:call-template>
  803.     </xsl:when>
  804.  
  805.     <xsl:otherwise>
  806.       <xsl:call-template name="copy-string">
  807.         <xsl:with-param name="count" select="$entry.colspan"/>
  808.         <xsl:with-param name="string">
  809.           <xsl:choose>
  810.             <xsl:when test="@morerows">
  811.               <xsl:value-of select="@morerows"/>
  812.             </xsl:when>
  813.             <xsl:otherwise>0</xsl:otherwise>
  814.           </xsl:choose>
  815.           <xsl:text>:</xsl:text>
  816.         </xsl:with-param>
  817.       </xsl:call-template>
  818.  
  819.       <xsl:choose>
  820.         <xsl:when test="following-sibling::entry">
  821.           <xsl:apply-templates select="following-sibling::entry[1]"
  822.                                mode="span">
  823.             <xsl:with-param name="col" select="$col+$entry.colspan"/>
  824.             <xsl:with-param name="spans" select="$following.spans"/>
  825.           </xsl:apply-templates>
  826.         </xsl:when>
  827.         <xsl:otherwise>
  828.           <xsl:call-template name="sfinaltd">
  829.             <xsl:with-param name="spans" select="$following.spans"/>
  830.           </xsl:call-template>
  831.         </xsl:otherwise>
  832.       </xsl:choose>
  833.     </xsl:otherwise>
  834.   </xsl:choose>
  835. </xsl:template>
  836.  
  837. <xsl:template name="generate.colgroup">
  838.   <xsl:param name="cols" select="1"/>
  839.   <xsl:param name="count" select="1"/>
  840.   <xsl:choose>
  841.     <xsl:when test="$count > $cols"></xsl:when>
  842.     <xsl:otherwise>
  843.       <xsl:call-template name="generate.col">
  844.         <xsl:with-param name="countcol" select="$count"/>
  845.       </xsl:call-template>
  846.       <xsl:call-template name="generate.colgroup">
  847.         <xsl:with-param name="cols" select="$cols"/>
  848.         <xsl:with-param name="count" select="$count+1"/>
  849.       </xsl:call-template>
  850.     </xsl:otherwise>
  851.   </xsl:choose>
  852. </xsl:template>
  853.  
  854. <xsl:template name="generate.col">
  855.   <xsl:param name="countcol">1</xsl:param>
  856.   <xsl:param name="colspecs" select="./colspec"/>
  857.   <xsl:param name="count">1</xsl:param>
  858.   <xsl:param name="colnum">1</xsl:param>
  859.  
  860.   <xsl:choose>
  861.     <xsl:when test="$count>count($colspecs)">
  862.       <col/>
  863.     </xsl:when>
  864.     <xsl:otherwise>
  865.       <xsl:variable name="colspec" select="$colspecs[$count=position()]"/>
  866.       <xsl:variable name="colspec.colnum">
  867.         <xsl:choose>
  868.           <xsl:when test="$colspec/@colnum">
  869.             <xsl:value-of select="$colspec/@colnum"/>
  870.           </xsl:when>
  871.           <xsl:otherwise>
  872.             <xsl:value-of select="$colnum"/>
  873.           </xsl:otherwise>
  874.         </xsl:choose>
  875.       </xsl:variable>
  876.  
  877.       <xsl:choose>
  878.         <xsl:when test="$colspec.colnum=$countcol">
  879.           <col>
  880.             <xsl:if test="$colspec/@colwidth
  881.                           and $use.extensions != 0
  882.                           and $tablecolumns.extension != 0">
  883.               <xsl:attribute name="width">
  884.                 <xsl:value-of select="$colspec/@colwidth"/>
  885.               </xsl:attribute>
  886.             </xsl:if>
  887.  
  888.             <xsl:choose>
  889.               <xsl:when test="$colspec/@align">
  890.                 <xsl:attribute name="align">
  891.                   <xsl:value-of select="$colspec/@align"/>
  892.                 </xsl:attribute>
  893.               </xsl:when>
  894.               <!-- Suggested by Pavel ZAMPACH <zampach@nemcb.cz> -->
  895.               <xsl:when test="$colspecs/ancestor::tgroup/@align">
  896.                 <xsl:attribute name="align">
  897.                   <xsl:value-of select="$colspecs/ancestor::tgroup/@align"/>
  898.                 </xsl:attribute>
  899.               </xsl:when>
  900.             </xsl:choose>
  901.  
  902.             <xsl:if test="$colspec/@char">
  903.               <xsl:attribute name="char">
  904.                 <xsl:value-of select="$colspec/@char"/>
  905.               </xsl:attribute>
  906.             </xsl:if>
  907.             <xsl:if test="$colspec/@charoff">
  908.               <xsl:attribute name="charoff">
  909.                 <xsl:value-of select="$colspec/@charoff"/>
  910.               </xsl:attribute>
  911.             </xsl:if>
  912.           </col>
  913.         </xsl:when>
  914.         <xsl:otherwise>
  915.           <xsl:call-template name="generate.col">
  916.             <xsl:with-param name="countcol" select="$countcol"/>
  917.             <xsl:with-param name="colspecs" select="$colspecs"/>
  918.             <xsl:with-param name="count" select="$count+1"/>
  919.             <xsl:with-param name="colnum">
  920.               <xsl:choose>
  921.                 <xsl:when test="$colspec/@colnum">
  922.                   <xsl:value-of select="$colspec/@colnum + 1"/>
  923.                 </xsl:when>
  924.                 <xsl:otherwise>
  925.                   <xsl:value-of select="$colnum + 1"/>
  926.                 </xsl:otherwise>
  927.               </xsl:choose>
  928.             </xsl:with-param>
  929.            </xsl:call-template>
  930.         </xsl:otherwise>
  931.       </xsl:choose>
  932.     </xsl:otherwise>
  933.   </xsl:choose>
  934. </xsl:template>
  935.  
  936. <xsl:template name="colspec.colwidth">
  937.   <!-- when this macro is called, the current context must be an entry -->
  938.   <xsl:param name="colname"></xsl:param>
  939.   <!-- .. = row, ../.. = thead|tbody, ../../.. = tgroup -->
  940.   <xsl:param name="colspecs" select="../../../../tgroup/colspec"/>
  941.   <xsl:param name="count">1</xsl:param>
  942.   <xsl:choose>
  943.     <xsl:when test="$count>count($colspecs)"></xsl:when>
  944.     <xsl:otherwise>
  945.       <xsl:variable name="colspec" select="$colspecs[$count=position()]"/>
  946.       <xsl:choose>
  947.         <xsl:when test="$colspec/@colname=$colname">
  948.           <xsl:value-of select="$colspec/@colwidth"/>
  949.         </xsl:when>
  950.         <xsl:otherwise>
  951.           <xsl:call-template name="colspec.colwidth">
  952.             <xsl:with-param name="colname" select="$colname"/>
  953.             <xsl:with-param name="colspecs" select="$colspecs"/>
  954.             <xsl:with-param name="count" select="$count+1"/>
  955.           </xsl:call-template>
  956.         </xsl:otherwise>
  957.       </xsl:choose>
  958.     </xsl:otherwise>
  959.   </xsl:choose>
  960. </xsl:template>
  961.  
  962. <!-- ====================================================================== -->
  963.  
  964. <xsl:template name="tr.attributes">
  965.   <xsl:param name="row" select="."/>
  966.   <xsl:param name="rownum" select="0"/>
  967.  
  968.   <!-- by default, do nothing. But you might want to say:
  969.  
  970.   <xsl:if test="$rownum mod 2 = 0">
  971.     <xsl:attribute name="class">oddrow</xsl:attribute>
  972.   </xsl:if>
  973.  
  974.   -->
  975. </xsl:template>
  976.  
  977. </xsl:stylesheet>
  978.  
  979.