2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
4 xmlns:stbl="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.Table"
5 xmlns:xtbl="xalan://com.nwalsh.xalan.Table"
6 xmlns:lxslt="http://xml.apache.org/xslt"
7 xmlns:ptbl="http://nwalsh.com/xslt/ext/xsltproc/python/Table"
8 exclude-result-prefixes="doc stbl xtbl lxslt ptbl"
11 <xsl:include href="../common/table.xsl"/>
13 <!-- ********************************************************************
14 $Id: table.xsl 8421 2009-05-04 07:49:49Z bobstayton $
15 ********************************************************************
17 This file is part of the XSL DocBook Stylesheet distribution.
18 See ../README or http://docbook.sf.net/release/xsl/current/ for
19 copyright and other information.
21 ******************************************************************** -->
23 <lxslt:component prefix="xtbl"
24 functions="adjustColumnWidths"/>
26 <xsl:template name="empty.table.cell">
27 <xsl:param name="colnum" select="0"/>
29 <xsl:variable name="rowsep">
31 <!-- If this is the last row, rowsep never applies. -->
32 <xsl:when test="not(ancestor-or-self::row[1]/following-sibling::row
33 or ancestor-or-self::thead/following-sibling::tbody
34 or ancestor-or-self::tbody/preceding-sibling::tfoot)">
35 <xsl:value-of select="0"/>
38 <xsl:call-template name="inherited.table.attribute">
39 <xsl:with-param name="entry" select="NOT-AN-ELEMENT-NAME"/>
40 <xsl:with-param name="row" select="ancestor-or-self::row[1]"/>
41 <xsl:with-param name="colnum" select="$colnum"/>
42 <xsl:with-param name="attribute" select="'rowsep'"/>
48 <xsl:variable name="colsep">
50 <!-- If this is the last column, colsep never applies. -->
51 <xsl:when test="number($colnum) >= ancestor::tgroup/@cols">0</xsl:when>
53 <xsl:call-template name="inherited.table.attribute">
54 <xsl:with-param name="entry" select="NOT-AN-ELEMENT-NAME"/>
55 <xsl:with-param name="row" select="ancestor-or-self::row[1]"/>
56 <xsl:with-param name="colnum" select="$colnum"/>
57 <xsl:with-param name="attribute" select="'colsep'"/>
63 <td class="auto-generated">
64 <xsl:if test="$table.borders.with.css != 0">
65 <xsl:attribute name="style">
66 <xsl:if test="$colsep > 0">
67 <xsl:call-template name="border">
68 <xsl:with-param name="side" select="'right'"/>
71 <xsl:if test="$rowsep > 0">
72 <xsl:call-template name="border">
73 <xsl:with-param name="side" select="'bottom'"/>
78 <xsl:text> </xsl:text>
82 <!-- ==================================================================== -->
84 <xsl:template name="border">
85 <xsl:param name="side" select="'left'"/>
86 <xsl:param name="padding" select="0"/>
87 <xsl:param name="style" select="$table.cell.border.style"/>
88 <xsl:param name="color" select="$table.cell.border.color"/>
89 <xsl:param name="thickness" select="$table.cell.border.thickness"/>
91 <!-- Note: Some browsers (mozilla) require at least a width and style. -->
94 <xsl:when test="($thickness != ''
99 or ($thickness != '')">
100 <!-- use the compound property if we can: -->
101 <!-- it saves space and probably works more reliably -->
102 <xsl:text>border-</xsl:text>
103 <xsl:value-of select="$side"/>
104 <xsl:text>: </xsl:text>
105 <xsl:value-of select="$thickness"/>
106 <xsl:text> </xsl:text>
107 <xsl:value-of select="$style"/>
108 <xsl:text> </xsl:text>
109 <xsl:value-of select="$color"/>
110 <xsl:text>; </xsl:text>
113 <!-- we need to specify the styles individually -->
114 <xsl:if test="$thickness != ''">
115 <xsl:text>border-</xsl:text>
116 <xsl:value-of select="$side"/>
117 <xsl:text>-width: </xsl:text>
118 <xsl:value-of select="$thickness"/>
119 <xsl:text>; </xsl:text>
122 <xsl:if test="$style != ''">
123 <xsl:text>border-</xsl:text>
124 <xsl:value-of select="$side"/>
125 <xsl:text>-style: </xsl:text>
126 <xsl:value-of select="$style"/>
127 <xsl:text>; </xsl:text>
130 <xsl:if test="$color != ''">
131 <xsl:text>border-</xsl:text>
132 <xsl:value-of select="$side"/>
133 <xsl:text>-color: </xsl:text>
134 <xsl:value-of select="$color"/>
135 <xsl:text>; </xsl:text>
141 <!-- ==================================================================== -->
143 <xsl:template match="tgroup" name="tgroup">
144 <xsl:if test="not(@cols) or @cols = '' or string(number(@cols)) = 'NaN'">
145 <xsl:message terminate="yes">
146 <xsl:text>Error: CALS tables must specify the number of columns.</xsl:text>
150 <xsl:variable name="summary">
151 <xsl:call-template name="pi.dbhtml_table-summary"/>
154 <xsl:variable name="cellspacing">
155 <xsl:call-template name="pi.dbhtml_cellspacing"/>
158 <xsl:variable name="cellpadding">
159 <xsl:call-template name="pi.dbhtml_cellpadding"/>
164 <!-- If there's a textobject/phrase for the table summary, use it -->
165 <xsl:when test="../textobject/phrase">
166 <xsl:attribute name="summary">
167 <xsl:value-of select="../textobject/phrase"/>
171 <!-- If there's a <?dbhtml table-summary="foo"?> PI, use it for
172 the HTML table summary attribute -->
173 <xsl:when test="$summary != ''">
174 <xsl:attribute name="summary">
175 <xsl:value-of select="$summary"/>
179 <!-- Otherwise, if there's a title, use that -->
180 <xsl:when test="../title">
181 <xsl:attribute name="summary">
182 <!-- This screws up on inline markup and footnotes, oh well... -->
183 <xsl:value-of select="string(../title)"/>
187 <!-- Otherwise, forget the whole idea -->
188 <xsl:otherwise><!-- nevermind --></xsl:otherwise>
191 <xsl:if test="$cellspacing != '' or $html.cellspacing != ''">
192 <xsl:attribute name="cellspacing">
194 <xsl:when test="$cellspacing != ''">
195 <xsl:value-of select="$cellspacing"/>
198 <xsl:value-of select="$html.cellspacing"/>
204 <xsl:if test="$cellpadding != '' or $html.cellpadding != ''">
205 <xsl:attribute name="cellpadding">
207 <xsl:when test="$cellpadding != ''">
208 <xsl:value-of select="$cellpadding"/>
211 <xsl:value-of select="$html.cellpadding"/>
217 <xsl:if test="../@pgwide=1 or local-name(.) = 'entrytbl'">
218 <xsl:attribute name="width">100%</xsl:attribute>
222 <xsl:when test="$table.borders.with.css != 0">
224 <xsl:when test="../@frame='all' or (not(../@frame) and $default.table.frame='all')">
225 <xsl:attribute name="style">
226 <xsl:text>border-collapse: collapse;</xsl:text>
227 <xsl:call-template name="border">
228 <xsl:with-param name="side" select="'top'"/>
229 <xsl:with-param name="style" select="$table.frame.border.style"/>
230 <xsl:with-param name="color" select="$table.frame.border.color"/>
231 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
233 <xsl:call-template name="border">
234 <xsl:with-param name="side" select="'bottom'"/>
235 <xsl:with-param name="style" select="$table.frame.border.style"/>
236 <xsl:with-param name="color" select="$table.frame.border.color"/>
237 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
239 <xsl:call-template name="border">
240 <xsl:with-param name="side" select="'left'"/>
241 <xsl:with-param name="style" select="$table.frame.border.style"/>
242 <xsl:with-param name="color" select="$table.frame.border.color"/>
243 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
245 <xsl:call-template name="border">
246 <xsl:with-param name="side" select="'right'"/>
247 <xsl:with-param name="style" select="$table.frame.border.style"/>
248 <xsl:with-param name="color" select="$table.frame.border.color"/>
249 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
253 <xsl:when test="../@frame='topbot' or (not(../@frame) and $default.table.frame='topbot')">
254 <xsl:attribute name="style">
255 <xsl:text>border-collapse: collapse;</xsl:text>
256 <xsl:call-template name="border">
257 <xsl:with-param name="side" select="'top'"/>
258 <xsl:with-param name="style" select="$table.frame.border.style"/>
259 <xsl:with-param name="color" select="$table.frame.border.color"/>
260 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
262 <xsl:call-template name="border">
263 <xsl:with-param name="side" select="'bottom'"/>
264 <xsl:with-param name="style" select="$table.frame.border.style"/>
265 <xsl:with-param name="color" select="$table.frame.border.color"/>
266 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
270 <xsl:when test="../@frame='top' or (not(../@frame) and $default.table.frame='top')">
271 <xsl:attribute name="style">
272 <xsl:text>border-collapse: collapse;</xsl:text>
273 <xsl:call-template name="border">
274 <xsl:with-param name="side" select="'top'"/>
275 <xsl:with-param name="style" select="$table.frame.border.style"/>
276 <xsl:with-param name="color" select="$table.frame.border.color"/>
277 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
281 <xsl:when test="../@frame='bottom' or (not(../@frame) and $default.table.frame='bottom')">
282 <xsl:attribute name="style">
283 <xsl:text>border-collapse: collapse;</xsl:text>
284 <xsl:call-template name="border">
285 <xsl:with-param name="side" select="'bottom'"/>
286 <xsl:with-param name="style" select="$table.frame.border.style"/>
287 <xsl:with-param name="color" select="$table.frame.border.color"/>
288 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
292 <xsl:when test="../@frame='sides' or (not(../@frame) and $default.table.frame='sides')">
293 <xsl:attribute name="style">
294 <xsl:text>border-collapse: collapse;</xsl:text>
295 <xsl:call-template name="border">
296 <xsl:with-param name="side" select="'left'"/>
297 <xsl:with-param name="style" select="$table.frame.border.style"/>
298 <xsl:with-param name="color" select="$table.frame.border.color"/>
299 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
301 <xsl:call-template name="border">
302 <xsl:with-param name="side" select="'right'"/>
303 <xsl:with-param name="style" select="$table.frame.border.style"/>
304 <xsl:with-param name="color" select="$table.frame.border.color"/>
305 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
309 <xsl:when test="../@frame='none'">
310 <xsl:attribute name="style">
311 <xsl:text>border: none;</xsl:text>
315 <xsl:attribute name="style">
316 <xsl:text>border-collapse: collapse;</xsl:text>
322 <xsl:when test="../@frame='none' or (not(../@frame) and $default.table.frame='none') or local-name(.) = 'entrytbl'">
323 <xsl:attribute name="border">0</xsl:attribute>
326 <xsl:attribute name="border">1</xsl:attribute>
330 <xsl:variable name="colgroup">
332 <xsl:call-template name="generate.colgroup">
333 <xsl:with-param name="cols" select="@cols"/>
338 <xsl:variable name="explicit.table.width">
339 <xsl:call-template name="pi.dbhtml_table-width">
340 <xsl:with-param name="node" select=".."/>
344 <xsl:variable name="table.width">
346 <xsl:when test="$explicit.table.width != ''">
347 <xsl:value-of select="$explicit.table.width"/>
349 <xsl:when test="$default.table.width = ''">
350 <xsl:text>100%</xsl:text>
353 <xsl:value-of select="$default.table.width"/>
358 <xsl:if test="$default.table.width != ''
359 or $explicit.table.width != ''">
360 <xsl:attribute name="width">
362 <xsl:when test="contains($table.width, '%')">
363 <xsl:value-of select="$table.width"/>
365 <xsl:when test="$use.extensions != 0
366 and $tablecolumns.extension != 0">
368 <xsl:when test="function-available('stbl:convertLength')">
369 <xsl:value-of select="stbl:convertLength($table.width)"/>
371 <xsl:when test="function-available('xtbl:convertLength')">
372 <xsl:value-of select="xtbl:convertLength($table.width)"/>
375 <xsl:message terminate="yes">
376 <xsl:text>No convertLength function available.</xsl:text>
382 <xsl:value-of select="$table.width"/>
389 <xsl:when test="$use.extensions != 0
390 and $tablecolumns.extension != 0">
392 <xsl:when test="function-available('stbl:adjustColumnWidths')">
393 <xsl:copy-of select="stbl:adjustColumnWidths($colgroup)"/>
395 <xsl:when test="function-available('xtbl:adjustColumnWidths')">
396 <xsl:copy-of select="xtbl:adjustColumnWidths($colgroup)"/>
398 <xsl:when test="function-available('ptbl:adjustColumnWidths')">
399 <xsl:copy-of select="ptbl:adjustColumnWidths($colgroup)"/>
402 <xsl:message terminate="yes">
403 <xsl:text>No adjustColumnWidths function available.</xsl:text>
409 <xsl:copy-of select="$colgroup"/>
413 <xsl:apply-templates select="thead"/>
414 <xsl:apply-templates select="tfoot"/>
415 <xsl:apply-templates select="tbody"/>
417 <xsl:if test=".//footnote|../title//footnote">
418 <tbody class="footnotes">
420 <td colspan="{@cols}">
421 <xsl:apply-templates select=".//footnote|../title//footnote" mode="table.footnote.mode"/>
429 <xsl:template match="tgroup/processing-instruction('dbhtml')">
430 <xsl:variable name="summary">
431 <xsl:call-template name="pi.dbhtml_table-summary"/>
434 <!-- Suppress the table-summary PI -->
435 <xsl:if test="$summary = ''">
436 <xsl:processing-instruction name="dbhtml">
437 <xsl:value-of select="."/>
438 </xsl:processing-instruction>
442 <xsl:template match="colspec"></xsl:template>
444 <xsl:template match="spanspec"></xsl:template>
446 <xsl:template match="thead|tfoot">
447 <xsl:element name="{local-name(.)}">
448 <xsl:if test="@align">
449 <xsl:attribute name="align">
450 <xsl:value-of select="@align"/>
453 <xsl:if test="@char">
454 <xsl:attribute name="char">
455 <xsl:value-of select="@char"/>
458 <xsl:if test="@charoff">
459 <xsl:attribute name="charoff">
460 <xsl:value-of select="@charoff"/>
463 <xsl:if test="@valign">
464 <xsl:attribute name="valign">
465 <xsl:value-of select="@valign"/>
469 <xsl:apply-templates select="row[1]">
470 <xsl:with-param name="spans">
471 <xsl:call-template name="blank.spans">
472 <xsl:with-param name="cols" select="../@cols"/>
475 </xsl:apply-templates>
480 <xsl:template match="tbody">
482 <xsl:if test="@align">
483 <xsl:attribute name="align">
484 <xsl:value-of select="@align"/>
487 <xsl:if test="@char">
488 <xsl:attribute name="char">
489 <xsl:value-of select="@char"/>
492 <xsl:if test="@charoff">
493 <xsl:attribute name="charoff">
494 <xsl:value-of select="@charoff"/>
497 <xsl:if test="@valign">
498 <xsl:attribute name="valign">
499 <xsl:value-of select="@valign"/>
503 <xsl:apply-templates select="row[1]">
504 <xsl:with-param name="spans">
505 <xsl:call-template name="blank.spans">
506 <xsl:with-param name="cols" select="../@cols"/>
509 </xsl:apply-templates>
514 <xsl:template match="row">
515 <xsl:param name="spans"/>
518 <xsl:when test="contains($spans, '0')">
519 <xsl:call-template name="normal-row">
520 <xsl:with-param name="spans" select="$spans"/>
526 <xsl:text>Ignoring row: </xsl:text>
527 <xsl:value-of select="$spans"/>
528 <xsl:text> = </xsl:text>
529 <xsl:call-template name="consume-row">
530 <xsl:with-param name="spans" select="$spans"/>
535 <xsl:if test="normalize-space(.//text()) != ''">
536 <xsl:message>Warning: overlapped row contains content!</xsl:message>
539 <tr><xsl:comment> This row intentionally left blank </xsl:comment></tr>
541 <xsl:apply-templates select="following-sibling::row[1]">
542 <xsl:with-param name="spans">
543 <xsl:call-template name="consume-row">
544 <xsl:with-param name="spans" select="$spans"/>
547 </xsl:apply-templates>
552 <xsl:template name="normal-row">
553 <xsl:param name="spans"/>
555 <xsl:variable name="row-height">
556 <xsl:if test="processing-instruction('dbhtml')">
557 <xsl:call-template name="pi.dbhtml_row-height"/>
561 <xsl:variable name="bgcolor">
562 <xsl:if test="processing-instruction('dbhtml')">
563 <xsl:call-template name="pi.dbhtml_bgcolor"/>
567 <xsl:variable name="class">
568 <xsl:if test="processing-instruction('dbhtml')">
569 <xsl:call-template name="pi.dbhtml_class"/>
574 <xsl:call-template name="tr.attributes">
575 <xsl:with-param name="rownum">
576 <xsl:number from="tgroup" count="row"/>
580 <xsl:if test="$row-height != ''">
581 <xsl:attribute name="height">
582 <xsl:value-of select="$row-height"/>
586 <xsl:if test="$bgcolor != ''">
587 <xsl:attribute name="bgcolor">
588 <xsl:value-of select="$bgcolor"/>
592 <xsl:if test="$class != ''">
593 <xsl:attribute name="class">
594 <xsl:value-of select="$class"/>
598 <xsl:if test="$table.borders.with.css != 0">
599 <xsl:if test="@rowsep = 1 and following-sibling::row">
600 <xsl:attribute name="style">
601 <xsl:call-template name="border">
602 <xsl:with-param name="side" select="'bottom'"/>
608 <xsl:if test="@align">
609 <xsl:attribute name="align">
610 <xsl:value-of select="@align"/>
613 <xsl:if test="@char">
614 <xsl:attribute name="char">
615 <xsl:value-of select="@char"/>
618 <xsl:if test="@charoff">
619 <xsl:attribute name="charoff">
620 <xsl:value-of select="@charoff"/>
623 <xsl:if test="@valign">
624 <xsl:attribute name="valign">
625 <xsl:value-of select="@valign"/>
629 <xsl:apply-templates select="(entry|entrytbl)[1]">
630 <xsl:with-param name="spans" select="$spans"/>
631 </xsl:apply-templates>
634 <xsl:if test="following-sibling::row">
635 <xsl:variable name="nextspans">
636 <xsl:apply-templates select="(entry|entrytbl)[1]" mode="span">
637 <xsl:with-param name="spans" select="$spans"/>
638 </xsl:apply-templates>
641 <xsl:apply-templates select="following-sibling::row[1]">
642 <xsl:with-param name="spans" select="$nextspans"/>
643 </xsl:apply-templates>
647 <xsl:template match="entry|entrytbl" name="entry">
648 <xsl:param name="col">
650 <xsl:when test="@revisionflag">
651 <xsl:number from="row"/>
653 <xsl:otherwise>1</xsl:otherwise>
657 <xsl:param name="spans"/>
659 <xsl:variable name="cellgi">
661 <xsl:when test="ancestor::thead">th</xsl:when>
662 <xsl:when test="ancestor::tfoot">th</xsl:when>
663 <xsl:otherwise>td</xsl:otherwise>
667 <xsl:variable name="empty.cell" select="count(node()) = 0"/>
669 <xsl:variable name="named.colnum">
670 <xsl:call-template name="entry.colnum"/>
673 <xsl:variable name="entry.colnum">
675 <xsl:when test="$named.colnum > 0">
676 <xsl:value-of select="$named.colnum"/>
679 <xsl:value-of select="$col"/>
684 <xsl:variable name="entry.colspan">
686 <xsl:when test="@spanname or @namest">
687 <xsl:call-template name="calculate.colspan"/>
689 <xsl:otherwise>1</xsl:otherwise>
693 <xsl:variable name="following.spans">
694 <xsl:call-template name="calculate.following.spans">
695 <xsl:with-param name="colspan" select="$entry.colspan"/>
696 <xsl:with-param name="spans" select="$spans"/>
700 <xsl:variable name="rowsep">
702 <!-- If this is the last row, rowsep never applies. -->
703 <xsl:when test="ancestor::entrytbl
704 and not (ancestor-or-self::row[1]/following-sibling::row)
705 and not (ancestor::thead)">
706 <xsl:value-of select="0"/>
708 <xsl:when test="not(ancestor-or-self::row[1]/following-sibling::row
709 or ancestor-or-self::thead/following-sibling::tbody
710 or ancestor-or-self::tbody/preceding-sibling::tfoot)">
711 <xsl:value-of select="0"/>
713 <xsl:when test="@morerows and not(@morerows <
714 count(ancestor-or-self::row[1]/following-sibling::row))">
715 <xsl:value-of select="0"/>
718 <xsl:call-template name="inherited.table.attribute">
719 <xsl:with-param name="entry" select="."/>
720 <xsl:with-param name="colnum" select="$entry.colnum"/>
721 <xsl:with-param name="attribute" select="'rowsep'"/>
727 <xsl:variable name="colsep">
729 <!-- If this is the last column, colsep never applies. -->
730 <xsl:when test="$following.spans = ''">0</xsl:when>
732 <xsl:call-template name="inherited.table.attribute">
733 <xsl:with-param name="entry" select="."/>
734 <xsl:with-param name="colnum" select="$entry.colnum"/>
735 <xsl:with-param name="attribute" select="'colsep'"/>
741 <xsl:variable name="valign">
742 <xsl:call-template name="inherited.table.attribute">
743 <xsl:with-param name="entry" select="."/>
744 <xsl:with-param name="colnum" select="$entry.colnum"/>
745 <xsl:with-param name="attribute" select="'valign'"/>
749 <xsl:variable name="align">
750 <xsl:call-template name="inherited.table.attribute">
751 <xsl:with-param name="entry" select="."/>
752 <xsl:with-param name="colnum" select="$entry.colnum"/>
753 <xsl:with-param name="attribute" select="'align'"/>
757 <xsl:variable name="char">
758 <xsl:call-template name="inherited.table.attribute">
759 <xsl:with-param name="entry" select="."/>
760 <xsl:with-param name="colnum" select="$entry.colnum"/>
761 <xsl:with-param name="attribute" select="'char'"/>
765 <xsl:variable name="charoff">
766 <xsl:call-template name="inherited.table.attribute">
767 <xsl:with-param name="entry" select="."/>
768 <xsl:with-param name="colnum" select="$entry.colnum"/>
769 <xsl:with-param name="attribute" select="'charoff'"/>
774 <xsl:when test="$spans != '' and not(starts-with($spans,'0:'))">
775 <xsl:call-template name="entry">
776 <xsl:with-param name="col" select="$col+1"/>
777 <xsl:with-param name="spans" select="substring-after($spans,':')"/>
781 <xsl:when test="number($entry.colnum) > $col">
782 <xsl:call-template name="empty.table.cell"/>
783 <xsl:call-template name="entry">
784 <xsl:with-param name="col" select="$col+1"/>
785 <xsl:with-param name="spans" select="substring-after($spans,':')"/>
790 <xsl:variable name="bgcolor">
791 <xsl:if test="processing-instruction('dbhtml')">
792 <xsl:call-template name="pi.dbhtml_bgcolor"/>
796 <xsl:element name="{$cellgi}">
797 <xsl:if test="$bgcolor != ''">
798 <xsl:attribute name="bgcolor">
799 <xsl:value-of select="$bgcolor"/>
803 <xsl:call-template name="locale.html.attributes"/>
804 <xsl:if test="$entry.propagates.style != 0 and @role">
805 <xsl:apply-templates select="." mode="class.attribute">
806 <xsl:with-param name="class" select="@role"/>
807 </xsl:apply-templates>
810 <xsl:if test="$show.revisionflag and @revisionflag">
811 <xsl:attribute name="class">
812 <xsl:value-of select="@revisionflag"/>
816 <xsl:if test="$table.borders.with.css != 0">
817 <xsl:attribute name="style">
818 <xsl:if test="$colsep > 0">
819 <xsl:call-template name="border">
820 <xsl:with-param name="side" select="'right'"/>
823 <xsl:if test="$rowsep > 0">
824 <xsl:call-template name="border">
825 <xsl:with-param name="side" select="'bottom'"/>
831 <xsl:if test="@morerows > 0">
832 <xsl:attribute name="rowspan">
833 <xsl:value-of select="1+@morerows"/>
837 <xsl:if test="$entry.colspan > 1">
838 <xsl:attribute name="colspan">
839 <xsl:value-of select="$entry.colspan"/>
843 <xsl:if test="$align != ''">
844 <xsl:attribute name="align">
845 <xsl:value-of select="$align"/>
849 <xsl:if test="$valign != ''">
850 <xsl:attribute name="valign">
851 <xsl:value-of select="$valign"/>
855 <xsl:if test="$char != ''">
856 <xsl:attribute name="char">
857 <xsl:value-of select="$char"/>
861 <xsl:if test="$charoff != ''">
862 <xsl:attribute name="charoff">
863 <xsl:value-of select="$charoff"/>
867 <xsl:if test="not(preceding-sibling::*) and
868 (ancestor::row[1]/@id or ancestor::row[1]/@xml:id)">
869 <xsl:call-template name="anchor">
870 <xsl:with-param name="node" select="ancestor::row[1]"/>
874 <xsl:call-template name="anchor"/>
877 <xsl:when test="$empty.cell">
878 <xsl:text> </xsl:text>
880 <xsl:when test="self::entrytbl">
881 <xsl:call-template name="tgroup"/>
884 <xsl:apply-templates/>
890 <xsl:when test="following-sibling::entry|following-sibling::entrytbl">
891 <xsl:apply-templates select="(following-sibling::entry
892 |following-sibling::entrytbl)[1]">
893 <xsl:with-param name="col" select="$col+$entry.colspan"/>
894 <xsl:with-param name="spans" select="$following.spans"/>
895 </xsl:apply-templates>
898 <xsl:call-template name="finaltd">
899 <xsl:with-param name="spans" select="$following.spans"/>
900 <xsl:with-param name="col" select="$col+$entry.colspan"/>
908 <xsl:template match="entry|entrytbl" name="sentry" mode="span">
909 <xsl:param name="col" select="1"/>
910 <xsl:param name="spans"/>
912 <xsl:variable name="entry.colnum">
913 <xsl:call-template name="entry.colnum"/>
916 <xsl:variable name="entry.colspan">
918 <xsl:when test="@spanname or @namest">
919 <xsl:call-template name="calculate.colspan"/>
921 <xsl:otherwise>1</xsl:otherwise>
925 <xsl:variable name="following.spans">
926 <xsl:call-template name="calculate.following.spans">
927 <xsl:with-param name="colspan" select="$entry.colspan"/>
928 <xsl:with-param name="spans" select="$spans"/>
933 <xsl:when test="$spans != '' and not(starts-with($spans,'0:'))">
934 <xsl:value-of select="substring-before($spans,':')-1"/>
935 <xsl:text>:</xsl:text>
936 <xsl:call-template name="sentry">
937 <xsl:with-param name="col" select="$col+1"/>
938 <xsl:with-param name="spans" select="substring-after($spans,':')"/>
942 <xsl:when test="number($entry.colnum) > $col">
943 <xsl:text>0:</xsl:text>
944 <xsl:call-template name="sentry">
945 <xsl:with-param name="col" select="$col + 1"/>
946 <xsl:with-param name="spans" select="substring-after($spans,':')"/>
951 <xsl:call-template name="copy-string">
952 <xsl:with-param name="count" select="$entry.colspan"/>
953 <xsl:with-param name="string">
955 <xsl:when test="@morerows">
956 <xsl:value-of select="@morerows"/>
958 <xsl:otherwise>0</xsl:otherwise>
960 <xsl:text>:</xsl:text>
965 <xsl:when test="following-sibling::entry|following-sibling::entrytbl">
966 <xsl:apply-templates select="(following-sibling::entry
967 |following-sibling::entrytbl)[1]"
969 <xsl:with-param name="col" select="$col+$entry.colspan"/>
970 <xsl:with-param name="spans" select="$following.spans"/>
971 </xsl:apply-templates>
974 <xsl:call-template name="sfinaltd">
975 <xsl:with-param name="spans" select="$following.spans"/>
983 <xsl:template name="generate.colgroup">
984 <xsl:param name="cols" select="1"/>
985 <xsl:param name="count" select="1"/>
987 <xsl:when test="$count > $cols"></xsl:when>
989 <xsl:call-template name="generate.col">
990 <xsl:with-param name="countcol" select="$count"/>
992 <xsl:call-template name="generate.colgroup">
993 <xsl:with-param name="cols" select="$cols"/>
994 <xsl:with-param name="count" select="$count+1"/>
1000 <xsl:template name="generate.col">
1001 <xsl:param name="countcol">1</xsl:param>
1002 <xsl:param name="colspecs" select="./colspec"/>
1003 <xsl:param name="count">1</xsl:param>
1004 <xsl:param name="colnum">1</xsl:param>
1007 <xsl:when test="$count>count($colspecs)">
1011 <xsl:variable name="colspec" select="$colspecs[$count=position()]"/>
1012 <xsl:variable name="colspec.colnum">
1014 <xsl:when test="$colspec/@colnum">
1015 <xsl:value-of select="$colspec/@colnum"/>
1018 <xsl:value-of select="$colnum"/>
1024 <xsl:when test="$colspec.colnum=$countcol">
1027 <xsl:when test="$colspec/@colwidth
1028 and $use.extensions != 0
1029 and $tablecolumns.extension != 0">
1030 <xsl:attribute name="width">
1032 <xsl:when test="normalize-space($colspec/@colwidth) = '*'">
1033 <xsl:value-of select="'1*'"/>
1036 <xsl:value-of select="$colspec/@colwidth"/>
1041 <!-- pass through to HTML if no * in colspecs -->
1042 <xsl:when test="$colspec/@colwidth and
1043 not($colspec/parent::*/colspec/@colwidth[contains(.,'*')])">
1044 <xsl:attribute name="width">
1046 <xsl:when test="normalize-space($colspec/@colwidth) = '*'">
1047 <xsl:value-of select="'1*'"/>
1050 <xsl:value-of select="$colspec/@colwidth"/>
1058 <xsl:when test="$colspec/@align">
1059 <xsl:attribute name="align">
1060 <xsl:value-of select="$colspec/@align"/>
1063 <!-- Suggested by Pavel ZAMPACH <zampach@nemcb.cz> -->
1064 <xsl:when test="$colspecs/ancestor::tgroup/@align">
1065 <xsl:attribute name="align">
1066 <xsl:value-of select="$colspecs/ancestor::tgroup/@align"/>
1071 <xsl:if test="$colspec/@char">
1072 <xsl:attribute name="char">
1073 <xsl:value-of select="$colspec/@char"/>
1076 <xsl:if test="$colspec/@charoff">
1077 <xsl:attribute name="charoff">
1078 <xsl:value-of select="$colspec/@charoff"/>
1084 <xsl:call-template name="generate.col">
1085 <xsl:with-param name="countcol" select="$countcol"/>
1086 <xsl:with-param name="colspecs" select="$colspecs"/>
1087 <xsl:with-param name="count" select="$count+1"/>
1088 <xsl:with-param name="colnum">
1090 <xsl:when test="$colspec/@colnum">
1091 <xsl:value-of select="$colspec/@colnum + 1"/>
1094 <xsl:value-of select="$colnum + 1"/>
1098 </xsl:call-template>
1105 <xsl:template name="colspec.colwidth">
1106 <!-- when this macro is called, the current context must be an entry -->
1107 <xsl:param name="colname"></xsl:param>
1108 <!-- .. = row, ../.. = thead|tbody, ../../.. = tgroup -->
1109 <xsl:param name="colspecs" select="../../../../tgroup/colspec"/>
1110 <xsl:param name="count">1</xsl:param>
1112 <xsl:when test="$count>count($colspecs)"></xsl:when>
1114 <xsl:variable name="colspec" select="$colspecs[$count=position()]"/>
1116 <xsl:when test="$colspec/@colname=$colname">
1117 <xsl:value-of select="$colspec/@colwidth"/>
1120 <xsl:call-template name="colspec.colwidth">
1121 <xsl:with-param name="colname" select="$colname"/>
1122 <xsl:with-param name="colspecs" select="$colspecs"/>
1123 <xsl:with-param name="count" select="$count+1"/>
1124 </xsl:call-template>
1131 <!-- ====================================================================== -->
1133 <xsl:template name="tr.attributes">
1134 <xsl:param name="row" select="."/>
1135 <xsl:param name="rownum" select="0"/>
1137 <!-- by default, do nothing. But you might want to say:
1139 <xsl:if test="$rownum mod 2 = 0">
1140 <xsl:attribute name="class">oddrow</xsl:attribute>