Debian Codegraph @

docs/xsl-generic/html/table.xsl

raw
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'>
10
11 <xsl:include href="../common/table.xsl"/>
12
13 <!-- ********************************************************************
14 $Id: table.xsl 7009 2007-07-11 09:42:54Z mzjn $
15 ********************************************************************
16
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.
20
21 ******************************************************************** -->
22
23 <lxslt:component prefix="xtbl"
24 functions="adjustColumnWidths"/>
25
26 <xsl:template name="empty.table.cell">
27 <xsl:param name="colnum" select="0"/>
28
29 <xsl:variable name="rowsep">
30 <xsl: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>
47
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>
62
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>
81
82 <!-- ==================================================================== -->
83
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"/>
90
91 <!-- Note: Some browsers (mozilla) require at least a width and style. -->
92
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>
121
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>
129
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>
140
141 <!-- ==================================================================== -->
142
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>
149
150 <xsl:variable name="summary">
151 <xsl:call-template name="pi.dbhtml_table-summary"/>
152 </xsl:variable>
153
154 <xsl:variable name="cellspacing">
155 <xsl:call-template name="pi.dbhtml_cellspacing"/>
156 </xsl:variable>
157
158 <xsl:variable name="cellpadding">
159 <xsl:call-template name="pi.dbhtml_cellpadding"/>
160 </xsl:variable>
161
162 <table>
163 <xsl:choose>
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"/>
168 </xsl:attribute>
169 </xsl:when>
170
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"/>
176 </xsl:attribute>
177 </xsl:when>
178
179 <!-- Otherwise, if there's a title, use that -->
180 <xsl:when test="../title">
181 <xsl:attribute name="summary">
182 <xsl:value-of select="string(../title)"/>
183 </xsl:attribute>
184 </xsl:when>
185
186 <!-- Otherwise, forget the whole idea -->
187 <xsl:otherwise><!-- nevermind --></xsl:otherwise>
188 </xsl:choose>
189
190 <xsl:if test="$cellspacing != '' or $html.cellspacing != ''">
191 <xsl:attribute name="cellspacing">
192 <xsl:choose>
193 <xsl:when test="$cellspacing != ''">
194 <xsl:value-of select="$cellspacing"/>
195 </xsl:when>
196 <xsl:otherwise>
197 <xsl:value-of select="$html.cellspacing"/>
198 </xsl:otherwise>
199 </xsl:choose>
200 </xsl:attribute>
201 </xsl:if>
202
203 <xsl:if test="$cellpadding != '' or $html.cellpadding != ''">
204 <xsl:attribute name="cellpadding">
205 <xsl:choose>
206 <xsl:when test="$cellpadding != ''">
207 <xsl:value-of select="$cellpadding"/>
208 </xsl:when>
209 <xsl:otherwise>
210 <xsl:value-of select="$html.cellpadding"/>
211 </xsl:otherwise>
212 </xsl:choose>
213 </xsl:attribute>
214 </xsl:if>
215
216 <xsl:if test="../@pgwide=1 or local-name(.) = 'entrytbl'">
217 <xsl:attribute name="width">100%</xsl:attribute>
218 </xsl:if>
219
220 <xsl:choose>
221 <xsl:when test="$table.borders.with.css != 0">
222 <xsl:choose>
223 <xsl:when test="../@frame='all' or (not(../@frame) and $default.table.frame='all')">
224 <xsl:attribute name="style">
225 <xsl:text>border-collapse: collapse;</xsl:text>
226 <xsl:call-template name="border">
227 <xsl:with-param name="side" select="'top'"/>
228 <xsl:with-param name="style" select="$table.frame.border.style"/>
229 <xsl:with-param name="color" select="$table.frame.border.color"/>
230 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
231 </xsl:call-template>
232 <xsl:call-template name="border">
233 <xsl:with-param name="side" select="'bottom'"/>
234 <xsl:with-param name="style" select="$table.frame.border.style"/>
235 <xsl:with-param name="color" select="$table.frame.border.color"/>
236 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
237 </xsl:call-template>
238 <xsl:call-template name="border">
239 <xsl:with-param name="side" select="'left'"/>
240 <xsl:with-param name="style" select="$table.frame.border.style"/>
241 <xsl:with-param name="color" select="$table.frame.border.color"/>
242 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
243 </xsl:call-template>
244 <xsl:call-template name="border">
245 <xsl:with-param name="side" select="'right'"/>
246 <xsl:with-param name="style" select="$table.frame.border.style"/>
247 <xsl:with-param name="color" select="$table.frame.border.color"/>
248 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
249 </xsl:call-template>
250 </xsl:attribute>
251 </xsl:when>
252 <xsl:when test="../@frame='topbot' or (not(../@frame) and $default.table.frame='topbot')">
253 <xsl:attribute name="style">
254 <xsl:text>border-collapse: collapse;</xsl:text>
255 <xsl:call-template name="border">
256 <xsl:with-param name="side" select="'top'"/>
257 <xsl:with-param name="style" select="$table.frame.border.style"/>
258 <xsl:with-param name="color" select="$table.frame.border.color"/>
259 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
260 </xsl:call-template>
261 <xsl:call-template name="border">
262 <xsl:with-param name="side" select="'bottom'"/>
263 <xsl:with-param name="style" select="$table.frame.border.style"/>
264 <xsl:with-param name="color" select="$table.frame.border.color"/>
265 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
266 </xsl:call-template>
267 </xsl:attribute>
268 </xsl:when>
269 <xsl:when test="../@frame='top' or (not(../@frame) and $default.table.frame='top')">
270 <xsl:attribute name="style">
271 <xsl:text>border-collapse: collapse;</xsl:text>
272 <xsl:call-template name="border">
273 <xsl:with-param name="side" select="'top'"/>
274 <xsl:with-param name="style" select="$table.frame.border.style"/>
275 <xsl:with-param name="color" select="$table.frame.border.color"/>
276 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
277 </xsl:call-template>
278 </xsl:attribute>
279 </xsl:when>
280 <xsl:when test="../@frame='bottom' or (not(../@frame) and $default.table.frame='bottom')">
281 <xsl:attribute name="style">
282 <xsl:text>border-collapse: collapse;</xsl:text>
283 <xsl:call-template name="border">
284 <xsl:with-param name="side" select="'bottom'"/>
285 <xsl:with-param name="style" select="$table.frame.border.style"/>
286 <xsl:with-param name="color" select="$table.frame.border.color"/>
287 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
288 </xsl:call-template>
289 </xsl:attribute>
290 </xsl:when>
291 <xsl:when test="../@frame='sides' or (not(../@frame) and $default.table.frame='sides')">
292 <xsl:attribute name="style">
293 <xsl:text>border-collapse: collapse;</xsl:text>
294 <xsl:call-template name="border">
295 <xsl:with-param name="side" select="'left'"/>
296 <xsl:with-param name="style" select="$table.frame.border.style"/>
297 <xsl:with-param name="color" select="$table.frame.border.color"/>
298 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
299 </xsl:call-template>
300 <xsl:call-template name="border">
301 <xsl:with-param name="side" select="'right'"/>
302 <xsl:with-param name="style" select="$table.frame.border.style"/>
303 <xsl:with-param name="color" select="$table.frame.border.color"/>
304 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
305 </xsl:call-template>
306 </xsl:attribute>
307 </xsl:when>
308 <xsl:when test="../@frame='none'">
309 <xsl:attribute name="style">
310 <xsl:text>border: none;</xsl:text>
311 </xsl:attribute>
312 </xsl:when>
313 <xsl:otherwise>
314 <xsl:attribute name="style">
315 <xsl:text>border-collapse: collapse;</xsl:text>
316 </xsl:attribute>
317 </xsl:otherwise>
318 </xsl:choose>
319
320 </xsl:when>
321 <xsl:when test="../@frame='none' or (not(../@frame) and $default.table.frame='none') or local-name(.) = 'entrytbl'">
322 <xsl:attribute name="border">0</xsl:attribute>
323 </xsl:when>
324 <xsl:otherwise>
325 <xsl:attribute name="border">1</xsl:attribute>
326 </xsl:otherwise>
327 </xsl:choose>
328
329 <xsl:variable name="colgroup">
330 <colgroup>
331 <xsl:call-template name="generate.colgroup">
332 <xsl:with-param name="cols" select="@cols"/>
333 </xsl:call-template>
334 </colgroup>
335 </xsl:variable>
336
337 <xsl:variable name="explicit.table.width">
338 <xsl:call-template name="pi.dbhtml_table-width">
339 <xsl:with-param name="node" select=".."/>
340 </xsl:call-template>
341 </xsl:variable>
342
343 <xsl:variable name="table.width">
344 <xsl:choose>
345 <xsl:when test="$explicit.table.width != ''">
346 <xsl:value-of select="$explicit.table.width"/>
347 </xsl:when>
348 <xsl:when test="$default.table.width = ''">
349 <xsl:text>100%</xsl:text>
350 </xsl:when>
351 <xsl:otherwise>
352 <xsl:value-of select="$default.table.width"/>
353 </xsl:otherwise>
354 </xsl:choose>
355 </xsl:variable>
356
357 <xsl:if test="$default.table.width != ''
358 or $explicit.table.width != ''">
359 <xsl:attribute name="width">
360 <xsl:choose>
361 <xsl:when test="contains($table.width, '%')">
362 <xsl:value-of select="$table.width"/>
363 </xsl:when>
364 <xsl:when test="$use.extensions != 0
365 and $tablecolumns.extension != 0">
366 <xsl:choose>
367 <xsl:when test="function-available('stbl:convertLength')">
368 <xsl:value-of select="stbl:convertLength($table.width)"/>
369 </xsl:when>
370 <xsl:when test="function-available('xtbl:convertLength')">
371 <xsl:value-of select="xtbl:convertLength($table.width)"/>
372 </xsl:when>
373 <xsl:otherwise>
374 <xsl:message terminate="yes">
375 <xsl:text>No convertLength function available.</xsl:text>
376 </xsl:message>
377 </xsl:otherwise>
378 </xsl:choose>
379 </xsl:when>
380 <xsl:otherwise>
381 <xsl:value-of select="$table.width"/>
382 </xsl:otherwise>
383 </xsl:choose>
384 </xsl:attribute>
385 </xsl:if>
386
387 <xsl:choose>
388 <xsl:when test="$use.extensions != 0
389 and $tablecolumns.extension != 0">
390 <xsl:choose>
391 <xsl:when test="function-available('stbl:adjustColumnWidths')">
392 <xsl:copy-of select="stbl:adjustColumnWidths($colgroup)"/>
393 </xsl:when>
394 <xsl:when test="function-available('xtbl:adjustColumnWidths')">
395 <xsl:copy-of select="xtbl:adjustColumnWidths($colgroup)"/>
396 </xsl:when>
397 <xsl:when test="function-available('ptbl:adjustColumnWidths')">
398 <xsl:copy-of select="ptbl:adjustColumnWidths($colgroup)"/>
399 </xsl:when>
400 <xsl:otherwise>
401 <xsl:message terminate="yes">
402 <xsl:text>No adjustColumnWidths function available.</xsl:text>
403 </xsl:message>
404 </xsl:otherwise>
405 </xsl:choose>
406 </xsl:when>
407 <xsl:otherwise>
408 <xsl:copy-of select="$colgroup"/>
409 </xsl:otherwise>
410 </xsl:choose>
411
412 <xsl:apply-templates select="thead"/>
413 <xsl:apply-templates select="tfoot"/>
414 <xsl:apply-templates select="tbody"/>
415
416 <xsl:if test=".//footnote">
417 <tbody class="footnotes">
418 <tr>
419 <td colspan="{@cols}">
420 <xsl:apply-templates select=".//footnote" mode="table.footnote.mode"/>
421 </td>
422 </tr>
423 </tbody>
424 </xsl:if>
425 </table>
426 </xsl:template>
427
428 <xsl:template match="tgroup/processing-instruction('dbhtml')">
429 <xsl:variable name="summary">
430 <xsl:call-template name="pi.dbhtml_table-summary"/>
431 </xsl:variable>
432
433 <!-- Suppress the table-summary PI -->
434 <xsl:if test="$summary = ''">
435 <xsl:processing-instruction name="dbhtml">
436 <xsl:value-of select="."/>
437 </xsl:processing-instruction>
438 </xsl:if>
439 </xsl:template>
440
441 <xsl:template match="colspec"></xsl:template>
442
443 <xsl:template match="spanspec"></xsl:template>
444
445 <xsl:template match="thead|tfoot">
446 <xsl:element name="{local-name(.)}">
447 <xsl:if test="@align">
448 <xsl:attribute name="align">
449 <xsl:value-of select="@align"/>
450 </xsl:attribute>
451 </xsl:if>
452 <xsl:if test="@char">
453 <xsl:attribute name="char">
454 <xsl:value-of select="@char"/>
455 </xsl:attribute>
456 </xsl:if>
457 <xsl:if test="@charoff">
458 <xsl:attribute name="charoff">
459 <xsl:value-of select="@charoff"/>
460 </xsl:attribute>
461 </xsl:if>
462 <xsl:if test="@valign">
463 <xsl:attribute name="valign">
464 <xsl:value-of select="@valign"/>
465 </xsl:attribute>
466 </xsl:if>
467
468 <xsl:apply-templates select="row[1]">
469 <xsl:with-param name="spans">
470 <xsl:call-template name="blank.spans">
471 <xsl:with-param name="cols" select="../@cols"/>
472 </xsl:call-template>
473 </xsl:with-param>
474 </xsl:apply-templates>
475
476 </xsl:element>
477 </xsl:template>
478
479 <xsl:template match="tbody">
480 <tbody>
481 <xsl:if test="@align">
482 <xsl:attribute name="align">
483 <xsl:value-of select="@align"/>
484 </xsl:attribute>
485 </xsl:if>
486 <xsl:if test="@char">
487 <xsl:attribute name="char">
488 <xsl:value-of select="@char"/>
489 </xsl:attribute>
490 </xsl:if>
491 <xsl:if test="@charoff">
492 <xsl:attribute name="charoff">
493 <xsl:value-of select="@charoff"/>
494 </xsl:attribute>
495 </xsl:if>
496 <xsl:if test="@valign">
497 <xsl:attribute name="valign">
498 <xsl:value-of select="@valign"/>
499 </xsl:attribute>
500 </xsl:if>
501
502 <xsl:apply-templates select="row[1]">
503 <xsl:with-param name="spans">
504 <xsl:call-template name="blank.spans">
505 <xsl:with-param name="cols" select="../@cols"/>
506 </xsl:call-template>
507 </xsl:with-param>
508 </xsl:apply-templates>
509
510 </tbody>
511 </xsl:template>
512
513 <xsl:template match="row">
514 <xsl:param name="spans"/>
515
516 <xsl:choose>
517 <xsl:when test="contains($spans, '0')">
518 <xsl:call-template name="normal-row">
519 <xsl:with-param name="spans" select="$spans"/>
520 </xsl:call-template>
521 </xsl:when>
522 <xsl:otherwise>
523 <!--
524 <xsl:message>
525 <xsl:text>Ignoring row: </xsl:text>
526 <xsl:value-of select="$spans"/>
527 <xsl:text> = </xsl:text>
528 <xsl:call-template name="consume-row">
529 <xsl:with-param name="spans" select="$spans"/>
530 </xsl:call-template>
531 </xsl:message>
532 -->
533
534 <xsl:if test="normalize-space(.//text()) != ''">
535 <xsl:message>Warning: overlapped row contains content!</xsl:message>
536 </xsl:if>
537
538 <tr><xsl:comment> This row intentionally left blank </xsl:comment></tr>
539
540 <xsl:apply-templates select="following-sibling::row[1]">
541 <xsl:with-param name="spans">
542 <xsl:call-template name="consume-row">
543 <xsl:with-param name="spans" select="$spans"/>
544 </xsl:call-template>
545 </xsl:with-param>
546 </xsl:apply-templates>
547 </xsl:otherwise>
548 </xsl:choose>
549 </xsl:template>
550
551 <xsl:template name="normal-row">
552 <xsl:param name="spans"/>
553
554 <xsl:variable name="row-height">
555 <xsl:if test="processing-instruction('dbhtml')">
556 <xsl:call-template name="pi.dbhtml_row-height"/>
557 </xsl:if>
558 </xsl:variable>
559
560 <xsl:variable name="bgcolor">
561 <xsl:if test="processing-instruction('dbhtml')">
562 <xsl:call-template name="pi.dbhtml_bgcolor"/>
563 </xsl:if>
564 </xsl:variable>
565
566 <xsl:variable name="class">
567 <xsl:if test="processing-instruction('dbhtml')">
568 <xsl:call-template name="pi.dbhtml_class"/>
569 </xsl:if>
570 </xsl:variable>
571
572 <tr>
573 <xsl:call-template name="tr.attributes">
574 <xsl:with-param name="rownum">
575 <xsl:number from="tgroup" count="row"/>
576 </xsl:with-param>
577 </xsl:call-template>
578
579 <xsl:if test="$row-height != ''">
580 <xsl:attribute name="height">
581 <xsl:value-of select="$row-height"/>
582 </xsl:attribute>
583 </xsl:if>
584
585 <xsl:if test="$bgcolor != ''">
586 <xsl:attribute name="bgcolor">
587 <xsl:value-of select="$bgcolor"/>
588 </xsl:attribute>
589 </xsl:if>
590
591 <xsl:if test="$class != ''">
592 <xsl:attribute name="class">
593 <xsl:value-of select="$class"/>
594 </xsl:attribute>
595 </xsl:if>
596
597 <xsl:if test="$table.borders.with.css != 0">
598 <xsl:if test="@rowsep = 1 and following-sibling::row">
599 <xsl:attribute name="style">
600 <xsl:call-template name="border">
601 <xsl:with-param name="side" select="'bottom'"/>
602 </xsl:call-template>
603 </xsl:attribute>
604 </xsl:if>
605 </xsl:if>
606
607 <xsl:if test="@align">
608 <xsl:attribute name="align">
609 <xsl:value-of select="@align"/>
610 </xsl:attribute>
611 </xsl:if>
612 <xsl:if test="@char">
613 <xsl:attribute name="char">
614 <xsl:value-of select="@char"/>
615 </xsl:attribute>
616 </xsl:if>
617 <xsl:if test="@charoff">
618 <xsl:attribute name="charoff">
619 <xsl:value-of select="@charoff"/>
620 </xsl:attribute>
621 </xsl:if>
622 <xsl:if test="@valign">
623 <xsl:attribute name="valign">
624 <xsl:value-of select="@valign"/>
625 </xsl:attribute>
626 </xsl:if>
627
628 <xsl:apply-templates select="(entry|entrytbl)[1]">
629 <xsl:with-param name="spans" select="$spans"/>
630 </xsl:apply-templates>
631 </tr>
632
633 <xsl:if test="following-sibling::row">
634 <xsl:variable name="nextspans">
635 <xsl:apply-templates select="(entry|entrytbl)[1]" mode="span">
636 <xsl:with-param name="spans" select="$spans"/>
637 </xsl:apply-templates>
638 </xsl:variable>
639
640 <xsl:apply-templates select="following-sibling::row[1]">
641 <xsl:with-param name="spans" select="$nextspans"/>
642 </xsl:apply-templates>
643 </xsl:if>
644 </xsl:template>
645
646 <xsl:template match="entry|entrytbl" name="entry">
647 <xsl:param name="col" select="1"/>
648 <xsl:param name="spans"/>
649
650 <xsl:variable name="cellgi">
651 <xsl:choose>
652 <xsl:when test="ancestor::thead">th</xsl:when>
653 <xsl:when test="ancestor::tfoot">th</xsl:when>
654 <xsl:otherwise>td</xsl:otherwise>
655 </xsl:choose>
656 </xsl:variable>
657
658 <xsl:variable name="empty.cell" select="count(node()) = 0"/>
659
660 <xsl:variable name="named.colnum">
661 <xsl:call-template name="entry.colnum"/>
662 </xsl:variable>
663
664 <xsl:variable name="entry.colnum">
665 <xsl:choose>
666 <xsl:when test="$named.colnum &gt; 0">
667 <xsl:value-of select="$named.colnum"/>
668 </xsl:when>
669 <xsl:otherwise>
670 <xsl:value-of select="$col"/>
671 </xsl:otherwise>
672 </xsl:choose>
673 </xsl:variable>
674
675 <xsl:variable name="entry.colspan">
676 <xsl:choose>
677 <xsl:when test="@spanname or @namest">
678 <xsl:call-template name="calculate.colspan"/>
679 </xsl:when>
680 <xsl:otherwise>1</xsl:otherwise>
681 </xsl:choose>
682 </xsl:variable>
683
684 <xsl:variable name="following.spans">
685 <xsl:call-template name="calculate.following.spans">
686 <xsl:with-param name="colspan" select="$entry.colspan"/>
687 <xsl:with-param name="spans" select="$spans"/>
688 </xsl:call-template>
689 </xsl:variable>
690
691 <xsl:variable name="rowsep">
692 <xsl:choose>
693 <!-- If this is the last row, rowsep never applies. -->
694 <xsl:when test="ancestor::entrytbl
695 and not (ancestor-or-self::row[1]/following-sibling::row)">
696 <xsl:value-of select="0"/>
697 </xsl:when>
698 <xsl:when test="not(ancestor-or-self::row[1]/following-sibling::row
699 or ancestor-or-self::thead/following-sibling::tbody
700 or ancestor-or-self::tbody/preceding-sibling::tfoot)">
701 <xsl:value-of select="0"/>
702 </xsl:when>
703 <xsl:when test="@morerows and not(@morerows &lt;
704 count(ancestor-or-self::row[1]/following-sibling::row))">
705 <xsl:value-of select="0"/>
706 </xsl:when>
707 <xsl:otherwise>
708 <xsl:call-template name="inherited.table.attribute">
709 <xsl:with-param name="entry" select="."/>
710 <xsl:with-param name="colnum" select="$entry.colnum"/>
711 <xsl:with-param name="attribute" select="'rowsep'"/>
712 </xsl:call-template>
713 </xsl:otherwise>
714 </xsl:choose>
715 </xsl:variable>
716
717 <xsl:variable name="colsep">
718 <xsl:choose>
719 <!-- If this is the last column, colsep never applies. -->
720 <xsl:when test="$following.spans = ''">0</xsl:when>
721 <xsl:otherwise>
722 <xsl:call-template name="inherited.table.attribute">
723 <xsl:with-param name="entry" select="."/>
724 <xsl:with-param name="colnum" select="$entry.colnum"/>
725 <xsl:with-param name="attribute" select="'colsep'"/>
726 </xsl:call-template>
727 </xsl:otherwise>
728 </xsl:choose>
729 </xsl:variable>
730
731 <xsl:variable name="valign">
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="'valign'"/>
736 </xsl:call-template>
737 </xsl:variable>
738
739 <xsl:variable name="align">
740 <xsl:call-template name="inherited.table.attribute">
741 <xsl:with-param name="entry" select="."/>
742 <xsl:with-param name="colnum" select="$entry.colnum"/>
743 <xsl:with-param name="attribute" select="'align'"/>
744 </xsl:call-template>
745 </xsl:variable>
746
747 <xsl:variable name="char">
748 <xsl:call-template name="inherited.table.attribute">
749 <xsl:with-param name="entry" select="."/>
750 <xsl:with-param name="colnum" select="$entry.colnum"/>
751 <xsl:with-param name="attribute" select="'char'"/>
752 </xsl:call-template>
753 </xsl:variable>
754
755 <xsl:variable name="charoff">
756 <xsl:call-template name="inherited.table.attribute">
757 <xsl:with-param name="entry" select="."/>
758 <xsl:with-param name="colnum" select="$entry.colnum"/>
759 <xsl:with-param name="attribute" select="'charoff'"/>
760 </xsl:call-template>
761 </xsl:variable>
762
763 <xsl:choose>
764 <xsl:when test="$spans != '' and not(starts-with($spans,'0:'))">
765 <xsl:call-template name="entry">
766 <xsl:with-param name="col" select="$col+1"/>
767 <xsl:with-param name="spans" select="substring-after($spans,':')"/>
768 </xsl:call-template>
769 </xsl:when>
770
771 <xsl:when test="number($entry.colnum) &gt; $col">
772 <xsl:call-template name="empty.table.cell"/>
773 <xsl:call-template name="entry">
774 <xsl:with-param name="col" select="$col+1"/>
775 <xsl:with-param name="spans" select="substring-after($spans,':')"/>
776 </xsl:call-template>
777 </xsl:when>
778
779 <xsl:otherwise>
780 <xsl:variable name="bgcolor">
781 <xsl:if test="processing-instruction('dbhtml')">
782 <xsl:call-template name="pi.dbhtml_bgcolor"/>
783 </xsl:if>
784 </xsl:variable>
785
786 <xsl:element name="{$cellgi}">
787 <xsl:if test="$bgcolor != ''">
788 <xsl:attribute name="bgcolor">
789 <xsl:value-of select="$bgcolor"/>
790 </xsl:attribute>
791 </xsl:if>
792
793 <xsl:if test="$entry.propagates.style != 0 and @role">
794 <xsl:apply-templates select="." mode="class.attribute">
795 <xsl:with-param name="class" select="@role"/>
796 </xsl:apply-templates>
797 </xsl:if>
798
799 <xsl:if test="$show.revisionflag and @revisionflag">
800 <xsl:attribute name="class">
801 <xsl:value-of select="@revisionflag"/>
802 </xsl:attribute>
803 </xsl:if>
804
805 <xsl:if test="$table.borders.with.css != 0">
806 <xsl:attribute name="style">
807 <xsl:if test="$colsep &gt; 0">
808 <xsl:call-template name="border">
809 <xsl:with-param name="side" select="'right'"/>
810 </xsl:call-template>
811 </xsl:if>
812 <xsl:if test="$rowsep &gt; 0">
813 <xsl:call-template name="border">
814 <xsl:with-param name="side" select="'bottom'"/>
815 </xsl:call-template>
816 </xsl:if>
817 </xsl:attribute>
818 </xsl:if>
819
820 <xsl:if test="@morerows &gt; 0">
821 <xsl:attribute name="rowspan">
822 <xsl:value-of select="1+@morerows"/>
823 </xsl:attribute>
824 </xsl:if>
825
826 <xsl:if test="$entry.colspan &gt; 1">
827 <xsl:attribute name="colspan">
828 <xsl:value-of select="$entry.colspan"/>
829 </xsl:attribute>
830 </xsl:if>
831
832 <xsl:if test="$align != ''">
833 <xsl:attribute name="align">
834 <xsl:value-of select="$align"/>
835 </xsl:attribute>
836 </xsl:if>
837
838 <xsl:if test="$valign != ''">
839 <xsl:attribute name="valign">
840 <xsl:value-of select="$valign"/>
841 </xsl:attribute>
842 </xsl:if>
843
844 <xsl:if test="$char != ''">
845 <xsl:attribute name="char">
846 <xsl:value-of select="$char"/>
847 </xsl:attribute>
848 </xsl:if>
849
850 <xsl:if test="$charoff != ''">
851 <xsl:attribute name="charoff">
852 <xsl:value-of select="$charoff"/>
853 </xsl:attribute>
854 </xsl:if>
855
856 <xsl:if test="not(preceding-sibling::*) and
857 (ancestor::row[1]/@id or ancestor::row[1]/@xml:id)">
858 <xsl:call-template name="anchor">
859 <xsl:with-param name="node" select="ancestor::row[1]"/>
860 </xsl:call-template>
861 </xsl:if>
862
863 <xsl:call-template name="anchor"/>
864
865 <xsl:choose>
866 <xsl:when test="$empty.cell">
867 <xsl:text>&#160;</xsl:text>
868 </xsl:when>
869 <xsl:when test="self::entrytbl">
870 <xsl:call-template name="tgroup"/>
871 </xsl:when>
872 <xsl:otherwise>
873 <xsl:apply-templates/>
874 </xsl:otherwise>
875 </xsl:choose>
876 </xsl:element>
877
878 <xsl:choose>
879 <xsl:when test="following-sibling::entry|following-sibling::entrytbl">
880 <xsl:apply-templates select="(following-sibling::entry
881 |following-sibling::entrytbl)[1]">
882 <xsl:with-param name="col" select="$col+$entry.colspan"/>
883 <xsl:with-param name="spans" select="$following.spans"/>
884 </xsl:apply-templates>
885 </xsl:when>
886 <xsl:otherwise>
887 <xsl:call-template name="finaltd">
888 <xsl:with-param name="spans" select="$following.spans"/>
889 <xsl:with-param name="col" select="$col+$entry.colspan"/>
890 </xsl:call-template>
891 </xsl:otherwise>
892 </xsl:choose>
893 </xsl:otherwise>
894 </xsl:choose>
895 </xsl:template>
896
897 <xsl:template match="entry|entrytbl" name="sentry" mode="span">
898 <xsl:param name="col" select="1"/>
899 <xsl:param name="spans"/>
900
901 <xsl:variable name="entry.colnum">
902 <xsl:call-template name="entry.colnum"/>
903 </xsl:variable>
904
905 <xsl:variable name="entry.colspan">
906 <xsl:choose>
907 <xsl:when test="@spanname or @namest">
908 <xsl:call-template name="calculate.colspan"/>
909 </xsl:when>
910 <xsl:otherwise>1</xsl:otherwise>
911 </xsl:choose>
912 </xsl:variable>
913
914 <xsl:variable name="following.spans">
915 <xsl:call-template name="calculate.following.spans">
916 <xsl:with-param name="colspan" select="$entry.colspan"/>
917 <xsl:with-param name="spans" select="$spans"/>
918 </xsl:call-template>
919 </xsl:variable>
920
921 <xsl:choose>
922 <xsl:when test="$spans != '' and not(starts-with($spans,'0:'))">
923 <xsl:value-of select="substring-before($spans,':')-1"/>
924 <xsl:text>:</xsl:text>
925 <xsl:call-template name="sentry">
926 <xsl:with-param name="col" select="$col+1"/>
927 <xsl:with-param name="spans" select="substring-after($spans,':')"/>
928 </xsl:call-template>
929 </xsl:when>
930
931 <xsl:when test="number($entry.colnum) &gt; $col">
932 <xsl:text>0:</xsl:text>
933 <xsl:call-template name="sentry">
934 <xsl:with-param name="col" select="$col+$entry.colspan"/>
935 <xsl:with-param name="spans" select="$following.spans"/>
936 </xsl:call-template>
937 </xsl:when>
938
939 <xsl:otherwise>
940 <xsl:call-template name="copy-string">
941 <xsl:with-param name="count" select="$entry.colspan"/>
942 <xsl:with-param name="string">
943 <xsl:choose>
944 <xsl:when test="@morerows">
945 <xsl:value-of select="@morerows"/>
946 </xsl:when>
947 <xsl:otherwise>0</xsl:otherwise>
948 </xsl:choose>
949 <xsl:text>:</xsl:text>
950 </xsl:with-param>
951 </xsl:call-template>
952
953 <xsl:choose>
954 <xsl:when test="following-sibling::entry|following-sibling::entrytbl">
955 <xsl:apply-templates select="(following-sibling::entry
956 |following-sibling::entrytbl)[1]"
957 mode="span">
958 <xsl:with-param name="col" select="$col+$entry.colspan"/>
959 <xsl:with-param name="spans" select="$following.spans"/>
960 </xsl:apply-templates>
961 </xsl:when>
962 <xsl:otherwise>
963 <xsl:call-template name="sfinaltd">
964 <xsl:with-param name="spans" select="$following.spans"/>
965 </xsl:call-template>
966 </xsl:otherwise>
967 </xsl:choose>
968 </xsl:otherwise>
969 </xsl:choose>
970 </xsl:template>
971
972 <xsl:template name="generate.colgroup">
973 <xsl:param name="cols" select="1"/>
974 <xsl:param name="count" select="1"/>
975 <xsl:choose>
976 <xsl:when test="$count &gt; $cols"></xsl:when>
977 <xsl:otherwise>
978 <xsl:call-template name="generate.col">
979 <xsl:with-param name="countcol" select="$count"/>
980 </xsl:call-template>
981 <xsl:call-template name="generate.colgroup">
982 <xsl:with-param name="cols" select="$cols"/>
983 <xsl:with-param name="count" select="$count+1"/>
984 </xsl:call-template>
985 </xsl:otherwise>
986 </xsl:choose>
987 </xsl:template>
988
989 <xsl:template name="generate.col">
990 <xsl:param name="countcol">1</xsl:param>
991 <xsl:param name="colspecs" select="./colspec"/>
992 <xsl:param name="count">1</xsl:param>
993 <xsl:param name="colnum">1</xsl:param>
994
995 <xsl:choose>
996 <xsl:when test="$count>count($colspecs)">
997 <col/>
998 </xsl:when>
999 <xsl:otherwise>
1000 <xsl:variable name="colspec" select="$colspecs[$count=position()]"/>
1001 <xsl:variable name="colspec.colnum">
1002 <xsl:choose>
1003 <xsl:when test="$colspec/@colnum">
1004 <xsl:value-of select="$colspec/@colnum"/>
1005 </xsl:when>
1006 <xsl:otherwise>
1007 <xsl:value-of select="$colnum"/>
1008 </xsl:otherwise>
1009 </xsl:choose>
1010 </xsl:variable>
1011
1012 <xsl:choose>
1013 <xsl:when test="$colspec.colnum=$countcol">
1014 <col>
1015 <xsl:if test="$colspec/@colwidth
1016 and $use.extensions != 0
1017 and $tablecolumns.extension != 0">
1018 <xsl:attribute name="width">
1019 <xsl:choose>
1020 <xsl:when test="normalize-space($colspec/@colwidth) = '*'">
1021 <xsl:value-of select="'1*'"/>
1022 </xsl:when>
1023 <xsl:otherwise>
1024 <xsl:value-of select="$colspec/@colwidth"/>
1025 </xsl:otherwise>
1026 </xsl:choose>
1027 </xsl:attribute>
1028 </xsl:if>
1029
1030 <xsl:choose>
1031 <xsl:when test="$colspec/@align">
1032 <xsl:attribute name="align">
1033 <xsl:value-of select="$colspec/@align"/>
1034 </xsl:attribute>
1035 </xsl:when>
1036 <!-- Suggested by Pavel ZAMPACH <[email protected]> -->
1037 <xsl:when test="$colspecs/ancestor::tgroup/@align">
1038 <xsl:attribute name="align">
1039 <xsl:value-of select="$colspecs/ancestor::tgroup/@align"/>
1040 </xsl:attribute>
1041 </xsl:when>
1042 </xsl:choose>
1043
1044 <xsl:if test="$colspec/@char">
1045 <xsl:attribute name="char">
1046 <xsl:value-of select="$colspec/@char"/>
1047 </xsl:attribute>
1048 </xsl:if>
1049 <xsl:if test="$colspec/@charoff">
1050 <xsl:attribute name="charoff">
1051 <xsl:value-of select="$colspec/@charoff"/>
1052 </xsl:attribute>
1053 </xsl:if>
1054 </col>
1055 </xsl:when>
1056 <xsl:otherwise>
1057 <xsl:call-template name="generate.col">
1058 <xsl:with-param name="countcol" select="$countcol"/>
1059 <xsl:with-param name="colspecs" select="$colspecs"/>
1060 <xsl:with-param name="count" select="$count+1"/>
1061 <xsl:with-param name="colnum">
1062 <xsl:choose>
1063 <xsl:when test="$colspec/@colnum">
1064 <xsl:value-of select="$colspec/@colnum + 1"/>
1065 </xsl:when>
1066 <xsl:otherwise>
1067 <xsl:value-of select="$colnum + 1"/>
1068 </xsl:otherwise>
1069 </xsl:choose>
1070 </xsl:with-param>
1071 </xsl:call-template>
1072 </xsl:otherwise>
1073 </xsl:choose>
1074 </xsl:otherwise>
1075 </xsl:choose>
1076 </xsl:template>
1077
1078 <xsl:template name="colspec.colwidth">
1079 <!-- when this macro is called, the current context must be an entry -->
1080 <xsl:param name="colname"></xsl:param>
1081 <!-- .. = row, ../.. = thead|tbody, ../../.. = tgroup -->
1082 <xsl:param name="colspecs" select="../../../../tgroup/colspec"/>
1083 <xsl:param name="count">1</xsl:param>
1084 <xsl:choose>
1085 <xsl:when test="$count>count($colspecs)"></xsl:when>
1086 <xsl:otherwise>
1087 <xsl:variable name="colspec" select="$colspecs[$count=position()]"/>
1088 <xsl:choose>
1089 <xsl:when test="$colspec/@colname=$colname">
1090 <xsl:value-of select="$colspec/@colwidth"/>
1091 </xsl:when>
1092 <xsl:otherwise>
1093 <xsl:call-template name="colspec.colwidth">
1094 <xsl:with-param name="colname" select="$colname"/>
1095 <xsl:with-param name="colspecs" select="$colspecs"/>
1096 <xsl:with-param name="count" select="$count+1"/>
1097 </xsl:call-template>
1098 </xsl:otherwise>
1099 </xsl:choose>
1100 </xsl:otherwise>
1101 </xsl:choose>
1102 </xsl:template>
1103
1104 <!-- ====================================================================== -->
1105
1106 <xsl:template name="tr.attributes">
1107 <xsl:param name="row" select="."/>
1108 <xsl:param name="rownum" select="0"/>
1109
1110 <!-- by default, do nothing. But you might want to say:
1111
1112 <xsl:if test="$rownum mod 2 = 0">
1113 <xsl:attribute name="class">oddrow</xsl:attribute>
1114 </xsl:if>
1115
1116 -->
1117 </xsl:template>
1118
1119 </xsl:stylesheet>
1120