| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540 | 
							- <?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:fo="http://www.w3.org/1999/XSL/Format"
 
-                 xmlns:rx="http://www.renderx.com/XSL/Extensions"
 
-                 xmlns:stbl="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.Table"
 
-                 xmlns:xtbl="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$
 
-      ********************************************************************
 
-      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.
 
-      ******************************************************************** -->
 
- <doc:reference xmlns="" xml:id="table-templates">
 
-   <?dbhtml dir="fo"?>
 
-   <info>
 
-     <title>Formatting Object Table Reference</title>
 
-     <releaseinfo role="meta">
 
-       $Id$
 
-     </releaseinfo>
 
-   </info>
 
-   <partintro xml:id="partintro">
 
-     <title>Introduction</title>
 
-     <para>This is technical reference documentation for the FO
 
-       table-processing templates in the DocBook XSL Stylesheets.</para>
 
-     <para>This is not intended to be user documentation.  It is
 
-       provided for developers writing customization layers for the
 
-       stylesheets.</para>
 
-   </partintro>
 
- </doc:reference>
 
- <!-- ==================================================================== -->
 
- <lxslt:component prefix="xtbl"
 
-                  functions="adjustColumnWidths"/>
 
- <!-- ==================================================================== -->
 
- <xsl:template name="make.table.content">
 
-   <xsl:choose>
 
-     <xsl:when test="tgroup|mediaobject|graphic">
 
-       <xsl:call-template name="calsTable"/>
 
-     </xsl:when>
 
-     <xsl:otherwise>
 
-       <xsl:apply-templates select="." mode="htmlTable"/>
 
-     </xsl:otherwise>
 
-   </xsl:choose>
 
- </xsl:template>
 
- <!-- ==================================================================== -->
 
- <xsl:template name="calsTable">
 
-   <xsl:variable name="keep.together">
 
-     <xsl:call-template name="pi.dbfo_keep-together"/>
 
-   </xsl:variable>
 
-   <xsl:for-each select="tgroup">
 
-     <fo:table xsl:use-attribute-sets="table.table.properties">
 
-       <xsl:if test="$keep.together != ''">
 
-         <xsl:attribute name="keep-together.within-column">
 
-           <xsl:value-of select="$keep.together"/>
 
-         </xsl:attribute>
 
-       </xsl:if>
 
-       <xsl:call-template name="table.frame"/>
 
-       <xsl:if test="following-sibling::tgroup">
 
-         <xsl:attribute name="border-bottom-width">0pt</xsl:attribute>
 
-         <xsl:attribute name="border-bottom-style">none</xsl:attribute>
 
-         <xsl:attribute name="padding-bottom">0pt</xsl:attribute>
 
-         <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
 
-         <xsl:attribute name="space-after">0pt</xsl:attribute>
 
-         <xsl:attribute name="space-after.minimum">0pt</xsl:attribute>
 
-         <xsl:attribute name="space-after.optimum">0pt</xsl:attribute>
 
-         <xsl:attribute name="space-after.maximum">0pt</xsl:attribute>
 
-       </xsl:if>
 
-       <xsl:if test="preceding-sibling::tgroup">
 
-         <xsl:attribute name="border-top-width">0pt</xsl:attribute>
 
-         <xsl:attribute name="border-top-style">none</xsl:attribute>
 
-         <xsl:attribute name="padding-top">0pt</xsl:attribute>
 
-         <xsl:attribute name="margin-top">0pt</xsl:attribute>
 
-         <xsl:attribute name="space-before">0pt</xsl:attribute>
 
-         <xsl:attribute name="space-before.minimum">0pt</xsl:attribute>
 
-         <xsl:attribute name="space-before.optimum">0pt</xsl:attribute>
 
-         <xsl:attribute name="space-before.maximum">0pt</xsl:attribute>
 
-       </xsl:if>
 
-       <xsl:apply-templates select="."/>
 
-     </fo:table>
 
-   </xsl:for-each>
 
- </xsl:template>
 
- <!-- ==================================================================== -->
 
- <!-- Placeholder template enables wrapping a fo:table in
 
-      another table for purposes of layout or applying
 
-      extensions such as XEP table-omit-initial-header to
 
-      create "continued" titles on page breaks. -->
 
- <xsl:template name="table.layout">
 
-   <xsl:param name="table.content" select="NOTANODE"/>
 
-   <xsl:copy-of select="$table.content"/>
 
- </xsl:template>
 
- <xsl:template name="table.block">
 
-   <xsl:param name="table.layout" select="NOTANODE"/>
 
-   <xsl:variable name="id">
 
-     <xsl:call-template name="object.id"/>
 
-   </xsl:variable>
 
-   <xsl:variable name="param.placement"
 
-                 select="substring-after(normalize-space(
 
-                    $formal.title.placement), concat(local-name(.), ' '))"/>
 
-   <xsl:variable name="placement">
 
-     <xsl:choose>
 
-       <xsl:when test="contains($param.placement, ' ')">
 
-         <xsl:value-of select="substring-before($param.placement, ' ')"/>
 
-       </xsl:when>
 
-       <xsl:when test="$param.placement = ''">before</xsl:when>
 
-       <xsl:otherwise>
 
-         <xsl:value-of select="$param.placement"/>
 
-       </xsl:otherwise>
 
-     </xsl:choose>
 
-   </xsl:variable>
 
-   <xsl:choose>
 
-     <xsl:when test="self::table">
 
-       <fo:block id="{$id}"
 
-                 xsl:use-attribute-sets="table.properties">
 
-         <xsl:if test="$placement = 'before'">
 
-           <xsl:call-template name="formal.object.heading">
 
-             <xsl:with-param name="placement" select="$placement"/>
 
-           </xsl:call-template>
 
-         </xsl:if>
 
-         <xsl:copy-of select="$table.layout"/>
 
-         <xsl:call-template name="table.footnote.block"/>
 
-         <xsl:if test="$placement != 'before'">
 
-           <xsl:call-template name="formal.object.heading">
 
-             <xsl:with-param name="placement" select="$placement"/>
 
-           </xsl:call-template>
 
-         </xsl:if>
 
-       </fo:block>
 
-     </xsl:when>
 
-     <xsl:otherwise>
 
-       <fo:block id="{$id}"
 
-                 xsl:use-attribute-sets="informaltable.properties">
 
-         <xsl:copy-of select="$table.layout"/>
 
-         <xsl:call-template name="table.footnote.block"/>
 
-       </fo:block>
 
-     </xsl:otherwise>
 
-   </xsl:choose>
 
- </xsl:template>
 
- <!-- Output a table's footnotes in a block -->
 
- <xsl:template name="table.footnote.block">
 
-   <xsl:if test=".//footnote">
 
-     <fo:block keep-with-previous.within-column="always">
 
-       <xsl:apply-templates select=".//footnote" mode="table.footnote.mode"/>
 
-     </fo:block>
 
-   </xsl:if>
 
- </xsl:template>
 
- <!-- ==================================================================== -->
 
- <xsl:template name="table.container">
 
-   <xsl:param name="table.block"/>
 
-   <xsl:choose>
 
-     <xsl:when test="@orient='land' and 
 
-                     $fop.extensions = 0 and 
 
-                     $passivetex.extensions = 0" >
 
-       <fo:block-container reference-orientation="90"
 
-             padding="6pt"
 
-             xsl:use-attribute-sets="list.block.spacing">
 
-         <xsl:attribute name="width">
 
-           <xsl:call-template name="table.width"/>
 
-         </xsl:attribute>
 
-         <fo:block start-indent="0pt" end-indent="0pt">
 
-           <xsl:copy-of select="$table.block"/>
 
-         </fo:block>
 
-       </fo:block-container>
 
-     </xsl:when>
 
-     <xsl:when test="@pgwide = 1">
 
-       <fo:block xsl:use-attribute-sets="pgwide.properties">
 
-         <xsl:copy-of select="$table.block"/>
 
-       </fo:block>
 
-     </xsl:when>
 
-     <xsl:otherwise>
 
-       <xsl:copy-of select="$table.block"/>
 
-     </xsl:otherwise>
 
-   </xsl:choose>
 
- </xsl:template>
 
- <!-- ==================================================================== -->
 
- <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>
 
-   <fo:table-cell text-align="center"
 
-                  display-align="center"
 
-                  xsl:use-attribute-sets="table.cell.padding">
 
-     <xsl:if test="$xep.extensions != 0">
 
-       <!-- Suggested by RenderX to workaround a bug in their implementation -->
 
-       <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
 
-     </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:if test="$colsep > 0 and number($colnum) < ancestor::tgroup/@cols">
 
-       <xsl:call-template name="border">
 
-         <xsl:with-param name="side" select="'right'"/>
 
-       </xsl:call-template>
 
-     </xsl:if>
 
-     <!-- fo:table-cell should not be empty -->
 
-     <fo:block/>
 
-   </fo:table-cell>
 
- </xsl:template>
 
- <!-- ==================================================================== -->
 
- <xsl:template name="table.frame">
 
-   <xsl:variable name="frame">
 
-     <xsl:choose>
 
-       <xsl:when test="../@frame">
 
-         <xsl:value-of select="../@frame"/>
 
-       </xsl:when>
 
-       <xsl:when test="$default.table.frame != ''">
 
-         <xsl:value-of select="$default.table.frame"/>
 
-       </xsl:when>
 
-       <xsl:otherwise>all</xsl:otherwise>
 
-     </xsl:choose>
 
-   </xsl:variable>
 
-   <xsl:choose>
 
-     <xsl:when test="$frame='all'">
 
-       <xsl:attribute name="border-left-style">
 
-         <xsl:value-of select="$table.frame.border.style"/>
 
-       </xsl:attribute>
 
-       <xsl:attribute name="border-right-style">
 
-         <xsl:value-of select="$table.frame.border.style"/>
 
-       </xsl:attribute>
 
-       <xsl:attribute name="border-top-style">
 
-         <xsl:value-of select="$table.frame.border.style"/>
 
-       </xsl:attribute>
 
-       <xsl:attribute name="border-bottom-style">
 
-         <xsl:value-of select="$table.frame.border.style"/>
 
-       </xsl:attribute>
 
-       <xsl:attribute name="border-left-width">
 
-         <xsl:value-of select="$table.frame.border.thickness"/>
 
-       </xsl:attribute>
 
-       <xsl:attribute name="border-right-width">
 
-         <xsl:value-of select="$table.frame.border.thickness"/>
 
-       </xsl:attribute>
 
-       <xsl:attribute name="border-top-width">
 
-         <xsl:value-of select="$table.frame.border.thickness"/>
 
-       </xsl:attribute>
 
-       <xsl:attribute name="border-bottom-width">
 
-         <xsl:value-of select="$table.frame.border.thickness"/>
 
-       </xsl:attribute>
 
-       <xsl:attribute name="border-left-color">
 
-         <xsl:value-of select="$table.frame.border.color"/>
 
-       </xsl:attribute>
 
-       <xsl:attribute name="border-right-color">
 
-         <xsl:value-of select="$table.frame.border.color"/>
 
-       </xsl:attribute>
 
-       <xsl:attribute name="border-top-color">
 
-         <xsl:value-of select="$table.frame.border.color"/>
 
-       </xsl:attribute>
 
-       <xsl:attribute name="border-bottom-color">
 
-         <xsl:value-of select="$table.frame.border.color"/>
 
-       </xsl:attribute>
 
-     </xsl:when>
 
-     <xsl:when test="$frame='bottom'">
 
-       <xsl:attribute name="border-left-style">none</xsl:attribute>
 
-       <xsl:attribute name="border-right-style">none</xsl:attribute>
 
-       <xsl:attribute name="border-top-style">none</xsl:attribute>
 
-       <xsl:attribute name="border-bottom-style">
 
-         <xsl:value-of select="$table.frame.border.style"/>
 
-       </xsl:attribute>
 
-       <xsl:attribute name="border-bottom-width">
 
-         <xsl:value-of select="$table.frame.border.thickness"/>
 
-       </xsl:attribute>
 
-       <xsl:attribute name="border-bottom-color">
 
-         <xsl:value-of select="$table.frame.border.color"/>
 
-       </xsl:attribute>
 
-     </xsl:when>
 
-     <xsl:when test="$frame='sides'">
 
-       <xsl:attribute name="border-left-style">
 
-         <xsl:value-of select="$table.frame.border.style"/>
 
-       </xsl:attribute>
 
-       <xsl:attribute name="border-right-style">
 
-         <xsl:value-of select="$table.frame.border.style"/>
 
-       </xsl:attribute>
 
-       <xsl:attribute name="border-top-style">none</xsl:attribute>
 
-       <xsl:attribute name="border-bottom-style">none</xsl:attribute>
 
-       <xsl:attribute name="border-left-width">
 
-         <xsl:value-of select="$table.frame.border.thickness"/>
 
-       </xsl:attribute>
 
-       <xsl:attribute name="border-right-width">
 
-         <xsl:value-of select="$table.frame.border.thickness"/>
 
-       </xsl:attribute>
 
-       <xsl:attribute name="border-left-color">
 
-         <xsl:value-of select="$table.frame.border.color"/>
 
-       </xsl:attribute>
 
-       <xsl:attribute name="border-right-color">
 
-         <xsl:value-of select="$table.frame.border.color"/>
 
-       </xsl:attribute>
 
-     </xsl:when>
 
-     <xsl:when test="$frame='top'">
 
-       <xsl:attribute name="border-left-style">none</xsl:attribute>
 
-       <xsl:attribute name="border-right-style">none</xsl:attribute>
 
-       <xsl:attribute name="border-top-style">
 
-         <xsl:value-of select="$table.frame.border.style"/>
 
-       </xsl:attribute>
 
-       <xsl:attribute name="border-bottom-style">none</xsl:attribute>
 
-       <xsl:attribute name="border-top-width">
 
-         <xsl:value-of select="$table.frame.border.thickness"/>
 
-       </xsl:attribute>
 
-       <xsl:attribute name="border-top-color">
 
-         <xsl:value-of select="$table.frame.border.color"/>
 
-       </xsl:attribute>
 
-     </xsl:when>
 
-     <xsl:when test="$frame='topbot'">
 
-       <xsl:attribute name="border-left-style">none</xsl:attribute>
 
-       <xsl:attribute name="border-right-style">none</xsl:attribute>
 
-       <xsl:attribute name="border-top-style">
 
-         <xsl:value-of select="$table.frame.border.style"/>
 
-       </xsl:attribute>
 
-       <xsl:attribute name="border-bottom-style">
 
-         <xsl:value-of select="$table.frame.border.style"/>
 
-       </xsl:attribute>
 
-       <xsl:attribute name="border-top-width">
 
-         <xsl:value-of select="$table.frame.border.thickness"/>
 
-       </xsl:attribute>
 
-       <xsl:attribute name="border-bottom-width">
 
-         <xsl:value-of select="$table.frame.border.thickness"/>
 
-       </xsl:attribute>
 
-       <xsl:attribute name="border-top-color">
 
-         <xsl:value-of select="$table.frame.border.color"/>
 
-       </xsl:attribute>
 
-       <xsl:attribute name="border-bottom-color">
 
-         <xsl:value-of select="$table.frame.border.color"/>
 
-       </xsl:attribute>
 
-     </xsl:when>
 
-     <xsl:when test="$frame='none'">
 
-       <xsl:attribute name="border-left-style">none</xsl:attribute>
 
-       <xsl:attribute name="border-right-style">none</xsl:attribute>
 
-       <xsl:attribute name="border-top-style">none</xsl:attribute>
 
-       <xsl:attribute name="border-bottom-style">none</xsl:attribute>
 
-     </xsl:when>
 
-     <xsl:otherwise>
 
-       <xsl:message>
 
-         <xsl:text>Impossible frame on table: </xsl:text>
 
-         <xsl:value-of select="$frame"/>
 
-       </xsl:message>
 
-       <xsl:attribute name="border-left-style">none</xsl:attribute>
 
-       <xsl:attribute name="border-right-style">none</xsl:attribute>
 
-       <xsl:attribute name="border-top-style">none</xsl:attribute>
 
-       <xsl:attribute name="border-bottom-style">none</xsl:attribute>
 
-     </xsl:otherwise>
 
-   </xsl:choose>
 
- </xsl:template>
 
- <!-- ==================================================================== -->
 
- <xsl:template name="border">
 
-   <xsl:param name="side" select="'left'"/>
 
-   <xsl:attribute name="border-{$side}-width">
 
-     <xsl:value-of select="$table.cell.border.thickness"/>
 
-   </xsl:attribute>
 
-   <xsl:attribute name="border-{$side}-style">
 
-     <xsl:value-of select="$table.cell.border.style"/>
 
-   </xsl:attribute>
 
-   <xsl:attribute name="border-{$side}-color">
 
-     <xsl:value-of select="$table.cell.border.color"/>
 
-   </xsl:attribute>
 
- </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="table.width">
 
-     <xsl:call-template name="table.width"/>
 
-   </xsl:variable>
 
-   <xsl:variable name="colspecs">
 
-     <xsl:choose>
 
-       <xsl:when test="$use.extensions != 0
 
-                       and $tablecolumns.extension != 0">
 
-         <xsl:call-template name="generate.colgroup.raw">
 
-           <xsl:with-param name="cols" select="@cols"/>
 
-         </xsl:call-template>
 
-       </xsl:when>
 
-       <xsl:otherwise>
 
-         <xsl:call-template name="generate.colgroup">
 
-           <xsl:with-param name="cols" select="@cols"/>
 
-         </xsl:call-template>
 
-       </xsl:otherwise>
 
-     </xsl:choose>
 
-   </xsl:variable>
 
-   <xsl:variable name="prop-columns"
 
-                 select=".//colspec[contains(@colwidth, '*')]"/>
 
-   <xsl:if test="count($prop-columns) != 0 or
 
-                 $fop.extensions != 0 or
 
-                 $fop1.extensions != 0 or
 
-                 $passivetex.extensions != 0">
 
-     <xsl:attribute name="table-layout">fixed</xsl:attribute>
 
-   </xsl:if>
 
-   <xsl:if test="count(preceding-sibling::tgroup) = 0">
 
-     <!-- If this is the first tgroup, output the width attribute for the -->
 
-     <!-- surrounding fo:table. (If this isn't the first tgroup, trying   -->
 
-     <!-- to output the attribute will cause an error.)                   -->
 
-     <xsl:attribute name="width">
 
-       <xsl:value-of select="$table.width"/>
 
-     </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($colspecs)"/>
 
-         </xsl:when>
 
-         <xsl:when test="function-available('xtbl:adjustColumnWidths')">
 
-           <xsl:copy-of select="xtbl:adjustColumnWidths($colspecs)"/>
 
-         </xsl:when>
 
-         <xsl:when test="function-available('ptbl:adjustColumnWidths')">
 
-           <xsl:copy-of select="ptbl:adjustColumnWidths($colspecs)"/>
 
-         </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="$colspecs"/>
 
-     </xsl:otherwise>
 
-   </xsl:choose>
 
-   <xsl:apply-templates select="thead"/>
 
-   <xsl:apply-templates select="tfoot"/>
 
-   <xsl:apply-templates select="tbody"/>
 
- </xsl:template>
 
- <xsl:template match="colspec"></xsl:template>
 
- <xsl:template name="table.width">
 
-   <xsl:variable name="numcols">
 
-     <xsl:call-template name="widest-html-row">
 
-       <xsl:with-param name="rows" select=".//tr"/>
 
-     </xsl:call-template>
 
-   </xsl:variable>
 
-   <xsl:variable name="explicit.table.width">
 
-     <xsl:choose>
 
-       <xsl:when test="self::entrytbl">
 
-         <xsl:call-template name="pi.dbfo_table-width"/>
 
-       </xsl:when>
 
-       <xsl:when test="self::table or self::informaltable">
 
-         <xsl:call-template name="pi.dbfo_table-width"/>
 
-       </xsl:when>
 
-       <xsl:otherwise>
 
-         <!-- * no dbfo@table-width PI as a child of this table, so check -->
 
-         <!-- * the parent of this table to see if the table has any -->
 
-         <!-- * sibling dbfo@table-width PIs (FIXME: 2007-07 MikeSmith: we -->
 
-         <!-- * should really instead be checking here just to see if the -->
 
-         <!-- * first preceding sibling of this table is a -->
 
-         <!-- * dbfo@table-width PI) -->
 
-         <xsl:call-template name="pi.dbfo_table-width">
 
-           <xsl:with-param name="node" select=".."/>
 
-         </xsl:call-template>
 
-       </xsl:otherwise>
 
-     </xsl:choose>
 
-   </xsl:variable>
 
-   <xsl:variable name="column.sum">
 
-     <xsl:choose>
 
-       <!-- CALS table -->
 
-       <xsl:when test="@cols">
 
-         <xsl:if test="count(colspec) = @cols">
 
-           <xsl:for-each select="colspec">
 
-             <xsl:if test="position() != 1">
 
-               <xsl:text> + </xsl:text>
 
-             </xsl:if>
 
-             <xsl:choose>
 
-               <xsl:when test="not(@colwidth)">NOWIDTH</xsl:when>
 
-               <xsl:when test="contains(@colwidth, '*')">NOWIDTH</xsl:when>
 
-               <xsl:otherwise>
 
-                 <xsl:value-of select="@colwidth"/>
 
-               </xsl:otherwise>
 
-             </xsl:choose>
 
-           </xsl:for-each>
 
-         </xsl:if>
 
-       </xsl:when>
 
-       <xsl:otherwise>
 
-         <!-- HTML table -->
 
-         <xsl:if test="count(col|colgroup/col) = $numcols">
 
-           <xsl:for-each select="col|colgroup/col">
 
-             <xsl:if test="position() != 1">
 
-               <xsl:text> + </xsl:text>
 
-             </xsl:if>
 
-             <xsl:choose>
 
-               <xsl:when test="not(@width)">NOWIDTH</xsl:when>
 
-               <xsl:when test="contains(@width, '%')">NOWIDTH</xsl:when>
 
-               <xsl:otherwise>
 
-                 <xsl:value-of select="@width"/>
 
-               </xsl:otherwise>
 
-             </xsl:choose>
 
-           </xsl:for-each>
 
-         </xsl:if>
 
-       </xsl:otherwise>
 
-     </xsl:choose>
 
-   </xsl:variable>
 
-   <xsl:variable name="column.sum.width">
 
-     <xsl:if test="not(contains($column.sum, 'NOWIDTH'))">
 
-       <xsl:value-of select="$column.sum"/>
 
-     </xsl:if>
 
-   </xsl:variable>
 
-   <xsl:variable name="prop-columns"
 
-                 select=".//colspec[contains(@colwidth, '*')]"/>
 
-   <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="$column.sum.width != ''">
 
-         <xsl:value-of select="$column.sum.width"/>
 
-       </xsl:when>
 
-       <xsl:when test="$default.table.width = ''">
 
-         <xsl:choose>
 
-           <!-- These processors don't support table-layout="auto" -->
 
-           <xsl:when test="$fop.extensions != 0 or
 
-                           $fop1.extensions != 0 or
 
-                           $passivetex.extensions != 0">
 
-             <xsl:text>100%</xsl:text>
 
-           </xsl:when>
 
-           <!-- Proportional columns imply 100% width -->
 
-           <xsl:when test="count($prop-columns) != 0">
 
-             <xsl:text>100%</xsl:text>
 
-           </xsl:when>
 
-           <xsl:otherwise>
 
-             <xsl:text>auto</xsl:text>
 
-           </xsl:otherwise>
 
-         </xsl:choose>
 
-       </xsl:when>
 
-       <xsl:otherwise>
 
-         <xsl:value-of select="$default.table.width"/>
 
-       </xsl:otherwise>
 
-     </xsl:choose>
 
-   </xsl:variable>
 
-   <xsl:value-of select="$table.width"/>
 
- </xsl:template>
 
- <xsl:template match="spanspec"></xsl:template>
 
- <xsl:template match="thead">
 
-   <xsl:variable name="tgroup" select="parent::*"/>
 
-   <fo:table-header start-indent="0pt" end-indent="0pt">
 
-     <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:apply-templates>
 
-   </fo:table-header>
 
- </xsl:template>
 
- <xsl:template match="tfoot">
 
-   <xsl:variable name="tgroup" select="parent::*"/>
 
-   <fo:table-footer start-indent="0pt" end-indent="0pt">
 
-     <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:apply-templates>
 
-   </fo:table-footer>
 
- </xsl:template>
 
- <xsl:template match="tbody">
 
-   <xsl:variable name="tgroup" select="parent::*"/>
 
-   <fo:table-body start-indent="0pt" end-indent="0pt">
 
-     <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:apply-templates>
 
-   </fo:table-body>
 
- </xsl:template>
 
- <xsl:template match="row">
 
-   <xsl:param name="spans"/>
 
-   <xsl:choose>
 
-     <xsl:when test="contains($spans, '0')">
 
-       <xsl:call-template name="normal-row">
 
-         <xsl:with-param name="spans" select="$spans"/>
 
-       </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>
 
-       <fo:table-row>
 
-         <xsl:comment> This row intentionally left blank </xsl:comment>
 
-         <fo:table-cell><fo:block/></fo:table-cell>
 
-       </fo:table-row>
 
-       <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:apply-templates>
 
-     </xsl:otherwise>
 
-   </xsl:choose>
 
- </xsl:template>
 
- <xsl:template name="normal-row">
 
-   <xsl:param name="spans"/>
 
-   <fo:table-row>
 
-     <xsl:call-template name="table.row.properties"/>
 
-     <xsl:call-template name="anchor"/>
 
-     <xsl:apply-templates select="(entry|entrytbl)[1]">
 
-       <xsl:with-param name="spans" select="$spans"/>
 
-     </xsl:apply-templates>
 
-   </fo:table-row>
 
-   <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:apply-templates>
 
-   </xsl:if>
 
- </xsl:template>
 
- <!-- customize this template to add row properties -->
 
- <xsl:template name="table.row.properties">
 
-   <xsl:variable name="bgcolor">
 
-     <xsl:call-template name="pi.dbfo_bgcolor"/>
 
-   </xsl:variable>
 
-   <xsl:if test="$bgcolor != ''">
 
-     <xsl:attribute name="background-color">
 
-       <xsl:value-of select="$bgcolor"/>
 
-     </xsl:attribute>
 
-   </xsl:if>
 
-   <!-- Keep header row with next row -->
 
-   <xsl:if test="ancestor::thead">
 
-     <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
 
-   </xsl:if>
 
- </xsl:template>
 
- <xsl:template match="entry|entrytbl" name="entry">
 
-   <xsl:param name="col" select="1"/>
 
-   <xsl:param name="spans"/>
 
-   <xsl:variable name="row" select="parent::row"/>
 
-   <xsl:variable name="group" select="$row/parent::*[1]"/>
 
-   <xsl:variable name="frame" select="ancestor::tgroup/parent::*/@frame"/>
 
-   <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="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>
 
-       <!-- Check for morerows too -->
 
-       <xsl:when test="(@morerows and count(ancestor-or-self::row[1]/
 
-                        following-sibling::row) = @morerows )
 
-                       and not (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="."/>
 
-           <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:message><xsl:value-of select="."/>: <xsl:value-of select="$rowsep"/></xsl:message>
 
- -->
 
-   <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:with-param name="colnum" select="$col"/>
 
-       </xsl:call-template>
 
-       <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="cell.content">
 
-         <fo:block>
 
-           <xsl:call-template name="table.cell.block.properties"/>
 
-           <!-- are we missing any indexterms? -->
 
-           <xsl:if test="not(preceding-sibling::entry)
 
-                         and not(parent::row/preceding-sibling::row)">
 
-             <!-- this is the first entry of the first row -->
 
-             <xsl:if test="ancestor::thead or
 
-                           (ancestor::tbody
 
-                            and not(ancestor::tbody/preceding-sibling::thead
 
-                                    or ancestor::tbody/preceding-sibling::tbody))">
 
-               <!-- of the thead or the first tbody -->
 
-               <xsl:apply-templates select="ancestor::tgroup/preceding-sibling::indexterm"/>
 
-             </xsl:if>
 
-           </xsl:if>
 
-           <!--
 
-           <xsl:text>(</xsl:text>
 
-           <xsl:value-of select="$rowsep"/>
 
-           <xsl:text>,</xsl:text>
 
-           <xsl:value-of select="$colsep"/>
 
-           <xsl:text>)</xsl:text>
 
-           -->
 
-           <xsl:choose>
 
-             <xsl:when test="$empty.cell">
 
-               <xsl:text> </xsl:text>
 
-             </xsl:when>
 
-             <xsl:when test="self::entrytbl">
 
-               <xsl:variable name="prop-columns"
 
-                             select=".//colspec[contains(@colwidth, '*')]"/>
 
-               <fo:table xsl:use-attribute-sets="table.table.properties">
 
-                 <xsl:if test="count($prop-columns) != 0">
 
-                   <xsl:attribute name="table-layout">fixed</xsl:attribute>
 
-                 </xsl:if>
 
-                 <xsl:call-template name="tgroup"/>
 
-               </fo:table>
 
-             </xsl:when>
 
-             <xsl:otherwise>
 
-               <xsl:apply-templates/>
 
-             </xsl:otherwise>
 
-           </xsl:choose>
 
-         </fo:block>
 
-       </xsl:variable>
 
-       <xsl:variable name="cell-orientation">
 
-         <xsl:call-template name="pi.dbfo_orientation">
 
-           <xsl:with-param name="node" select="ancestor-or-self::entry"/>
 
-         </xsl:call-template>
 
-       </xsl:variable>
 
-       <xsl:variable name="row-orientation">
 
-         <xsl:call-template name="pi.dbfo_orientation">
 
-           <xsl:with-param name="node" select="ancestor-or-self::row"/>
 
-         </xsl:call-template>
 
-       </xsl:variable>
 
-       <xsl:variable name="cell-width">
 
-         <xsl:call-template name="pi.dbfo_rotated-width">
 
-           <xsl:with-param name="node" select="ancestor-or-self::entry"/>
 
-         </xsl:call-template>
 
-       </xsl:variable>
 
-       <xsl:variable name="row-width">
 
-         <xsl:call-template name="pi.dbfo_rotated-width">
 
-           <xsl:with-param name="node" select="ancestor-or-self::row"/>
 
-         </xsl:call-template>
 
-       </xsl:variable>
 
-       <xsl:variable name="orientation">
 
-         <xsl:choose>
 
-           <xsl:when test="$cell-orientation != ''">
 
-             <xsl:value-of select="$cell-orientation"/>
 
-           </xsl:when>
 
-           <xsl:otherwise>
 
-             <xsl:value-of select="$row-orientation"/>
 
-           </xsl:otherwise>
 
-         </xsl:choose>
 
-       </xsl:variable>
 
-       <xsl:variable name="rotated-width">
 
-         <xsl:choose>
 
-           <xsl:when test="$cell-width != ''">
 
-             <xsl:value-of select="$cell-width"/>
 
-           </xsl:when>
 
-           <xsl:otherwise>
 
-             <xsl:value-of select="$row-width"/>
 
-           </xsl:otherwise>
 
-         </xsl:choose>
 
-       </xsl:variable>
 
-       <xsl:variable name="bgcolor">
 
-         <xsl:call-template name="pi.dbfo_bgcolor">
 
-           <xsl:with-param name="node" select="ancestor-or-self::entry"/>
 
-         </xsl:call-template>
 
-       </xsl:variable>
 
-       <fo:table-cell xsl:use-attribute-sets="table.cell.padding">
 
-         <xsl:call-template name="table.cell.properties">
 
-           <xsl:with-param name="bgcolor.pi" select="$bgcolor"/>
 
-           <xsl:with-param name="rowsep.inherit" select="$rowsep"/>
 
-           <xsl:with-param name="colsep.inherit" select="$colsep"/>
 
-           <xsl:with-param name="col" select="$col"/>
 
-           <xsl:with-param name="valign.inherit" select="$valign"/>
 
-           <xsl:with-param name="align.inherit" select="$align"/>
 
-           <xsl:with-param name="char.inherit" select="$char"/>
 
-         </xsl:call-template>
 
-         <xsl:call-template name="anchor"/>
 
-         <xsl:if test="@morerows">
 
-           <xsl:attribute name="number-rows-spanned">
 
-             <xsl:value-of select="@morerows+1"/>
 
-           </xsl:attribute>
 
-         </xsl:if>
 
-         <xsl:if test="$entry.colspan > 1">
 
-           <xsl:attribute name="number-columns-spanned">
 
-             <xsl:value-of select="$entry.colspan"/>
 
-           </xsl:attribute>
 
-         </xsl:if>
 
- <!--
 
-         <xsl:if test="@charoff">
 
-           <xsl:attribute name="charoff">
 
-             <xsl:value-of select="@charoff"/>
 
-           </xsl:attribute>
 
-         </xsl:if>
 
- -->
 
-         <xsl:choose>
 
-           <xsl:when test="$fop.extensions = 0 and $passivetex.extensions = 0
 
-                           and $orientation != ''">
 
-             <fo:block-container reference-orientation="{$orientation}">
 
-               <xsl:if test="$rotated-width != ''">
 
-                 <xsl:attribute name="width">
 
-                   <xsl:value-of select="$rotated-width"/>
 
-                 </xsl:attribute>
 
-               </xsl:if>
 
-               <xsl:copy-of select="$cell.content"/>
 
-             </fo:block-container>
 
-           </xsl:when>
 
-           <xsl:otherwise>
 
-             <xsl:copy-of select="$cell.content"/>
 
-           </xsl:otherwise>
 
-         </xsl:choose>
 
-       </fo:table-cell>
 
-       <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>
 
- <!-- Expand this template to add properties to any fo:table-cell -->
 
- <xsl:template name="table.cell.properties">
 
-   <xsl:param name="bgcolor.pi" select="''"/>
 
-   <xsl:param name="rowsep.inherit" select="1"/>
 
-   <xsl:param name="colsep.inherit" select="1"/>
 
-   <xsl:param name="col" select="1"/>
 
-   <xsl:param name="valign.inherit" select="''"/>
 
-   <xsl:param name="align.inherit" select="''"/>
 
-   <xsl:param name="char.inherit" select="''"/>
 
-   <xsl:choose>
 
-     <xsl:when test="ancestor::tgroup">
 
-       <xsl:if test="$bgcolor.pi != ''">
 
-         <xsl:attribute name="background-color">
 
-           <xsl:value-of select="$bgcolor.pi"/>
 
-         </xsl:attribute>
 
-       </xsl:if>
 
-       <xsl:if test="$rowsep.inherit > 0">
 
-         <xsl:call-template name="border">
 
-           <xsl:with-param name="side" select="'bottom'"/>
 
-         </xsl:call-template>
 
-       </xsl:if>
 
-       <xsl:if test="$colsep.inherit > 0 and 
 
-                       $col < ancestor::tgroup/@cols">
 
-         <xsl:call-template name="border">
 
-           <xsl:with-param name="side" select="'right'"/>
 
-         </xsl:call-template>
 
-       </xsl:if>
 
-       <xsl:if test="$valign.inherit != ''">
 
-         <xsl:attribute name="display-align">
 
-           <xsl:choose>
 
-             <xsl:when test="$valign.inherit='top'">before</xsl:when>
 
-             <xsl:when test="$valign.inherit='middle'">center</xsl:when>
 
-             <xsl:when test="$valign.inherit='bottom'">after</xsl:when>
 
-             <xsl:otherwise>
 
-               <xsl:message>
 
-                 <xsl:text>Unexpected valign value: </xsl:text>
 
-                 <xsl:value-of select="$valign.inherit"/>
 
-                 <xsl:text>, center used.</xsl:text>
 
-               </xsl:message>
 
-               <xsl:text>center</xsl:text>
 
-             </xsl:otherwise>
 
-           </xsl:choose>
 
-         </xsl:attribute>
 
-       </xsl:if>
 
-       <xsl:choose>
 
-         <xsl:when test="$align.inherit = 'char' and $char.inherit != ''">
 
-           <xsl:attribute name="text-align">
 
-             <xsl:value-of select="$char.inherit"/>
 
-           </xsl:attribute>
 
-         </xsl:when>
 
-         <xsl:when test="$align.inherit != ''">
 
-           <xsl:attribute name="text-align">
 
-             <xsl:value-of select="$align.inherit"/>
 
-           </xsl:attribute>
 
-         </xsl:when>
 
-       </xsl:choose>
 
-     </xsl:when>
 
-     <xsl:otherwise>
 
-       <!-- HTML table -->
 
-       <xsl:variable name="border" 
 
-                     select="(ancestor::table |
 
-                              ancestor::informaltable)[last()]/@border"/>
 
-       <xsl:if test="$border != '' and $border != 0">
 
-         <xsl:attribute name="border">
 
-           <xsl:value-of select="$table.cell.border.thickness"/>
 
-           <xsl:text> </xsl:text>
 
-           <xsl:value-of select="$table.cell.border.style"/>
 
-           <xsl:text> </xsl:text>
 
-           <xsl:value-of select="$table.cell.border.color"/>
 
-         </xsl:attribute>
 
-       </xsl:if>
 
-     </xsl:otherwise>
 
-   </xsl:choose>
 
- </xsl:template>
 
- <!-- Expand this template to add properties to any cell's block -->
 
- <xsl:template name="table.cell.block.properties">
 
-   <!-- highlight this entry? -->
 
-   <xsl:if test="ancestor::thead or ancestor::tfoot">
 
-     <xsl:attribute name="font-weight">bold</xsl:attribute>
 
-   </xsl:if>
 
- </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+$entry.colspan"/>
 
-         <xsl:with-param name="spans" select="$following.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.raw">
 
-   <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.raw">
 
-         <xsl:with-param name="countcol" select="$count"/>
 
-       </xsl:call-template>
 
-       <xsl:call-template name="generate.colgroup.raw">
 
-         <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.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.raw">
 
-   <!-- generate the table-column for column countcol -->
 
-   <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)">
 
-       <fo:table-column column-number="{$countcol}"/>
 
-     </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:variable name="colspec.colwidth">
 
-         <xsl:choose>
 
-           <xsl:when test="$colspec/@colwidth">
 
-             <xsl:value-of select="$colspec/@colwidth"/>
 
-           </xsl:when>
 
-           <xsl:otherwise>1*</xsl:otherwise>
 
-         </xsl:choose>
 
-       </xsl:variable>
 
-       <xsl:choose>
 
-         <xsl:when test="$colspec.colnum=$countcol">
 
-           <fo:table-column column-number="{$countcol}">
 
-             <xsl:attribute name="column-width">
 
-               <xsl:value-of select="$colspec.colwidth"/>
 
-             </xsl:attribute>
 
-           </fo:table-column>
 
-         </xsl:when>
 
-         <xsl:otherwise>
 
-           <xsl:call-template name="generate.col.raw">
 
-             <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="generate.col">
 
-   <!-- generate the table-column for column countcol -->
 
-   <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)">
 
-       <fo:table-column column-number="{$countcol}">
 
-         <xsl:variable name="colwidth">
 
-           <xsl:call-template name="calc.column.width"/>
 
-         </xsl:variable>
 
-         <xsl:if test="$colwidth != 'proportional-column-width(1)'">
 
-           <xsl:attribute name="column-width">
 
-             <xsl:value-of select="$colwidth"/>
 
-           </xsl:attribute>
 
-         </xsl:if>
 
-       </fo:table-column>
 
-     </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:variable name="colspec.colwidth">
 
-         <xsl:choose>
 
-           <xsl:when test="$colspec/@colwidth">
 
-             <xsl:value-of select="$colspec/@colwidth"/>
 
-           </xsl:when>
 
-           <xsl:otherwise>1*</xsl:otherwise>
 
-         </xsl:choose>
 
-       </xsl:variable>
 
-       <xsl:choose>
 
-         <xsl:when test="$colspec.colnum=$countcol">
 
-           <fo:table-column column-number="{$countcol}">
 
-             <xsl:variable name="colwidth">
 
-               <xsl:call-template name="calc.column.width">
 
-                 <xsl:with-param name="colwidth">
 
-                   <xsl:value-of select="$colspec.colwidth"/>
 
-                 </xsl:with-param>
 
-               </xsl:call-template>
 
-             </xsl:variable>
 
-             <xsl:if test="$colwidth != 'proportional-column-width(1)'">
 
-               <xsl:attribute name="column-width">
 
-                 <xsl:value-of select="$colwidth"/>
 
-               </xsl:attribute>
 
-             </xsl:if>
 
-           </fo:table-column>
 
-         </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>
 
- <doc:template name="calc.column.width" xmlns="">
 
- <refpurpose>Calculate an XSL FO table column width specification from a
 
- CALS table column width specification.</refpurpose>
 
- <refdescription>
 
- <para>CALS expresses table column widths in the following basic
 
- forms:</para>
 
- <itemizedlist>
 
- <listitem>
 
- <para><emphasis>99.99units</emphasis>, a fixed length specifier.</para>
 
- </listitem>
 
- <listitem>
 
- <para><emphasis>99.99</emphasis>, a fixed length specifier without any units.</para>
 
- </listitem>
 
- <listitem>
 
- <para><emphasis>99.99*</emphasis>, a relative length specifier.</para>
 
- </listitem>
 
- <listitem>
 
- <para><emphasis>99.99*+99.99units</emphasis>, a combination of both.</para>
 
- </listitem>
 
- </itemizedlist>
 
- <para>The CALS units are points (pt), picas (pi), centimeters (cm),
 
- millimeters (mm), and inches (in). These are the same units as XSL,
 
- except that XSL abbreviates picas "pc" instead of "pi". If a length
 
- specifier has no units, the CALS default unit (pt) is assumed.</para>
 
- <para>Relative length specifiers are represented in XSL with the
 
- proportional-column-width() function.</para>
 
- <para>Here are some examples:</para>
 
- <itemizedlist>
 
- <listitem>
 
- <para>"36pt" becomes "36pt"</para>
 
- </listitem>
 
- <listitem>
 
- <para>"3pi" becomes "3pc"</para>
 
- </listitem>
 
- <listitem>
 
- <para>"36" becomes "36pt"</para>
 
- </listitem>
 
- <listitem>
 
- <para>"3*" becomes "proportional-column-width(3)"</para>
 
- </listitem>
 
- <listitem>
 
- <para>"3*+2pi" becomes "proportional-column-width(3)+2pc"</para>
 
- </listitem>
 
- <listitem>
 
- <para>"1*+2" becomes "proportional-column-width(1)+2pt"</para>
 
- </listitem>
 
- </itemizedlist>
 
- </refdescription>
 
- <refparameter>
 
- <variablelist>
 
- <varlistentry><term>colwidth</term>
 
- <listitem>
 
- <para>The CALS column width specification.</para>
 
- </listitem>
 
- </varlistentry>
 
- </variablelist>
 
- </refparameter>
 
- <refreturn>
 
- <para>The XSL column width specification.</para>
 
- </refreturn>
 
- </doc:template>
 
- <xsl:template name="calc.column.width">
 
-   <xsl:param name="colwidth">1*</xsl:param>
 
-   <!-- Ok, the colwidth could have any one of the following forms: -->
 
-   <!--        1*       = proportional width -->
 
-   <!--         *       = same as 1* -->
 
-   <!--     1unit       = 1.0 units wide -->
 
-   <!--         1       = 1pt wide -->
 
-   <!--  1*+1unit       = proportional width + some fixed width -->
 
-   <!--      1*+1       = proportional width + some fixed width -->
 
-   <!-- If it has a proportional width, translate it to XSL -->
 
-   <xsl:if test="contains($colwidth, '*')">
 
-     <xsl:text>proportional-column-width(</xsl:text>
 
-     <xsl:choose>
 
-       <xsl:when test="substring-before($colwidth, '*') != ''"> 
 
-         <xsl:value-of select="substring-before($colwidth, '*')"/>
 
-       </xsl:when>
 
-       <xsl:otherwise>
 
-          <xsl:text>1.00</xsl:text>
 
-       </xsl:otherwise>
 
-     </xsl:choose>
 
-     <xsl:text>)</xsl:text>
 
-   </xsl:if>
 
-   <!-- Now grab the non-proportional part of the specification -->
 
-   <xsl:variable name="width-units">
 
-     <xsl:choose>
 
-       <xsl:when test="contains($colwidth, '*')">
 
-         <xsl:value-of
 
-              select="normalize-space(substring-after($colwidth, '*'))"/>
 
-       </xsl:when>
 
-       <xsl:otherwise>
 
-         <xsl:value-of select="normalize-space($colwidth)"/>
 
-       </xsl:otherwise>
 
-     </xsl:choose>
 
-   </xsl:variable>
 
-   <!-- Ok, now the width-units could have any one of the following forms: -->
 
-   <!--                 = <empty string> -->
 
-   <!--     1unit       = 1.0 units wide -->
 
-   <!--         1       = 1pt wide -->
 
-   <!-- with an optional leading sign -->
 
-   <!-- Grab the width part by blanking out the units part and discarding -->
 
-   <!-- whitespace. It's not pretty, but it works. -->
 
-   <xsl:variable name="width"
 
-        select="normalize-space(translate($width-units,
 
-                                          '+-0123456789.abcdefghijklmnopqrstuvwxyz',
 
-                                          '+-0123456789.'))"/>
 
-   <!-- Grab the units part by blanking out the width part and discarding -->
 
-   <!-- whitespace. It's not pretty, but it works. -->
 
-   <xsl:variable name="units"
 
-        select="normalize-space(translate($width-units,
 
-                                          'abcdefghijklmnopqrstuvwxyz+-0123456789.',
 
-                                          'abcdefghijklmnopqrstuvwxyz'))"/>
 
-   <!-- Output the width -->
 
-   <xsl:value-of select="$width"/>
 
-   <!-- Output the units, translated appropriately -->
 
-   <xsl:choose>
 
-     <xsl:when test="$units = 'pi'">pc</xsl:when>
 
-     <xsl:when test="$units = '' and $width != ''">pt</xsl:when>
 
-     <xsl:otherwise><xsl:value-of select="$units"/></xsl:otherwise>
 
-   </xsl:choose>
 
- </xsl:template>
 
- <!-- ==================================================================== -->
 
- </xsl:stylesheet>
 
 
  |