cvsimport
[fvwm.git] / doc / docbook-xsl / html / table.xsl
blobcf66847f5f259629578f2e4dadc1368685d05162
1 <?xml version='1.0'?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3 xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
4 xmlns:stbl="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.Table"
5 xmlns:xtbl="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"
9 version='1.0'>
11 <xsl:include href="../common/table.xsl"/>
13 <!-- ********************************************************************
14 $Id: table.xsl,v 1.1 2007/03/10 05:15:13 scott Exp $
15 ********************************************************************
17 This file is part of the XSL DocBook Stylesheet distribution.
18 See ../README or http://nwalsh.com/docbook/xsl/ for copyright
19 and other information.
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">
30 <xsl:choose>
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"/>
36 </xsl:when>
37 <xsl:otherwise>
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'"/>
43 </xsl:call-template>
44 </xsl:otherwise>
45 </xsl:choose>
46 </xsl:variable>
48 <xsl:variable name="colsep">
49 <xsl:choose>
50 <!-- If this is the last column, colsep never applies. -->
51 <xsl:when test="number($colnum) &gt;= ancestor::tgroup/@cols">0</xsl:when>
52 <xsl:otherwise>
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'"/>
58 </xsl:call-template>
59 </xsl:otherwise>
60 </xsl:choose>
61 </xsl:variable>
63 <td class="auto-generated">
64 <xsl:if test="$table.borders.with.css != 0">
65 <xsl:attribute name="style">
66 <xsl:if test="$colsep &gt; 0">
67 <xsl:call-template name="border">
68 <xsl:with-param name="side" select="'right'"/>
69 </xsl:call-template>
70 </xsl:if>
71 <xsl:if test="$rowsep &gt; 0">
72 <xsl:call-template name="border">
73 <xsl:with-param name="side" select="'bottom'"/>
74 </xsl:call-template>
75 </xsl:if>
76 </xsl:attribute>
77 </xsl:if>
78 <xsl:text>&#160;</xsl:text>
79 </td>
80 </xsl:template>
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. -->
93 <xsl:choose>
94 <xsl:when test="($thickness != ''
95 and $style != ''
96 and $color != '')
97 or ($thickness != ''
98 and $style != '')
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>
111 </xsl:when>
112 <xsl:otherwise>
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>
120 </xsl:if>
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>
128 </xsl:if>
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>
136 </xsl:if>
137 </xsl:otherwise>
138 </xsl:choose>
139 </xsl:template>
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>
147 </xsl:message>
148 </xsl:if>
150 <xsl:variable name="summary">
151 <xsl:call-template name="dbhtml-attribute">
152 <xsl:with-param name="pis"
153 select="processing-instruction('dbhtml')"/>
154 <xsl:with-param name="attribute" select="'table-summary'"/>
155 </xsl:call-template>
156 </xsl:variable>
158 <xsl:variable name="cellspacing">
159 <xsl:call-template name="dbhtml-attribute">
160 <xsl:with-param name="pis"
161 select="processing-instruction('dbhtml')"/>
162 <xsl:with-param name="attribute" select="'cellspacing'"/>
163 </xsl:call-template>
164 </xsl:variable>
166 <xsl:variable name="cellpadding">
167 <xsl:call-template name="dbhtml-attribute">
168 <xsl:with-param name="pis"
169 select="processing-instruction('dbhtml')[1]"/>
170 <xsl:with-param name="attribute" select="'cellpadding'"/>
171 </xsl:call-template>
172 </xsl:variable>
174 <table>
175 <xsl:choose>
176 <!-- If there's a textobject/phrase for the table summary, use it -->
177 <xsl:when test="../textobject/phrase">
178 <xsl:attribute name="summary">
179 <xsl:value-of select="../textobject/phrase"/>
180 </xsl:attribute>
181 </xsl:when>
183 <!-- If there's a <?dbhtml table-summary="foo"?> PI, use it for
184 the HTML table summary attribute -->
185 <xsl:when test="$summary != ''">
186 <xsl:attribute name="summary">
187 <xsl:value-of select="$summary"/>
188 </xsl:attribute>
189 </xsl:when>
191 <!-- Otherwise, if there's a title, use that -->
192 <xsl:when test="../title">
193 <xsl:attribute name="summary">
194 <xsl:value-of select="string(../title)"/>
195 </xsl:attribute>
196 </xsl:when>
198 <!-- Otherwise, forget the whole idea -->
199 <xsl:otherwise><!-- nevermind --></xsl:otherwise>
200 </xsl:choose>
202 <xsl:if test="$cellspacing != '' or $html.cellspacing != ''">
203 <xsl:attribute name="cellspacing">
204 <xsl:choose>
205 <xsl:when test="$cellspacing != ''">
206 <xsl:value-of select="$cellspacing"/>
207 </xsl:when>
208 <xsl:otherwise>
209 <xsl:value-of select="$html.cellspacing"/>
210 </xsl:otherwise>
211 </xsl:choose>
212 </xsl:attribute>
213 </xsl:if>
215 <xsl:if test="$cellpadding != '' or $html.cellpadding != ''">
216 <xsl:attribute name="cellpadding">
217 <xsl:choose>
218 <xsl:when test="$cellpadding != ''">
219 <xsl:value-of select="$cellpadding"/>
220 </xsl:when>
221 <xsl:otherwise>
222 <xsl:value-of select="$html.cellpadding"/>
223 </xsl:otherwise>
224 </xsl:choose>
225 </xsl:attribute>
226 </xsl:if>
228 <xsl:if test="../@pgwide=1 or local-name(.) = 'entrytbl'">
229 <xsl:attribute name="width">100%</xsl:attribute>
230 </xsl:if>
232 <xsl:choose>
233 <xsl:when test="$table.borders.with.css != 0">
234 <xsl:attribute name="border">0</xsl:attribute>
235 <xsl:choose>
236 <xsl:when test="../@frame='all' or (not(../@frame) and $default.table.frame='all')">
237 <xsl:attribute name="style">
238 <xsl:text>border-collapse: collapse;</xsl:text>
239 <xsl:call-template name="border">
240 <xsl:with-param name="side" select="'top'"/>
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"/>
244 </xsl:call-template>
245 <xsl:call-template name="border">
246 <xsl:with-param name="side" select="'bottom'"/>
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"/>
250 </xsl:call-template>
251 <xsl:call-template name="border">
252 <xsl:with-param name="side" select="'left'"/>
253 <xsl:with-param name="style" select="$table.frame.border.style"/>
254 <xsl:with-param name="color" select="$table.frame.border.color"/>
255 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
256 </xsl:call-template>
257 <xsl:call-template name="border">
258 <xsl:with-param name="side" select="'right'"/>
259 <xsl:with-param name="style" select="$table.frame.border.style"/>
260 <xsl:with-param name="color" select="$table.frame.border.color"/>
261 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
262 </xsl:call-template>
263 </xsl:attribute>
264 </xsl:when>
265 <xsl:when test="../@frame='topbot' or (not(../@frame) and $default.table.frame='topbot')">
266 <xsl:attribute name="style">
267 <xsl:text>border-collapse: collapse;</xsl:text>
268 <xsl:call-template name="border">
269 <xsl:with-param name="side" select="'top'"/>
270 <xsl:with-param name="style" select="$table.frame.border.style"/>
271 <xsl:with-param name="color" select="$table.frame.border.color"/>
272 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
273 </xsl:call-template>
274 <xsl:call-template name="border">
275 <xsl:with-param name="side" select="'bottom'"/>
276 <xsl:with-param name="style" select="$table.frame.border.style"/>
277 <xsl:with-param name="color" select="$table.frame.border.color"/>
278 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
279 </xsl:call-template>
280 </xsl:attribute>
281 </xsl:when>
282 <xsl:when test="../@frame='top' or (not(../@frame) and $default.table.frame='top')">
283 <xsl:attribute name="style">
284 <xsl:text>border-collapse: collapse;</xsl:text>
285 <xsl:call-template name="border">
286 <xsl:with-param name="side" select="'top'"/>
287 <xsl:with-param name="style" select="$table.frame.border.style"/>
288 <xsl:with-param name="color" select="$table.frame.border.color"/>
289 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
290 </xsl:call-template>
291 </xsl:attribute>
292 </xsl:when>
293 <xsl:when test="../@frame='bottom' or (not(../@frame) and $default.table.frame='bottom')">
294 <xsl:attribute name="style">
295 <xsl:text>border-collapse: collapse;</xsl:text>
296 <xsl:call-template name="border">
297 <xsl:with-param name="side" select="'bottom'"/>
298 <xsl:with-param name="style" select="$table.frame.border.style"/>
299 <xsl:with-param name="color" select="$table.frame.border.color"/>
300 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
301 </xsl:call-template>
302 </xsl:attribute>
303 </xsl:when>
304 <xsl:when test="../@frame='sides' or (not(../@frame) and $default.table.frame='sides')">
305 <xsl:attribute name="style">
306 <xsl:text>border-collapse: collapse;</xsl:text>
307 <xsl:call-template name="border">
308 <xsl:with-param name="side" select="'left'"/>
309 <xsl:with-param name="style" select="$table.frame.border.style"/>
310 <xsl:with-param name="color" select="$table.frame.border.color"/>
311 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
312 </xsl:call-template>
313 <xsl:call-template name="border">
314 <xsl:with-param name="side" select="'right'"/>
315 <xsl:with-param name="style" select="$table.frame.border.style"/>
316 <xsl:with-param name="color" select="$table.frame.border.color"/>
317 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
318 </xsl:call-template>
319 </xsl:attribute>
320 </xsl:when>
321 <xsl:otherwise>
322 <xsl:attribute name="style">
323 <xsl:text>border-collapse: collapse;</xsl:text>
324 </xsl:attribute>
325 </xsl:otherwise>
326 </xsl:choose>
327 </xsl:when>
328 <xsl:when test="../@frame='none' or (not(../@frame) and $default.table.frame='none') or local-name(.) = 'entrytbl'">
329 <xsl:attribute name="border">0</xsl:attribute>
330 </xsl:when>
331 <xsl:otherwise>
332 <xsl:attribute name="border">1</xsl:attribute>
333 </xsl:otherwise>
334 </xsl:choose>
336 <xsl:variable name="colgroup">
337 <colgroup>
338 <xsl:call-template name="generate.colgroup">
339 <xsl:with-param name="cols" select="@cols"/>
340 </xsl:call-template>
341 </colgroup>
342 </xsl:variable>
344 <xsl:variable name="explicit.table.width">
345 <xsl:call-template name="dbhtml-attribute">
346 <xsl:with-param name="pis"
347 select="../processing-instruction('dbhtml')[1]"/>
348 <xsl:with-param name="attribute" select="'table-width'"/>
349 </xsl:call-template>
350 </xsl:variable>
352 <xsl:variable name="table.width">
353 <xsl:choose>
354 <xsl:when test="$explicit.table.width != ''">
355 <xsl:value-of select="$explicit.table.width"/>
356 </xsl:when>
357 <xsl:when test="$default.table.width = ''">
358 <xsl:text>100%</xsl:text>
359 </xsl:when>
360 <xsl:otherwise>
361 <xsl:value-of select="$default.table.width"/>
362 </xsl:otherwise>
363 </xsl:choose>
364 </xsl:variable>
366 <xsl:if test="$default.table.width != ''
367 or $explicit.table.width != ''">
368 <xsl:attribute name="width">
369 <xsl:choose>
370 <xsl:when test="contains($table.width, '%')">
371 <xsl:value-of select="$table.width"/>
372 </xsl:when>
373 <xsl:when test="$use.extensions != 0
374 and $tablecolumns.extension != 0">
375 <xsl:choose>
376 <xsl:when test="function-available('stbl:convertLength')">
377 <xsl:value-of select="stbl:convertLength($table.width)"/>
378 </xsl:when>
379 <xsl:when test="function-available('xtbl:convertLength')">
380 <xsl:value-of select="xtbl:convertLength($table.width)"/>
381 </xsl:when>
382 <xsl:otherwise>
383 <xsl:message terminate="yes">
384 <xsl:text>No convertLength function available.</xsl:text>
385 </xsl:message>
386 </xsl:otherwise>
387 </xsl:choose>
388 </xsl:when>
389 <xsl:otherwise>
390 <xsl:value-of select="$table.width"/>
391 </xsl:otherwise>
392 </xsl:choose>
393 </xsl:attribute>
394 </xsl:if>
396 <xsl:choose>
397 <xsl:when test="$use.extensions != 0
398 and $tablecolumns.extension != 0">
399 <xsl:choose>
400 <xsl:when test="function-available('stbl:adjustColumnWidths')">
401 <xsl:copy-of select="stbl:adjustColumnWidths($colgroup)"/>
402 </xsl:when>
403 <xsl:when test="function-available('xtbl:adjustColumnWidths')">
404 <xsl:copy-of select="xtbl:adjustColumnWidths($colgroup)"/>
405 </xsl:when>
406 <xsl:when test="function-available('ptbl:adjustColumnWidths')">
407 <xsl:copy-of select="ptbl:adjustColumnWidths($colgroup)"/>
408 </xsl:when>
409 <xsl:otherwise>
410 <xsl:message terminate="yes">
411 <xsl:text>No adjustColumnWidths function available.</xsl:text>
412 </xsl:message>
413 </xsl:otherwise>
414 </xsl:choose>
415 </xsl:when>
416 <xsl:otherwise>
417 <xsl:copy-of select="$colgroup"/>
418 </xsl:otherwise>
419 </xsl:choose>
421 <xsl:apply-templates select="thead"/>
422 <xsl:apply-templates select="tfoot"/>
423 <xsl:apply-templates select="tbody"/>
425 <xsl:if test=".//footnote">
426 <tbody class="footnotes">
427 <tr>
428 <td colspan="{@cols}">
429 <xsl:apply-templates select=".//footnote" mode="table.footnote.mode"/>
430 </td>
431 </tr>
432 </tbody>
433 </xsl:if>
434 </table>
435 </xsl:template>
437 <xsl:template match="tgroup/processing-instruction('dbhtml')">
438 <xsl:variable name="summary">
439 <xsl:call-template name="dbhtml-attribute">
440 <xsl:with-param name="pis" select="."/>
441 <xsl:with-param name="attribute" select="'table-summary'"/>
442 </xsl:call-template>
443 </xsl:variable>
445 <!-- Suppress the table-summary PI -->
446 <xsl:if test="$summary = ''">
447 <xsl:processing-instruction name="dbhtml">
448 <xsl:value-of select="."/>
449 </xsl:processing-instruction>
450 </xsl:if>
451 </xsl:template>
453 <xsl:template match="colspec"></xsl:template>
455 <xsl:template match="spanspec"></xsl:template>
457 <xsl:template match="thead|tfoot">
458 <xsl:element name="{local-name(.)}">
459 <xsl:if test="@align">
460 <xsl:attribute name="align">
461 <xsl:value-of select="@align"/>
462 </xsl:attribute>
463 </xsl:if>
464 <xsl:if test="@char">
465 <xsl:attribute name="char">
466 <xsl:value-of select="@char"/>
467 </xsl:attribute>
468 </xsl:if>
469 <xsl:if test="@charoff">
470 <xsl:attribute name="charoff">
471 <xsl:value-of select="@charoff"/>
472 </xsl:attribute>
473 </xsl:if>
474 <xsl:if test="@valign">
475 <xsl:attribute name="valign">
476 <xsl:value-of select="@valign"/>
477 </xsl:attribute>
478 </xsl:if>
480 <xsl:apply-templates select="row[1]">
481 <xsl:with-param name="spans">
482 <xsl:call-template name="blank.spans">
483 <xsl:with-param name="cols" select="../@cols"/>
484 </xsl:call-template>
485 </xsl:with-param>
486 </xsl:apply-templates>
488 </xsl:element>
489 </xsl:template>
491 <xsl:template match="tbody">
492 <tbody>
493 <xsl:if test="@align">
494 <xsl:attribute name="align">
495 <xsl:value-of select="@align"/>
496 </xsl:attribute>
497 </xsl:if>
498 <xsl:if test="@char">
499 <xsl:attribute name="char">
500 <xsl:value-of select="@char"/>
501 </xsl:attribute>
502 </xsl:if>
503 <xsl:if test="@charoff">
504 <xsl:attribute name="charoff">
505 <xsl:value-of select="@charoff"/>
506 </xsl:attribute>
507 </xsl:if>
508 <xsl:if test="@valign">
509 <xsl:attribute name="valign">
510 <xsl:value-of select="@valign"/>
511 </xsl:attribute>
512 </xsl:if>
514 <xsl:apply-templates select="row[1]">
515 <xsl:with-param name="spans">
516 <xsl:call-template name="blank.spans">
517 <xsl:with-param name="cols" select="../@cols"/>
518 </xsl:call-template>
519 </xsl:with-param>
520 </xsl:apply-templates>
522 </tbody>
523 </xsl:template>
525 <xsl:template match="row">
526 <xsl:param name="spans"/>
528 <xsl:choose>
529 <xsl:when test="contains($spans, '0')">
530 <xsl:call-template name="normal-row">
531 <xsl:with-param name="spans" select="$spans"/>
532 </xsl:call-template>
533 </xsl:when>
534 <xsl:otherwise>
535 <!--
536 <xsl:message>
537 <xsl:text>Ignoring row: </xsl:text>
538 <xsl:value-of select="$spans"/>
539 <xsl:text> = </xsl:text>
540 <xsl:call-template name="consume-row">
541 <xsl:with-param name="spans" select="$spans"/>
542 </xsl:call-template>
543 </xsl:message>
546 <xsl:if test="normalize-space(.//text()) != ''">
547 <xsl:message>Warning: overlapped row contains content!</xsl:message>
548 </xsl:if>
550 <tr><xsl:comment> This row intentionally left blank </xsl:comment></tr>
552 <xsl:apply-templates select="following-sibling::row[1]">
553 <xsl:with-param name="spans">
554 <xsl:call-template name="consume-row">
555 <xsl:with-param name="spans" select="$spans"/>
556 </xsl:call-template>
557 </xsl:with-param>
558 </xsl:apply-templates>
559 </xsl:otherwise>
560 </xsl:choose>
561 </xsl:template>
563 <xsl:template name="normal-row">
564 <xsl:param name="spans"/>
566 <xsl:variable name="row-height">
567 <xsl:if test="processing-instruction('dbhtml')">
568 <xsl:call-template name="dbhtml-attribute">
569 <xsl:with-param name="pis" select="processing-instruction('dbhtml')"/>
570 <xsl:with-param name="attribute" select="'row-height'"/>
571 </xsl:call-template>
572 </xsl:if>
573 </xsl:variable>
575 <xsl:variable name="bgcolor">
576 <xsl:if test="processing-instruction('dbhtml')">
577 <xsl:call-template name="dbhtml-attribute">
578 <xsl:with-param name="pis" select="processing-instruction('dbhtml')"/>
579 <xsl:with-param name="attribute" select="'bgcolor'"/>
580 </xsl:call-template>
581 </xsl:if>
582 </xsl:variable>
584 <xsl:variable name="class">
585 <xsl:if test="processing-instruction('dbhtml')">
586 <xsl:call-template name="dbhtml-attribute">
587 <xsl:with-param name="pis" select="processing-instruction('dbhtml')"/>
588 <xsl:with-param name="attribute" select="'class'"/>
589 </xsl:call-template>
590 </xsl:if>
591 </xsl:variable>
593 <tr>
594 <xsl:call-template name="tr.attributes">
595 <xsl:with-param name="rownum">
596 <xsl:number from="tgroup" count="row"/>
597 </xsl:with-param>
598 </xsl:call-template>
600 <xsl:if test="$row-height != ''">
601 <xsl:attribute name="height">
602 <xsl:value-of select="$row-height"/>
603 </xsl:attribute>
604 </xsl:if>
606 <xsl:if test="$bgcolor != ''">
607 <xsl:attribute name="bgcolor">
608 <xsl:value-of select="$bgcolor"/>
609 </xsl:attribute>
610 </xsl:if>
612 <xsl:if test="$class != ''">
613 <xsl:attribute name="class">
614 <xsl:value-of select="$class"/>
615 </xsl:attribute>
616 </xsl:if>
618 <xsl:if test="$table.borders.with.css != 0">
619 <xsl:if test="@rowsep = 1 and following-sibling::row">
620 <xsl:attribute name="style">
621 <xsl:call-template name="border">
622 <xsl:with-param name="side" select="'bottom'"/>
623 </xsl:call-template>
624 </xsl:attribute>
625 </xsl:if>
626 </xsl:if>
628 <xsl:if test="@align">
629 <xsl:attribute name="align">
630 <xsl:value-of select="@align"/>
631 </xsl:attribute>
632 </xsl:if>
633 <xsl:if test="@char">
634 <xsl:attribute name="char">
635 <xsl:value-of select="@char"/>
636 </xsl:attribute>
637 </xsl:if>
638 <xsl:if test="@charoff">
639 <xsl:attribute name="charoff">
640 <xsl:value-of select="@charoff"/>
641 </xsl:attribute>
642 </xsl:if>
643 <xsl:if test="@valign">
644 <xsl:attribute name="valign">
645 <xsl:value-of select="@valign"/>
646 </xsl:attribute>
647 </xsl:if>
649 <xsl:apply-templates select="(entry|entrytbl)[1]">
650 <xsl:with-param name="spans" select="$spans"/>
651 </xsl:apply-templates>
652 </tr>
654 <xsl:if test="following-sibling::row">
655 <xsl:variable name="nextspans">
656 <xsl:apply-templates select="(entry|entrytbl)[1]" mode="span">
657 <xsl:with-param name="spans" select="$spans"/>
658 </xsl:apply-templates>
659 </xsl:variable>
661 <xsl:apply-templates select="following-sibling::row[1]">
662 <xsl:with-param name="spans" select="$nextspans"/>
663 </xsl:apply-templates>
664 </xsl:if>
665 </xsl:template>
667 <xsl:template match="entry|entrytbl" name="entry">
668 <xsl:param name="col" select="1"/>
669 <xsl:param name="spans"/>
671 <xsl:variable name="cellgi">
672 <xsl:choose>
673 <xsl:when test="ancestor::thead">th</xsl:when>
674 <xsl:when test="ancestor::tfoot">th</xsl:when>
675 <xsl:otherwise>td</xsl:otherwise>
676 </xsl:choose>
677 </xsl:variable>
679 <xsl:variable name="empty.cell" select="count(node()) = 0"/>
681 <xsl:variable name="named.colnum">
682 <xsl:call-template name="entry.colnum"/>
683 </xsl:variable>
685 <xsl:variable name="entry.colnum">
686 <xsl:choose>
687 <xsl:when test="$named.colnum &gt; 0">
688 <xsl:value-of select="$named.colnum"/>
689 </xsl:when>
690 <xsl:otherwise>
691 <xsl:value-of select="$col"/>
692 </xsl:otherwise>
693 </xsl:choose>
694 </xsl:variable>
696 <xsl:variable name="entry.colspan">
697 <xsl:choose>
698 <xsl:when test="@spanname or @namest">
699 <xsl:call-template name="calculate.colspan"/>
700 </xsl:when>
701 <xsl:otherwise>1</xsl:otherwise>
702 </xsl:choose>
703 </xsl:variable>
705 <xsl:variable name="following.spans">
706 <xsl:call-template name="calculate.following.spans">
707 <xsl:with-param name="colspan" select="$entry.colspan"/>
708 <xsl:with-param name="spans" select="$spans"/>
709 </xsl:call-template>
710 </xsl:variable>
712 <xsl:variable name="rowsep">
713 <xsl:choose>
714 <!-- If this is the last row, rowsep never applies. -->
715 <xsl:when test="ancestor::entrytbl
716 and not (ancestor-or-self::row[1]/following-sibling::row)">
717 <xsl:value-of select="0"/>
718 </xsl:when>
719 <xsl:when test="not(ancestor-or-self::row[1]/following-sibling::row
720 or ancestor-or-self::thead/following-sibling::tbody
721 or ancestor-or-self::tbody/preceding-sibling::tfoot)">
722 <xsl:value-of select="0"/>
723 </xsl:when>
724 <xsl:when test="@morerows and not(@morerows &lt;
725 count(ancestor-or-self::row[1]/following-sibling::row))">
726 <xsl:value-of select="0"/>
727 </xsl:when>
728 <xsl:otherwise>
729 <xsl:call-template name="inherited.table.attribute">
730 <xsl:with-param name="entry" select="."/>
731 <xsl:with-param name="colnum" select="$entry.colnum"/>
732 <xsl:with-param name="attribute" select="'rowsep'"/>
733 </xsl:call-template>
734 </xsl:otherwise>
735 </xsl:choose>
736 </xsl:variable>
738 <xsl:variable name="colsep">
739 <xsl:choose>
740 <!-- If this is the last column, colsep never applies. -->
741 <xsl:when test="$following.spans = ''">0</xsl:when>
742 <xsl:otherwise>
743 <xsl:call-template name="inherited.table.attribute">
744 <xsl:with-param name="entry" select="."/>
745 <xsl:with-param name="colnum" select="$entry.colnum"/>
746 <xsl:with-param name="attribute" select="'colsep'"/>
747 </xsl:call-template>
748 </xsl:otherwise>
749 </xsl:choose>
750 </xsl:variable>
752 <xsl:variable name="valign">
753 <xsl:call-template name="inherited.table.attribute">
754 <xsl:with-param name="entry" select="."/>
755 <xsl:with-param name="colnum" select="$entry.colnum"/>
756 <xsl:with-param name="attribute" select="'valign'"/>
757 </xsl:call-template>
758 </xsl:variable>
760 <xsl:variable name="align">
761 <xsl:call-template name="inherited.table.attribute">
762 <xsl:with-param name="entry" select="."/>
763 <xsl:with-param name="colnum" select="$entry.colnum"/>
764 <xsl:with-param name="attribute" select="'align'"/>
765 </xsl:call-template>
766 </xsl:variable>
768 <xsl:variable name="char">
769 <xsl:call-template name="inherited.table.attribute">
770 <xsl:with-param name="entry" select="."/>
771 <xsl:with-param name="colnum" select="$entry.colnum"/>
772 <xsl:with-param name="attribute" select="'char'"/>
773 </xsl:call-template>
774 </xsl:variable>
776 <xsl:variable name="charoff">
777 <xsl:call-template name="inherited.table.attribute">
778 <xsl:with-param name="entry" select="."/>
779 <xsl:with-param name="colnum" select="$entry.colnum"/>
780 <xsl:with-param name="attribute" select="'charoff'"/>
781 </xsl:call-template>
782 </xsl:variable>
784 <xsl:choose>
785 <xsl:when test="$spans != '' and not(starts-with($spans,'0:'))">
786 <xsl:call-template name="entry">
787 <xsl:with-param name="col" select="$col+1"/>
788 <xsl:with-param name="spans" select="substring-after($spans,':')"/>
789 </xsl:call-template>
790 </xsl:when>
792 <xsl:when test="number($entry.colnum) &gt; $col">
793 <xsl:call-template name="empty.table.cell"/>
794 <xsl:call-template name="entry">
795 <xsl:with-param name="col" select="$col+1"/>
796 <xsl:with-param name="spans" select="substring-after($spans,':')"/>
797 </xsl:call-template>
798 </xsl:when>
800 <xsl:otherwise>
801 <xsl:variable name="bgcolor">
802 <xsl:if test="processing-instruction('dbhtml')">
803 <xsl:call-template name="dbhtml-attribute">
804 <xsl:with-param name="pis" select="processing-instruction('dbhtml')"/>
805 <xsl:with-param name="attribute" select="'bgcolor'"/>
806 </xsl:call-template>
807 </xsl:if>
808 </xsl:variable>
810 <xsl:element name="{$cellgi}">
811 <xsl:if test="$bgcolor != ''">
812 <xsl:attribute name="bgcolor">
813 <xsl:value-of select="$bgcolor"/>
814 </xsl:attribute>
815 </xsl:if>
817 <xsl:if test="$entry.propagates.style != 0 and @role">
818 <xsl:apply-templates select="." mode="class.attribute">
819 <xsl:with-param name="class" select="@role"/>
820 </xsl:apply-templates>
821 </xsl:if>
823 <xsl:if test="$show.revisionflag and @revisionflag">
824 <xsl:attribute name="class">
825 <xsl:value-of select="@revisionflag"/>
826 </xsl:attribute>
827 </xsl:if>
829 <xsl:if test="$table.borders.with.css != 0">
830 <xsl:attribute name="style">
831 <xsl:if test="$colsep &gt; 0">
832 <xsl:call-template name="border">
833 <xsl:with-param name="side" select="'right'"/>
834 </xsl:call-template>
835 </xsl:if>
836 <xsl:if test="$rowsep &gt; 0">
837 <xsl:call-template name="border">
838 <xsl:with-param name="side" select="'bottom'"/>
839 </xsl:call-template>
840 </xsl:if>
841 </xsl:attribute>
842 </xsl:if>
844 <xsl:if test="@morerows &gt; 0">
845 <xsl:attribute name="rowspan">
846 <xsl:value-of select="1+@morerows"/>
847 </xsl:attribute>
848 </xsl:if>
850 <xsl:if test="$entry.colspan &gt; 1">
851 <xsl:attribute name="colspan">
852 <xsl:value-of select="$entry.colspan"/>
853 </xsl:attribute>
854 </xsl:if>
856 <xsl:if test="$align != ''">
857 <xsl:attribute name="align">
858 <xsl:value-of select="$align"/>
859 </xsl:attribute>
860 </xsl:if>
862 <xsl:if test="$valign != ''">
863 <xsl:attribute name="valign">
864 <xsl:value-of select="$valign"/>
865 </xsl:attribute>
866 </xsl:if>
868 <xsl:if test="$char != ''">
869 <xsl:attribute name="char">
870 <xsl:value-of select="$char"/>
871 </xsl:attribute>
872 </xsl:if>
874 <xsl:if test="$charoff != ''">
875 <xsl:attribute name="charoff">
876 <xsl:value-of select="$charoff"/>
877 </xsl:attribute>
878 </xsl:if>
880 <xsl:if test="not(preceding-sibling::*) and
881 (ancestor::row[1]/@id or ancestor::row[1]/@xml:id)">
882 <xsl:call-template name="anchor">
883 <xsl:with-param name="node" select="ancestor::row[1]"/>
884 </xsl:call-template>
885 </xsl:if>
887 <xsl:call-template name="anchor"/>
889 <xsl:choose>
890 <xsl:when test="$empty.cell">
891 <xsl:text>&#160;</xsl:text>
892 </xsl:when>
893 <xsl:when test="self::entrytbl">
894 <xsl:call-template name="tgroup"/>
895 </xsl:when>
896 <xsl:otherwise>
897 <xsl:apply-templates/>
898 </xsl:otherwise>
899 </xsl:choose>
900 </xsl:element>
902 <xsl:choose>
903 <xsl:when test="following-sibling::entry|following-sibling::entrytbl">
904 <xsl:apply-templates select="(following-sibling::entry
905 |following-sibling::entrytbl)[1]">
906 <xsl:with-param name="col" select="$col+$entry.colspan"/>
907 <xsl:with-param name="spans" select="$following.spans"/>
908 </xsl:apply-templates>
909 </xsl:when>
910 <xsl:otherwise>
911 <xsl:call-template name="finaltd">
912 <xsl:with-param name="spans" select="$following.spans"/>
913 <xsl:with-param name="col" select="$col+$entry.colspan"/>
914 </xsl:call-template>
915 </xsl:otherwise>
916 </xsl:choose>
917 </xsl:otherwise>
918 </xsl:choose>
919 </xsl:template>
921 <xsl:template match="entry|entrytbl" name="sentry" mode="span">
922 <xsl:param name="col" select="1"/>
923 <xsl:param name="spans"/>
925 <xsl:variable name="entry.colnum">
926 <xsl:call-template name="entry.colnum"/>
927 </xsl:variable>
929 <xsl:variable name="entry.colspan">
930 <xsl:choose>
931 <xsl:when test="@spanname or @namest">
932 <xsl:call-template name="calculate.colspan"/>
933 </xsl:when>
934 <xsl:otherwise>1</xsl:otherwise>
935 </xsl:choose>
936 </xsl:variable>
938 <xsl:variable name="following.spans">
939 <xsl:call-template name="calculate.following.spans">
940 <xsl:with-param name="colspan" select="$entry.colspan"/>
941 <xsl:with-param name="spans" select="$spans"/>
942 </xsl:call-template>
943 </xsl:variable>
945 <xsl:choose>
946 <xsl:when test="$spans != '' and not(starts-with($spans,'0:'))">
947 <xsl:value-of select="substring-before($spans,':')-1"/>
948 <xsl:text>:</xsl:text>
949 <xsl:call-template name="sentry">
950 <xsl:with-param name="col" select="$col+1"/>
951 <xsl:with-param name="spans" select="substring-after($spans,':')"/>
952 </xsl:call-template>
953 </xsl:when>
955 <xsl:when test="number($entry.colnum) &gt; $col">
956 <xsl:text>0:</xsl:text>
957 <xsl:call-template name="sentry">
958 <xsl:with-param name="col" select="$col+$entry.colspan"/>
959 <xsl:with-param name="spans" select="$following.spans"/>
960 </xsl:call-template>
961 </xsl:when>
963 <xsl:otherwise>
964 <xsl:call-template name="copy-string">
965 <xsl:with-param name="count" select="$entry.colspan"/>
966 <xsl:with-param name="string">
967 <xsl:choose>
968 <xsl:when test="@morerows">
969 <xsl:value-of select="@morerows"/>
970 </xsl:when>
971 <xsl:otherwise>0</xsl:otherwise>
972 </xsl:choose>
973 <xsl:text>:</xsl:text>
974 </xsl:with-param>
975 </xsl:call-template>
977 <xsl:choose>
978 <xsl:when test="following-sibling::entry|following-sibling::entrytbl">
979 <xsl:apply-templates select="(following-sibling::entry
980 |following-sibling::entrytbl)[1]"
981 mode="span">
982 <xsl:with-param name="col" select="$col+$entry.colspan"/>
983 <xsl:with-param name="spans" select="$following.spans"/>
984 </xsl:apply-templates>
985 </xsl:when>
986 <xsl:otherwise>
987 <xsl:call-template name="sfinaltd">
988 <xsl:with-param name="spans" select="$following.spans"/>
989 </xsl:call-template>
990 </xsl:otherwise>
991 </xsl:choose>
992 </xsl:otherwise>
993 </xsl:choose>
994 </xsl:template>
996 <xsl:template name="generate.colgroup">
997 <xsl:param name="cols" select="1"/>
998 <xsl:param name="count" select="1"/>
999 <xsl:choose>
1000 <xsl:when test="$count &gt; $cols"></xsl:when>
1001 <xsl:otherwise>
1002 <xsl:call-template name="generate.col">
1003 <xsl:with-param name="countcol" select="$count"/>
1004 </xsl:call-template>
1005 <xsl:call-template name="generate.colgroup">
1006 <xsl:with-param name="cols" select="$cols"/>
1007 <xsl:with-param name="count" select="$count+1"/>
1008 </xsl:call-template>
1009 </xsl:otherwise>
1010 </xsl:choose>
1011 </xsl:template>
1013 <xsl:template name="generate.col">
1014 <xsl:param name="countcol">1</xsl:param>
1015 <xsl:param name="colspecs" select="./colspec"/>
1016 <xsl:param name="count">1</xsl:param>
1017 <xsl:param name="colnum">1</xsl:param>
1019 <xsl:choose>
1020 <xsl:when test="$count>count($colspecs)">
1021 <col/>
1022 </xsl:when>
1023 <xsl:otherwise>
1024 <xsl:variable name="colspec" select="$colspecs[$count=position()]"/>
1025 <xsl:variable name="colspec.colnum">
1026 <xsl:choose>
1027 <xsl:when test="$colspec/@colnum">
1028 <xsl:value-of select="$colspec/@colnum"/>
1029 </xsl:when>
1030 <xsl:otherwise>
1031 <xsl:value-of select="$colnum"/>
1032 </xsl:otherwise>
1033 </xsl:choose>
1034 </xsl:variable>
1036 <xsl:choose>
1037 <xsl:when test="$colspec.colnum=$countcol">
1038 <col>
1039 <xsl:if test="$colspec/@colwidth
1040 and $use.extensions != 0
1041 and $tablecolumns.extension != 0">
1042 <xsl:attribute name="width">
1043 <xsl:choose>
1044 <xsl:when test="normalize-space($colspec/@colwidth) = '*'">
1045 <xsl:value-of select="'1*'"/>
1046 </xsl:when>
1047 <xsl:otherwise>
1048 <xsl:value-of select="$colspec/@colwidth"/>
1049 </xsl:otherwise>
1050 </xsl:choose>
1051 </xsl:attribute>
1052 </xsl:if>
1054 <xsl:choose>
1055 <xsl:when test="$colspec/@align">
1056 <xsl:attribute name="align">
1057 <xsl:value-of select="$colspec/@align"/>
1058 </xsl:attribute>
1059 </xsl:when>
1060 <!-- Suggested by Pavel ZAMPACH <zampach@nemcb.cz> -->
1061 <xsl:when test="$colspecs/ancestor::tgroup/@align">
1062 <xsl:attribute name="align">
1063 <xsl:value-of select="$colspecs/ancestor::tgroup/@align"/>
1064 </xsl:attribute>
1065 </xsl:when>
1066 </xsl:choose>
1068 <xsl:if test="$colspec/@char">
1069 <xsl:attribute name="char">
1070 <xsl:value-of select="$colspec/@char"/>
1071 </xsl:attribute>
1072 </xsl:if>
1073 <xsl:if test="$colspec/@charoff">
1074 <xsl:attribute name="charoff">
1075 <xsl:value-of select="$colspec/@charoff"/>
1076 </xsl:attribute>
1077 </xsl:if>
1078 </col>
1079 </xsl:when>
1080 <xsl:otherwise>
1081 <xsl:call-template name="generate.col">
1082 <xsl:with-param name="countcol" select="$countcol"/>
1083 <xsl:with-param name="colspecs" select="$colspecs"/>
1084 <xsl:with-param name="count" select="$count+1"/>
1085 <xsl:with-param name="colnum">
1086 <xsl:choose>
1087 <xsl:when test="$colspec/@colnum">
1088 <xsl:value-of select="$colspec/@colnum + 1"/>
1089 </xsl:when>
1090 <xsl:otherwise>
1091 <xsl:value-of select="$colnum + 1"/>
1092 </xsl:otherwise>
1093 </xsl:choose>
1094 </xsl:with-param>
1095 </xsl:call-template>
1096 </xsl:otherwise>
1097 </xsl:choose>
1098 </xsl:otherwise>
1099 </xsl:choose>
1100 </xsl:template>
1102 <xsl:template name="colspec.colwidth">
1103 <!-- when this macro is called, the current context must be an entry -->
1104 <xsl:param name="colname"></xsl:param>
1105 <!-- .. = row, ../.. = thead|tbody, ../../.. = tgroup -->
1106 <xsl:param name="colspecs" select="../../../../tgroup/colspec"/>
1107 <xsl:param name="count">1</xsl:param>
1108 <xsl:choose>
1109 <xsl:when test="$count>count($colspecs)"></xsl:when>
1110 <xsl:otherwise>
1111 <xsl:variable name="colspec" select="$colspecs[$count=position()]"/>
1112 <xsl:choose>
1113 <xsl:when test="$colspec/@colname=$colname">
1114 <xsl:value-of select="$colspec/@colwidth"/>
1115 </xsl:when>
1116 <xsl:otherwise>
1117 <xsl:call-template name="colspec.colwidth">
1118 <xsl:with-param name="colname" select="$colname"/>
1119 <xsl:with-param name="colspecs" select="$colspecs"/>
1120 <xsl:with-param name="count" select="$count+1"/>
1121 </xsl:call-template>
1122 </xsl:otherwise>
1123 </xsl:choose>
1124 </xsl:otherwise>
1125 </xsl:choose>
1126 </xsl:template>
1128 <!-- ====================================================================== -->
1130 <xsl:template name="tr.attributes">
1131 <xsl:param name="row" select="."/>
1132 <xsl:param name="rownum" select="0"/>
1134 <!-- by default, do nothing. But you might want to say:
1136 <xsl:if test="$rownum mod 2 = 0">
1137 <xsl:attribute name="class">oddrow</xsl:attribute>
1138 </xsl:if>
1141 </xsl:template>
1143 </xsl:stylesheet>