| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209 | <?xml version='1.0'?><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"                xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"                xmlns:stbl="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.Table"                xmlns:xtbl="xalan://com.nwalsh.xalan.Table"                xmlns:lxslt="http://xml.apache.org/xslt"                xmlns:ptbl="http://nwalsh.com/xslt/ext/xsltproc/python/Table"                exclude-result-prefixes="doc stbl xtbl lxslt ptbl"                version='1.0'><xsl:include href="../common/table.xsl"/><!-- ********************************************************************     $Id: table.xsl 9297 2012-04-22 03:56:16Z bobstayton $     ********************************************************************     This file is part of the XSL DocBook Stylesheet distribution.     See ../README or http://docbook.sf.net/release/xsl/current/ for     copyright and other information.     ******************************************************************** --><lxslt:component prefix="xtbl"                 functions="adjustColumnWidths"/><xsl:template name="empty.table.cell">  <xsl:param name="colnum" select="0"/>  <xsl:variable name="rowsep">    <xsl:choose>      <!-- If this is the last row, rowsep never applies. -->      <xsl:when test="not(ancestor-or-self::row[1]/following-sibling::row                          or ancestor-or-self::thead/following-sibling::tbody                          or ancestor-or-self::tbody/preceding-sibling::tfoot)">        <xsl:value-of select="0"/>      </xsl:when>      <xsl:otherwise>        <xsl:call-template name="inherited.table.attribute">          <xsl:with-param name="entry" select="NOT-AN-ELEMENT-NAME"/>          <xsl:with-param name="row" select="ancestor-or-self::row[1]"/>          <xsl:with-param name="colnum" select="$colnum"/>          <xsl:with-param name="attribute" select="'rowsep'"/>        </xsl:call-template>      </xsl:otherwise>    </xsl:choose>  </xsl:variable>  <xsl:variable name="colsep">    <xsl:choose>      <!-- If this is the last column, colsep never applies. -->      <xsl:when test="number($colnum) >= ancestor::tgroup/@cols">0</xsl:when>      <xsl:otherwise>        <xsl:call-template name="inherited.table.attribute">          <xsl:with-param name="entry" select="NOT-AN-ELEMENT-NAME"/>          <xsl:with-param name="row" select="ancestor-or-self::row[1]"/>          <xsl:with-param name="colnum" select="$colnum"/>          <xsl:with-param name="attribute" select="'colsep'"/>        </xsl:call-template>      </xsl:otherwise>    </xsl:choose>  </xsl:variable>  <td class="auto-generated">    <xsl:if test="$table.borders.with.css != 0">      <xsl:attribute name="style">        <xsl:if test="$colsep > 0">          <xsl:call-template name="border">            <xsl:with-param name="side" select="'right'"/>          </xsl:call-template>        </xsl:if>        <xsl:if test="$rowsep > 0">          <xsl:call-template name="border">            <xsl:with-param name="side" select="'bottom'"/>          </xsl:call-template>        </xsl:if>      </xsl:attribute>    </xsl:if>    <xsl:text> </xsl:text>  </td></xsl:template><!-- ==================================================================== --><xsl:template name="border">  <xsl:param name="side" select="'left'"/>  <xsl:param name="padding" select="0"/>  <xsl:param name="style" select="$table.cell.border.style"/>  <xsl:param name="color" select="$table.cell.border.color"/>  <xsl:param name="thickness" select="$table.cell.border.thickness"/>  <!-- Note: Some browsers (mozilla) require at least a width and style. -->  <xsl:choose>    <xsl:when test="($thickness != ''                     and $style != ''                     and $color != '')                    or ($thickness != ''                        and $style != '')                    or ($thickness != '')">      <!-- use the compound property if we can: -->      <!-- it saves space and probably works more reliably -->      <xsl:text>border-</xsl:text>      <xsl:value-of select="$side"/>      <xsl:text>: </xsl:text>      <xsl:value-of select="$thickness"/>      <xsl:text> </xsl:text>      <xsl:value-of select="$style"/>      <xsl:text> </xsl:text>      <xsl:value-of select="$color"/>      <xsl:text>; </xsl:text>    </xsl:when>    <xsl:otherwise>      <!-- we need to specify the styles individually -->      <xsl:if test="$thickness != ''">        <xsl:text>border-</xsl:text>        <xsl:value-of select="$side"/>        <xsl:text>-width: </xsl:text>        <xsl:value-of select="$thickness"/>        <xsl:text>; </xsl:text>      </xsl:if>      <xsl:if test="$style != ''">        <xsl:text>border-</xsl:text>        <xsl:value-of select="$side"/>        <xsl:text>-style: </xsl:text>        <xsl:value-of select="$style"/>        <xsl:text>; </xsl:text>      </xsl:if>      <xsl:if test="$color != ''">        <xsl:text>border-</xsl:text>        <xsl:value-of select="$side"/>        <xsl:text>-color: </xsl:text>        <xsl:value-of select="$color"/>        <xsl:text>; </xsl:text>      </xsl:if>    </xsl:otherwise>  </xsl:choose></xsl:template><!-- ==================================================================== --><xsl:template match="tgroup" name="tgroup">  <xsl:if test="not(@cols) or @cols = '' or string(number(@cols)) = 'NaN'">    <xsl:message terminate="yes">      <xsl:text>Error: CALS tables must specify the number of columns.</xsl:text>    </xsl:message>  </xsl:if>  <xsl:variable name="summary">    <xsl:call-template name="pi.dbhtml_table-summary"/>  </xsl:variable>  <xsl:variable name="cellspacing">    <xsl:call-template name="pi.dbhtml_cellspacing"/>  </xsl:variable>  <xsl:variable name="cellpadding">    <xsl:call-template name="pi.dbhtml_cellpadding"/>  </xsl:variable>  <table>    <xsl:choose>      <!-- If there's a textobject/phrase for the table summary, use it -->      <xsl:when test="../textobject/phrase">        <xsl:attribute name="summary">          <xsl:value-of select="../textobject/phrase"/>        </xsl:attribute>      </xsl:when>      <!-- If there's a <?dbhtml table-summary="foo"?> PI, use it for           the HTML table summary attribute -->      <xsl:when test="$summary != ''">        <xsl:attribute name="summary">          <xsl:value-of select="$summary"/>        </xsl:attribute>      </xsl:when>      <!-- Otherwise, if there's a title, use that -->      <xsl:when test="../title">        <xsl:attribute name="summary">          <!-- This screws up on inline markup and footnotes, oh well... -->          <xsl:value-of select="string(../title)"/>        </xsl:attribute>      </xsl:when>      <!-- Otherwise, forget the whole idea -->      <xsl:otherwise><!-- nevermind --></xsl:otherwise>    </xsl:choose>    <xsl:if test="$cellspacing != '' or $html.cellspacing != ''">      <xsl:attribute name="cellspacing">        <xsl:choose>          <xsl:when test="$cellspacing != ''">            <xsl:value-of select="$cellspacing"/>          </xsl:when>          <xsl:otherwise>            <xsl:value-of select="$html.cellspacing"/>          </xsl:otherwise>        </xsl:choose>      </xsl:attribute>    </xsl:if>    <xsl:if test="$cellpadding != '' or $html.cellpadding != ''">      <xsl:attribute name="cellpadding">        <xsl:choose>          <xsl:when test="$cellpadding != ''">            <xsl:value-of select="$cellpadding"/>          </xsl:when>          <xsl:otherwise>            <xsl:value-of select="$html.cellpadding"/>          </xsl:otherwise>        </xsl:choose>      </xsl:attribute>    </xsl:if>    <xsl:if test="../@pgwide=1 or local-name(.) = 'entrytbl'">      <xsl:attribute name="width">100%</xsl:attribute>    </xsl:if>    <xsl:choose>      <xsl:when test="$table.borders.with.css != 0">        <xsl:choose>          <xsl:when test="../@frame='all' or (not(../@frame) and $default.table.frame='all')">            <xsl:attribute name="style">              <xsl:text>border-collapse: collapse;</xsl:text>              <xsl:call-template name="border">                <xsl:with-param name="side" select="'top'"/>                <xsl:with-param name="style" select="$table.frame.border.style"/>                <xsl:with-param name="color" select="$table.frame.border.color"/>                <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>              </xsl:call-template>              <xsl:call-template name="border">                <xsl:with-param name="side" select="'bottom'"/>                <xsl:with-param name="style" select="$table.frame.border.style"/>                <xsl:with-param name="color" select="$table.frame.border.color"/>                <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>              </xsl:call-template>              <xsl:call-template name="border">                <xsl:with-param name="side" select="'left'"/>                <xsl:with-param name="style" select="$table.frame.border.style"/>                <xsl:with-param name="color" select="$table.frame.border.color"/>                <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>              </xsl:call-template>              <xsl:call-template name="border">                <xsl:with-param name="side" select="'right'"/>                <xsl:with-param name="style" select="$table.frame.border.style"/>                <xsl:with-param name="color" select="$table.frame.border.color"/>                <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>              </xsl:call-template>            </xsl:attribute>          </xsl:when>          <xsl:when test="../@frame='topbot' or (not(../@frame) and $default.table.frame='topbot')">            <xsl:attribute name="style">              <xsl:text>border-collapse: collapse;</xsl:text>              <xsl:call-template name="border">                <xsl:with-param name="side" select="'top'"/>                <xsl:with-param name="style" select="$table.frame.border.style"/>                <xsl:with-param name="color" select="$table.frame.border.color"/>                <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>              </xsl:call-template>              <xsl:call-template name="border">                <xsl:with-param name="side" select="'bottom'"/>                <xsl:with-param name="style" select="$table.frame.border.style"/>                <xsl:with-param name="color" select="$table.frame.border.color"/>                <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>              </xsl:call-template>            </xsl:attribute>          </xsl:when>          <xsl:when test="../@frame='top' or (not(../@frame) and $default.table.frame='top')">            <xsl:attribute name="style">              <xsl:text>border-collapse: collapse;</xsl:text>              <xsl:call-template name="border">                <xsl:with-param name="side" select="'top'"/>                <xsl:with-param name="style" select="$table.frame.border.style"/>                <xsl:with-param name="color" select="$table.frame.border.color"/>                <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>              </xsl:call-template>            </xsl:attribute>          </xsl:when>          <xsl:when test="../@frame='bottom' or (not(../@frame) and $default.table.frame='bottom')">            <xsl:attribute name="style">              <xsl:text>border-collapse: collapse;</xsl:text>              <xsl:call-template name="border">                <xsl:with-param name="side" select="'bottom'"/>                <xsl:with-param name="style" select="$table.frame.border.style"/>                <xsl:with-param name="color" select="$table.frame.border.color"/>                <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>              </xsl:call-template>            </xsl:attribute>          </xsl:when>          <xsl:when test="../@frame='sides' or (not(../@frame) and $default.table.frame='sides')">            <xsl:attribute name="style">              <xsl:text>border-collapse: collapse;</xsl:text>              <xsl:call-template name="border">                <xsl:with-param name="side" select="'left'"/>                <xsl:with-param name="style" select="$table.frame.border.style"/>                <xsl:with-param name="color" select="$table.frame.border.color"/>                <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>              </xsl:call-template>              <xsl:call-template name="border">                <xsl:with-param name="side" select="'right'"/>                <xsl:with-param name="style" select="$table.frame.border.style"/>                <xsl:with-param name="color" select="$table.frame.border.color"/>                <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>              </xsl:call-template>            </xsl:attribute>          </xsl:when>          <xsl:when test="../@frame='none'">            <xsl:attribute name="style">              <xsl:text>border: none;</xsl:text>            </xsl:attribute>          </xsl:when>          <xsl:otherwise>            <xsl:attribute name="style">              <xsl:text>border-collapse: collapse;</xsl:text>            </xsl:attribute>          </xsl:otherwise>        </xsl:choose>      </xsl:when>      <xsl:when test="../@frame='none' or (not(../@frame) and $default.table.frame='none') or local-name(.) = 'entrytbl'">        <xsl:attribute name="border">0</xsl:attribute>      </xsl:when>      <xsl:otherwise>        <xsl:attribute name="border">1</xsl:attribute>      </xsl:otherwise>    </xsl:choose>    <xsl:variable name="colgroup">      <colgroup>        <xsl:call-template name="generate.colgroup">          <xsl:with-param name="cols" select="@cols"/>        </xsl:call-template>      </colgroup>    </xsl:variable>    <xsl:variable name="explicit.table.width">      <xsl:call-template name="pi.dbhtml_table-width">        <xsl:with-param name="node" select=".."/>      </xsl:call-template>    </xsl:variable>    <xsl:variable name="table.width">      <xsl:choose>        <xsl:when test="$explicit.table.width != ''">          <xsl:value-of select="$explicit.table.width"/>        </xsl:when>        <xsl:when test="$default.table.width = ''">          <xsl:text>100%</xsl:text>        </xsl:when>        <xsl:otherwise>          <xsl:value-of select="$default.table.width"/>        </xsl:otherwise>      </xsl:choose>    </xsl:variable>    <xsl:if test="$default.table.width != ''                  or $explicit.table.width != ''">      <xsl:attribute name="width">        <xsl:choose>          <xsl:when test="contains($table.width, '%')">            <xsl:value-of select="$table.width"/>          </xsl:when>          <xsl:when test="$use.extensions != 0                          and $tablecolumns.extension != 0">            <xsl:choose>              <xsl:when test="function-available('stbl:convertLength')">                <xsl:value-of select="stbl:convertLength($table.width)"/>              </xsl:when>              <xsl:when test="function-available('xtbl:convertLength')">                <xsl:value-of select="xtbl:convertLength($table.width)"/>              </xsl:when>              <xsl:otherwise>                <xsl:message terminate="yes">                  <xsl:text>No convertLength function available.</xsl:text>                </xsl:message>              </xsl:otherwise>            </xsl:choose>          </xsl:when>          <xsl:otherwise>            <xsl:value-of select="$table.width"/>          </xsl:otherwise>        </xsl:choose>      </xsl:attribute>    </xsl:if>    <xsl:choose>      <xsl:when test="$use.extensions != 0                      and $tablecolumns.extension != 0">        <xsl:choose>          <xsl:when test="function-available('stbl:adjustColumnWidths')">            <xsl:copy-of select="stbl:adjustColumnWidths($colgroup)"/>          </xsl:when>          <xsl:when test="function-available('xtbl:adjustColumnWidths')">            <xsl:copy-of select="xtbl:adjustColumnWidths($colgroup)"/>          </xsl:when>          <xsl:when test="function-available('ptbl:adjustColumnWidths')">            <xsl:copy-of select="ptbl:adjustColumnWidths($colgroup)"/>          </xsl:when>          <xsl:otherwise>            <xsl:message terminate="yes">              <xsl:text>No adjustColumnWidths function available.</xsl:text>            </xsl:message>          </xsl:otherwise>        </xsl:choose>      </xsl:when>      <xsl:otherwise>        <xsl:copy-of select="$colgroup"/>      </xsl:otherwise>    </xsl:choose>    <xsl:apply-templates select="thead"/>    <xsl:apply-templates select="tfoot"/>    <xsl:apply-templates select="tbody"/>    <xsl:if test=".//footnote|../title//footnote">      <tbody class="footnotes">        <tr>          <td colspan="{@cols}">            <xsl:apply-templates select=".//footnote|../title//footnote" mode="table.footnote.mode"/>          </td>        </tr>      </tbody>    </xsl:if>  </table></xsl:template><xsl:template match="tgroup/processing-instruction('dbhtml')">  <xsl:variable name="summary">    <xsl:call-template name="pi.dbhtml_table-summary"/>  </xsl:variable>  <!-- Suppress the table-summary PI -->  <xsl:if test="$summary = ''">    <xsl:processing-instruction name="dbhtml">      <xsl:value-of select="."/>    </xsl:processing-instruction>  </xsl:if></xsl:template><xsl:template match="colspec"></xsl:template><xsl:template match="spanspec"></xsl:template><xsl:template match="thead|tfoot">  <xsl:element name="{local-name(.)}">    <xsl:if test="@align">      <xsl:attribute name="align">        <xsl:value-of select="@align"/>      </xsl:attribute>    </xsl:if>    <xsl:if test="@char">      <xsl:attribute name="char">        <xsl:value-of select="@char"/>      </xsl:attribute>    </xsl:if>    <xsl:if test="@charoff">      <xsl:attribute name="charoff">        <xsl:value-of select="@charoff"/>      </xsl:attribute>    </xsl:if>    <xsl:if test="@valign">      <xsl:attribute name="valign">        <xsl:value-of select="@valign"/>      </xsl:attribute>    </xsl:if>    <xsl:choose>      <!-- recurse on rows only if @morerows is present -->      <xsl:when test="row/entry/@morerows|row/entrytbl/@morerows">        <xsl:apply-templates select="row[1]">          <xsl:with-param name="spans">            <xsl:call-template name="blank.spans">              <xsl:with-param name="cols" select="../@cols"/>            </xsl:call-template>          </xsl:with-param>          <xsl:with-param name="browserows" select="'recurse'"/>        </xsl:apply-templates>      </xsl:when>      <xsl:otherwise>        <xsl:apply-templates select="row">          <xsl:with-param name="spans">            <xsl:call-template name="blank.spans">              <xsl:with-param name="cols" select="../@cols"/>            </xsl:call-template>          </xsl:with-param>          <xsl:with-param name="browserows" select="'loop'" />        </xsl:apply-templates>      </xsl:otherwise>    </xsl:choose>  </xsl:element></xsl:template><xsl:template match="tbody">  <tbody>    <xsl:if test="@align">      <xsl:attribute name="align">        <xsl:value-of select="@align"/>      </xsl:attribute>    </xsl:if>    <xsl:if test="@char">      <xsl:attribute name="char">        <xsl:value-of select="@char"/>      </xsl:attribute>    </xsl:if>    <xsl:if test="@charoff">      <xsl:attribute name="charoff">        <xsl:value-of select="@charoff"/>      </xsl:attribute>    </xsl:if>    <xsl:if test="@valign">      <xsl:attribute name="valign">        <xsl:value-of select="@valign"/>      </xsl:attribute>    </xsl:if>    <xsl:choose>      <xsl:when test="row/entry/@morerows|row/entrytbl/@morerows">        <xsl:apply-templates select="row[1]">          <xsl:with-param name="spans">            <xsl:call-template name="blank.spans">              <xsl:with-param name="cols" select="../@cols"/>            </xsl:call-template>          </xsl:with-param>          <xsl:with-param name="browserows" select="'recurse'"/>        </xsl:apply-templates>      </xsl:when>      <xsl:otherwise>        <xsl:apply-templates select="row">          <xsl:with-param name="spans">            <xsl:call-template name="blank.spans">              <xsl:with-param name="cols" select="../@cols"/>            </xsl:call-template>          </xsl:with-param>          <xsl:with-param name="browserows" select="'loop'" />        </xsl:apply-templates>      </xsl:otherwise>    </xsl:choose>  </tbody></xsl:template><xsl:template match="row">  <xsl:param name="spans"/>  <xsl:param name="browserows"/>  <xsl:choose>    <xsl:when test="contains($spans, '0')">      <xsl:call-template name="normal-row">        <xsl:with-param name="spans" select="$spans"/>        <xsl:with-param name="browserows" select="$browserows"/>      </xsl:call-template>    </xsl:when>    <xsl:otherwise>      <!--      <xsl:message>        <xsl:text>Ignoring row: </xsl:text>        <xsl:value-of select="$spans"/>        <xsl:text> = </xsl:text>        <xsl:call-template name="consume-row">          <xsl:with-param name="spans" select="$spans"/>        </xsl:call-template>      </xsl:message>      -->      <xsl:if test="normalize-space(.//text()) != ''">        <xsl:message>Warning: overlapped row contains content!</xsl:message>      </xsl:if>      <tr><xsl:comment> This row intentionally left blank </xsl:comment></tr>      <xsl:if test="$browserows = 'recurse'">        <xsl:apply-templates select="following-sibling::row[1]">          <xsl:with-param name="spans">            <xsl:call-template name="consume-row">              <xsl:with-param name="spans" select="$spans"/>            </xsl:call-template>          </xsl:with-param>          <xsl:with-param name="browserows" select="$browserows"/>        </xsl:apply-templates>      </xsl:if>    </xsl:otherwise>  </xsl:choose></xsl:template><xsl:template name="normal-row">  <xsl:param name="spans"/>  <xsl:param name="browserows"/>  <xsl:variable name="row-height">    <xsl:if test="processing-instruction('dbhtml')">      <xsl:call-template name="pi.dbhtml_row-height"/>    </xsl:if>  </xsl:variable>  <xsl:variable name="bgcolor">    <xsl:if test="processing-instruction('dbhtml')">      <xsl:call-template name="pi.dbhtml_bgcolor"/>    </xsl:if>  </xsl:variable>  <xsl:variable name="class">    <xsl:if test="processing-instruction('dbhtml')">      <xsl:call-template name="pi.dbhtml_class"/>    </xsl:if>  </xsl:variable>  <tr>    <xsl:call-template name="id.attribute"/>    <xsl:call-template name="tr.attributes">      <xsl:with-param name="rownum">        <xsl:number from="tgroup" count="row"/>      </xsl:with-param>    </xsl:call-template>    <xsl:if test="$row-height != ''">      <xsl:attribute name="height">        <xsl:value-of select="$row-height"/>      </xsl:attribute>    </xsl:if>    <xsl:if test="$bgcolor != ''">      <xsl:attribute name="bgcolor">        <xsl:value-of select="$bgcolor"/>      </xsl:attribute>    </xsl:if>    <xsl:if test="$class != ''">      <xsl:attribute name="class">        <xsl:value-of select="$class"/>      </xsl:attribute>    </xsl:if>    <xsl:if test="$table.borders.with.css != 0">      <xsl:if test="@rowsep = 1 and following-sibling::row">        <xsl:attribute name="style">          <xsl:call-template name="border">            <xsl:with-param name="side" select="'bottom'"/>          </xsl:call-template>        </xsl:attribute>      </xsl:if>    </xsl:if>    <xsl:if test="@align">      <xsl:attribute name="align">        <xsl:value-of select="@align"/>      </xsl:attribute>    </xsl:if>    <xsl:if test="@char">      <xsl:attribute name="char">        <xsl:value-of select="@char"/>      </xsl:attribute>    </xsl:if>    <xsl:if test="@charoff">      <xsl:attribute name="charoff">        <xsl:value-of select="@charoff"/>      </xsl:attribute>    </xsl:if>    <xsl:if test="@valign">      <xsl:attribute name="valign">        <xsl:value-of select="@valign"/>      </xsl:attribute>    </xsl:if>    <xsl:apply-templates select="(entry|entrytbl)[1]">      <xsl:with-param name="spans" select="$spans"/>    </xsl:apply-templates>  </tr>  <xsl:if test="$browserows = 'recurse'">    <xsl:if test="following-sibling::row">      <xsl:variable name="nextspans">        <xsl:apply-templates select="(entry|entrytbl)[1]" mode="span">          <xsl:with-param name="spans" select="$spans"/>        </xsl:apply-templates>      </xsl:variable>        <xsl:apply-templates select="following-sibling::row[1]">        <xsl:with-param name="spans" select="$nextspans"/>        <xsl:with-param name="browserows" select="$browserows"/>      </xsl:apply-templates>    </xsl:if>  </xsl:if></xsl:template><xsl:template match="entry|entrytbl" name="entry">  <xsl:param name="col">    <xsl:choose>      <xsl:when test="@revisionflag">        <xsl:number from="row"/>      </xsl:when>      <xsl:otherwise>1</xsl:otherwise>    </xsl:choose>  </xsl:param>  <xsl:param name="spans"/>  <xsl:variable name="cellgi">    <xsl:choose>      <xsl:when test="ancestor::thead">th</xsl:when>      <xsl:when test="ancestor::tfoot">th</xsl:when>      <xsl:when test="ancestor::tbody and                       (ancestor::table[@rowheader = 'firstcol'] or                      ancestor::informaltable[@rowheader = 'firstcol']) and                      ancestor-or-self::entry[1][count(preceding-sibling::entry) = 0]">        <xsl:text>th</xsl:text>      </xsl:when>      <xsl:otherwise>td</xsl:otherwise>    </xsl:choose>  </xsl:variable>  <xsl:variable name="empty.cell" select="count(node()) = 0"/>  <xsl:variable name="named.colnum">    <xsl:call-template name="entry.colnum"/>  </xsl:variable>  <xsl:variable name="entry.colnum">    <xsl:choose>      <xsl:when test="$named.colnum > 0">        <xsl:value-of select="$named.colnum"/>      </xsl:when>      <xsl:otherwise>        <xsl:value-of select="$col"/>      </xsl:otherwise>    </xsl:choose>  </xsl:variable>  <xsl:variable name="entry.colspan">    <xsl:choose>      <xsl:when test="@spanname or @namest">        <xsl:call-template name="calculate.colspan"/>      </xsl:when>      <xsl:otherwise>1</xsl:otherwise>    </xsl:choose>  </xsl:variable>  <xsl:variable name="following.spans">    <xsl:call-template name="calculate.following.spans">      <xsl:with-param name="colspan" select="$entry.colspan"/>      <xsl:with-param name="spans" select="$spans"/>    </xsl:call-template>  </xsl:variable>  <xsl:variable name="rowsep">    <xsl:choose>      <!-- If this is the last row, rowsep never applies. -->      <xsl:when test="ancestor::entrytbl                      and not (ancestor-or-self::row[1]/following-sibling::row)                      and not (ancestor::thead)">        <xsl:value-of select="0"/>      </xsl:when>      <xsl:when test="not(ancestor-or-self::row[1]/following-sibling::row                          or ancestor-or-self::thead/following-sibling::tbody                          or ancestor-or-self::tbody/preceding-sibling::tfoot)">        <xsl:value-of select="0"/>      </xsl:when>      <xsl:when test="@morerows and not(@morerows <                  count(ancestor-or-self::row[1]/following-sibling::row))">        <xsl:value-of select="0"/>      </xsl:when>      <xsl:otherwise>        <xsl:call-template name="inherited.table.attribute">          <xsl:with-param name="entry" select="."/>          <xsl:with-param name="colnum" select="$entry.colnum"/>          <xsl:with-param name="attribute" select="'rowsep'"/>        </xsl:call-template>      </xsl:otherwise>    </xsl:choose>  </xsl:variable>  <xsl:variable name="colsep">    <xsl:choose>      <!-- If this is the last column, colsep never applies. -->      <xsl:when test="$following.spans = ''">0</xsl:when>      <xsl:otherwise>        <xsl:call-template name="inherited.table.attribute">          <xsl:with-param name="entry" select="."/>          <xsl:with-param name="colnum" select="$entry.colnum"/>          <xsl:with-param name="attribute" select="'colsep'"/>        </xsl:call-template>      </xsl:otherwise>    </xsl:choose>  </xsl:variable>  <xsl:variable name="valign">    <xsl:call-template name="inherited.table.attribute">      <xsl:with-param name="entry" select="."/>      <xsl:with-param name="colnum" select="$entry.colnum"/>      <xsl:with-param name="attribute" select="'valign'"/>    </xsl:call-template>  </xsl:variable>  <xsl:variable name="align">    <xsl:call-template name="inherited.table.attribute">      <xsl:with-param name="entry" select="."/>      <xsl:with-param name="colnum" select="$entry.colnum"/>      <xsl:with-param name="attribute" select="'align'"/>    </xsl:call-template>  </xsl:variable>  <xsl:variable name="char">    <xsl:call-template name="inherited.table.attribute">      <xsl:with-param name="entry" select="."/>      <xsl:with-param name="colnum" select="$entry.colnum"/>      <xsl:with-param name="attribute" select="'char'"/>    </xsl:call-template>  </xsl:variable>  <xsl:variable name="charoff">    <xsl:call-template name="inherited.table.attribute">      <xsl:with-param name="entry" select="."/>      <xsl:with-param name="colnum" select="$entry.colnum"/>      <xsl:with-param name="attribute" select="'charoff'"/>    </xsl:call-template>  </xsl:variable>  <xsl:choose>    <xsl:when test="$spans != '' and not(starts-with($spans,'0:'))">      <xsl:call-template name="entry">        <xsl:with-param name="col" select="$col+1"/>        <xsl:with-param name="spans" select="substring-after($spans,':')"/>      </xsl:call-template>    </xsl:when>    <xsl:when test="number($entry.colnum) > $col">      <xsl:call-template name="empty.table.cell"/>      <xsl:call-template name="entry">        <xsl:with-param name="col" select="$col+1"/>        <xsl:with-param name="spans" select="substring-after($spans,':')"/>      </xsl:call-template>    </xsl:when>    <xsl:otherwise>      <xsl:variable name="bgcolor">        <xsl:if test="processing-instruction('dbhtml')">          <xsl:call-template name="pi.dbhtml_bgcolor"/>        </xsl:if>      </xsl:variable>      <xsl:element name="{$cellgi}">        <xsl:call-template name="id.attribute"/>        <xsl:if test="$bgcolor != ''">          <xsl:attribute name="bgcolor">            <xsl:value-of select="$bgcolor"/>          </xsl:attribute>        </xsl:if>        <xsl:call-template name="locale.html.attributes"/>        <xsl:choose>          <xsl:when test="$entry.propagates.style != 0 and @role">            <xsl:apply-templates select="." mode="class.attribute">              <xsl:with-param name="class" select="@role"/>            </xsl:apply-templates>          </xsl:when>          <xsl:otherwise>            <xsl:apply-templates select="." mode="class.attribute">              <xsl:with-param name="class" select="''"/>            </xsl:apply-templates>          </xsl:otherwise>        </xsl:choose>        <xsl:if test="$show.revisionflag and @revisionflag">          <xsl:attribute name="class">            <xsl:value-of select="@revisionflag"/>          </xsl:attribute>        </xsl:if>        <xsl:if test="$table.borders.with.css != 0">          <xsl:attribute name="style">            <xsl:if test="$colsep > 0">              <xsl:call-template name="border">                <xsl:with-param name="side" select="'right'"/>              </xsl:call-template>            </xsl:if>            <xsl:if test="$rowsep > 0">              <xsl:call-template name="border">                <xsl:with-param name="side" select="'bottom'"/>              </xsl:call-template>            </xsl:if>          </xsl:attribute>        </xsl:if>        <xsl:if test="@morerows > 0">          <xsl:attribute name="rowspan">            <xsl:value-of select="1+@morerows"/>          </xsl:attribute>        </xsl:if>        <xsl:if test="$entry.colspan > 1">          <xsl:attribute name="colspan">            <xsl:value-of select="$entry.colspan"/>          </xsl:attribute>        </xsl:if>        <xsl:if test="$align != ''">          <xsl:attribute name="align">            <xsl:value-of select="$align"/>          </xsl:attribute>        </xsl:if>        <xsl:if test="$valign != ''">          <xsl:attribute name="valign">            <xsl:value-of select="$valign"/>          </xsl:attribute>        </xsl:if>        <xsl:if test="$char != ''">          <xsl:attribute name="char">            <xsl:value-of select="$char"/>          </xsl:attribute>        </xsl:if>        <xsl:if test="$charoff != ''">          <xsl:attribute name="charoff">            <xsl:value-of select="$charoff"/>          </xsl:attribute>        </xsl:if>        <xsl:if test="not(preceding-sibling::*) and                     (ancestor::row[1]/@id or ancestor::row[1]/@xml:id)">          <xsl:call-template name="anchor">            <xsl:with-param name="node" select="ancestor::row[1]"/>          </xsl:call-template>        </xsl:if>        <xsl:call-template name="anchor"/>        <xsl:choose>          <xsl:when test="$empty.cell">            <xsl:text> </xsl:text>          </xsl:when>          <xsl:when test="self::entrytbl">            <xsl:call-template name="tgroup"/>          </xsl:when>          <xsl:otherwise>            <xsl:apply-templates/>          </xsl:otherwise>        </xsl:choose>      </xsl:element>      <xsl:choose>        <xsl:when test="following-sibling::entry|following-sibling::entrytbl">          <xsl:apply-templates select="(following-sibling::entry                                       |following-sibling::entrytbl)[1]">            <xsl:with-param name="col" select="$col+$entry.colspan"/>            <xsl:with-param name="spans" select="$following.spans"/>          </xsl:apply-templates>        </xsl:when>        <xsl:otherwise>          <xsl:call-template name="finaltd">            <xsl:with-param name="spans" select="$following.spans"/>            <xsl:with-param name="col" select="$col+$entry.colspan"/>          </xsl:call-template>        </xsl:otherwise>      </xsl:choose>    </xsl:otherwise>  </xsl:choose></xsl:template><xsl:template match="entry|entrytbl" name="sentry" mode="span">  <xsl:param name="col" select="1"/>  <xsl:param name="spans"/>  <xsl:variable name="entry.colnum">    <xsl:call-template name="entry.colnum"/>  </xsl:variable>  <xsl:variable name="entry.colspan">    <xsl:choose>      <xsl:when test="@spanname or @namest">        <xsl:call-template name="calculate.colspan"/>      </xsl:when>      <xsl:otherwise>1</xsl:otherwise>    </xsl:choose>  </xsl:variable>  <xsl:variable name="following.spans">    <xsl:call-template name="calculate.following.spans">      <xsl:with-param name="colspan" select="$entry.colspan"/>      <xsl:with-param name="spans" select="$spans"/>    </xsl:call-template>  </xsl:variable>  <xsl:choose>    <xsl:when test="$spans != '' and not(starts-with($spans,'0:'))">      <xsl:value-of select="substring-before($spans,':')-1"/>      <xsl:text>:</xsl:text>      <xsl:call-template name="sentry">        <xsl:with-param name="col" select="$col+1"/>        <xsl:with-param name="spans" select="substring-after($spans,':')"/>      </xsl:call-template>    </xsl:when>    <xsl:when test="number($entry.colnum) > $col">      <xsl:text>0:</xsl:text>      <xsl:call-template name="sentry">        <xsl:with-param name="col" select="$col + 1"/>        <xsl:with-param name="spans" select="substring-after($spans,':')"/>      </xsl:call-template>    </xsl:when>    <xsl:otherwise>      <xsl:call-template name="copy-string">        <xsl:with-param name="count" select="$entry.colspan"/>        <xsl:with-param name="string">          <xsl:choose>            <xsl:when test="@morerows">              <xsl:value-of select="@morerows"/>            </xsl:when>            <xsl:otherwise>0</xsl:otherwise>          </xsl:choose>          <xsl:text>:</xsl:text>        </xsl:with-param>      </xsl:call-template>      <xsl:choose>        <xsl:when test="following-sibling::entry|following-sibling::entrytbl">          <xsl:apply-templates select="(following-sibling::entry                                        |following-sibling::entrytbl)[1]"                               mode="span">            <xsl:with-param name="col" select="$col+$entry.colspan"/>            <xsl:with-param name="spans" select="$following.spans"/>          </xsl:apply-templates>        </xsl:when>        <xsl:otherwise>          <xsl:call-template name="sfinaltd">            <xsl:with-param name="spans" select="$following.spans"/>          </xsl:call-template>        </xsl:otherwise>      </xsl:choose>    </xsl:otherwise>  </xsl:choose></xsl:template><xsl:template name="generate.colgroup">  <xsl:param name="cols" select="1"/>  <xsl:param name="count" select="1"/>  <xsl:choose>    <xsl:when test="$count > $cols"></xsl:when>    <xsl:otherwise>      <xsl:call-template name="generate.col">        <xsl:with-param name="countcol" select="$count"/>      </xsl:call-template>      <xsl:call-template name="generate.colgroup">        <xsl:with-param name="cols" select="$cols"/>        <xsl:with-param name="count" select="$count+1"/>      </xsl:call-template>    </xsl:otherwise>  </xsl:choose></xsl:template><xsl:template name="generate.col">  <xsl:param name="countcol">1</xsl:param>  <xsl:param name="colspecs" select="./colspec"/>  <xsl:param name="count">1</xsl:param>  <xsl:param name="colnum">1</xsl:param>  <xsl:choose>    <xsl:when test="$count>count($colspecs)">      <col/>    </xsl:when>    <xsl:otherwise>      <xsl:variable name="colspec" select="$colspecs[$count=position()]"/>      <xsl:variable name="colspec.colnum">        <xsl:choose>          <xsl:when test="$colspec/@colnum">            <xsl:value-of select="$colspec/@colnum"/>          </xsl:when>          <xsl:otherwise>            <xsl:value-of select="$colnum"/>          </xsl:otherwise>        </xsl:choose>      </xsl:variable>      <xsl:choose>        <xsl:when test="$colspec.colnum=$countcol">          <col>            <xsl:choose>              <xsl:when test="$colspec/@colwidth                            and $use.extensions != 0                            and $tablecolumns.extension != 0">                <xsl:attribute name="width">                  <xsl:choose>                    <xsl:when test="normalize-space($colspec/@colwidth) = '*'">                      <xsl:value-of select="'1*'"/>                    </xsl:when>                    <xsl:otherwise>                      <xsl:value-of select="$colspec/@colwidth"/>                    </xsl:otherwise>                  </xsl:choose>                </xsl:attribute>              </xsl:when>              <!-- pass through to HTML if no * in colspecs -->              <xsl:when test="$colspec/@colwidth and                             not($colspec/parent::*/colspec/@colwidth[contains(.,'*')])">                <xsl:attribute name="width">                  <xsl:choose>                    <xsl:when test="normalize-space($colspec/@colwidth) = '*'">                      <xsl:value-of select="'1*'"/>                    </xsl:when>                    <xsl:otherwise>                      <xsl:value-of select="$colspec/@colwidth"/>                    </xsl:otherwise>                  </xsl:choose>                </xsl:attribute>              </xsl:when>            </xsl:choose>            <xsl:choose>              <xsl:when test="$colspec/@align">                <xsl:attribute name="align">                  <xsl:value-of select="$colspec/@align"/>                </xsl:attribute>              </xsl:when>              <!-- Suggested by Pavel ZAMPACH <zampach@nemcb.cz> -->              <xsl:when test="$colspecs/ancestor::tgroup/@align">                <xsl:attribute name="align">                  <xsl:value-of select="$colspecs/ancestor::tgroup/@align"/>                </xsl:attribute>              </xsl:when>            </xsl:choose>            <xsl:if test="$colspec/@char">              <xsl:attribute name="char">                <xsl:value-of select="$colspec/@char"/>              </xsl:attribute>            </xsl:if>                        <xsl:if test="$colspec/@charoff">              <xsl:attribute name="charoff">                <xsl:value-of select="$colspec/@charoff"/>              </xsl:attribute>            </xsl:if>            <xsl:if test="$colspec/@colname">              <xsl:attribute name="class">                <xsl:value-of select="$colspec/@colname"/>              </xsl:attribute>            </xsl:if>          </col>        </xsl:when>        <xsl:otherwise>          <xsl:call-template name="generate.col">            <xsl:with-param name="countcol" select="$countcol"/>            <xsl:with-param name="colspecs" select="$colspecs"/>            <xsl:with-param name="count" select="$count+1"/>            <xsl:with-param name="colnum">              <xsl:choose>                <xsl:when test="$colspec/@colnum">                  <xsl:value-of select="$colspec/@colnum + 1"/>                </xsl:when>                <xsl:otherwise>                  <xsl:value-of select="$colnum + 1"/>                </xsl:otherwise>              </xsl:choose>            </xsl:with-param>           </xsl:call-template>        </xsl:otherwise>      </xsl:choose>    </xsl:otherwise>  </xsl:choose></xsl:template><xsl:template name="colspec.colwidth">  <!-- when this macro is called, the current context must be an entry -->  <xsl:param name="colname"></xsl:param>  <!-- .. = row, ../.. = thead|tbody, ../../.. = tgroup -->  <xsl:param name="colspecs" select="../../../../tgroup/colspec"/>  <xsl:param name="count">1</xsl:param>  <xsl:choose>    <xsl:when test="$count>count($colspecs)"></xsl:when>    <xsl:otherwise>      <xsl:variable name="colspec" select="$colspecs[$count=position()]"/>      <xsl:choose>        <xsl:when test="$colspec/@colname=$colname">          <xsl:value-of select="$colspec/@colwidth"/>        </xsl:when>        <xsl:otherwise>          <xsl:call-template name="colspec.colwidth">            <xsl:with-param name="colname" select="$colname"/>            <xsl:with-param name="colspecs" select="$colspecs"/>            <xsl:with-param name="count" select="$count+1"/>          </xsl:call-template>        </xsl:otherwise>      </xsl:choose>    </xsl:otherwise>  </xsl:choose></xsl:template><!-- ====================================================================== --><xsl:template name="tr.attributes">  <xsl:param name="row" select="."/>  <xsl:param name="rownum" select="0"/>  <!-- by default, do nothing. But you might want to say:  <xsl:if test="$rownum mod 2 = 0">    <xsl:attribute name="class">oddrow</xsl:attribute>  </xsl:if>  --></xsl:template></xsl:stylesheet>
 |