Debian Codegraph @

docbook-xsl-ns/xhtml/table.xsl

raw
1 <?xml version="1.0" encoding="ASCII"?><!--This file was created automatically by html2xhtml--><!--from the HTML stylesheets.--><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:d="http://docbook.org/ns/docbook" xmlns:doc="http://nwalsh.com/xsl/documentation/1.0" xmlns:stbl="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.Table" xmlns:xtbl="xalan://com.nwalsh.xalan.Table" xmlns:lxslt="http://xml.apache.org/xslt" xmlns:ptbl="http://nwalsh.com/xslt/ext/xsltproc/python/Table" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="doc stbl xtbl lxslt ptbl d" version="1.0">
2
3 <xsl:include href="../common/table.xsl"/>
4
5 <!-- ********************************************************************
6
7 This file is part of the XSL DocBook Stylesheet distribution.
8 See ../README or http://cdn.docbook.org/release/xsl/current/ for
9 copyright and other information.
10
11 ******************************************************************** -->
12
13 <lxslt:component prefix="xtbl" functions="adjustColumnWidths"/>
14
15 <xsl:template name="empty.table.cell">
16 <xsl:param name="colnum" select="0"/>
17
18 <xsl:variable name="rowsep">
19 <xsl:choose>
20 <!-- If this is the last row, rowsep never applies. -->
21 <xsl:when test="not(ancestor-or-self::d:row[1]/following-sibling::d:row or ancestor-or-self::d:thead/following-sibling::d:tbody or ancestor-or-self::d:tbody/preceding-sibling::d:tfoot)">
22 <xsl:value-of select="0"/>
23 </xsl:when>
24 <xsl:otherwise>
25 <xsl:call-template name="inherited.table.attribute">
26 <xsl:with-param name="entry" select="NOT-AN-ELEMENT-NAME"/>
27 <xsl:with-param name="row" select="ancestor-or-self::d:row[1]"/>
28 <xsl:with-param name="colnum" select="$colnum"/>
29 <xsl:with-param name="attribute" select="'rowsep'"/>
30 </xsl:call-template>
31 </xsl:otherwise>
32 </xsl:choose>
33 </xsl:variable>
34
35 <xsl:variable name="colsep">
36 <xsl:choose>
37 <!-- If this is the last column, colsep never applies. -->
38 <xsl:when test="number($colnum) &gt;= ancestor::d:tgroup/@cols">0</xsl:when>
39 <xsl:otherwise>
40 <xsl:call-template name="inherited.table.attribute">
41 <xsl:with-param name="entry" select="NOT-AN-ELEMENT-NAME"/>
42 <xsl:with-param name="row" select="ancestor-or-self::d:row[1]"/>
43 <xsl:with-param name="colnum" select="$colnum"/>
44 <xsl:with-param name="attribute" select="'colsep'"/>
45 </xsl:call-template>
46 </xsl:otherwise>
47 </xsl:choose>
48 </xsl:variable>
49
50 <td class="auto-generated">
51 <xsl:if test="$table.borders.with.css != 0">
52 <xsl:attribute name="style">
53 <xsl:if test="$colsep &gt; 0">
54 <xsl:call-template name="border">
55 <xsl:with-param name="side" select="'right'"/>
56 </xsl:call-template>
57 </xsl:if>
58 <xsl:if test="$rowsep &gt; 0">
59 <xsl:call-template name="border">
60 <xsl:with-param name="side" select="'bottom'"/>
61 </xsl:call-template>
62 </xsl:if>
63 </xsl:attribute>
64 </xsl:if>
65 <xsl:text>&#160;</xsl:text>
66 </td>
67 </xsl:template>
68
69 <!-- ==================================================================== -->
70
71 <xsl:template name="border">
72 <xsl:param name="side" select="'left'"/>
73 <xsl:param name="padding" select="0"/>
74 <xsl:param name="style" select="$table.cell.border.style"/>
75 <xsl:param name="color" select="$table.cell.border.color"/>
76 <xsl:param name="thickness" select="$table.cell.border.thickness"/>
77
78 <!-- Note: Some browsers (mozilla) require at least a width and style. -->
79
80 <xsl:choose>
81 <xsl:when test="($thickness != '' and $style != '' and $color != '') or ($thickness != '' and $style != '') or ($thickness != '')">
82 <!-- use the compound property if we can: -->
83 <!-- it saves space and probably works more reliably -->
84 <xsl:text>border-</xsl:text>
85 <xsl:value-of select="$side"/>
86 <xsl:text>: </xsl:text>
87 <xsl:value-of select="$thickness"/>
88 <xsl:text> </xsl:text>
89 <xsl:value-of select="$style"/>
90 <xsl:text> </xsl:text>
91 <xsl:value-of select="$color"/>
92 <xsl:text>; </xsl:text>
93 </xsl:when>
94 <xsl:otherwise>
95 <!-- we need to specify the styles individually -->
96 <xsl:if test="$thickness != ''">
97 <xsl:text>border-</xsl:text>
98 <xsl:value-of select="$side"/>
99 <xsl:text>-width: </xsl:text>
100 <xsl:value-of select="$thickness"/>
101 <xsl:text>; </xsl:text>
102 </xsl:if>
103
104 <xsl:if test="$style != ''">
105 <xsl:text>border-</xsl:text>
106 <xsl:value-of select="$side"/>
107 <xsl:text>-style: </xsl:text>
108 <xsl:value-of select="$style"/>
109 <xsl:text>; </xsl:text>
110 </xsl:if>
111
112 <xsl:if test="$color != ''">
113 <xsl:text>border-</xsl:text>
114 <xsl:value-of select="$side"/>
115 <xsl:text>-color: </xsl:text>
116 <xsl:value-of select="$color"/>
117 <xsl:text>; </xsl:text>
118 </xsl:if>
119 </xsl:otherwise>
120 </xsl:choose>
121 </xsl:template>
122
123 <!-- ==================================================================== -->
124
125 <xsl:template match="d:tgroup" name="tgroup">
126 <xsl:if test="not(@cols) or @cols = '' or string(number(@cols)) = 'NaN'">
127 <xsl:message terminate="yes">
128 <xsl:text>Error: CALS tables must specify the number of columns.</xsl:text>
129 </xsl:message>
130 </xsl:if>
131
132 <xsl:variable name="summary">
133 <xsl:call-template name="pi.dbhtml_table-summary"/>
134 </xsl:variable>
135
136 <xsl:variable name="cellspacing">
137 <xsl:call-template name="pi.dbhtml_cellspacing"/>
138 </xsl:variable>
139
140 <xsl:variable name="cellpadding">
141 <xsl:call-template name="pi.dbhtml_cellpadding"/>
142 </xsl:variable>
143
144 <table>
145 <!-- common attributes should come from parent table, not tgroup -->
146 <xsl:apply-templates select=".." mode="common.html.attributes"/>
147
148 <xsl:choose>
149 <!-- If there's a textobject/phrase for the table summary, use it -->
150 <xsl:when test="../d:textobject/d:phrase">
151 <xsl:attribute name="summary">
152 <xsl:value-of select="../d:textobject/d:phrase"/>
153 </xsl:attribute>
154 </xsl:when>
155
156 <!-- If there's a <?dbhtml table-summary="foo"?> PI, use it for
157 the HTML table summary attribute -->
158 <xsl:when test="$summary != ''">
159 <xsl:attribute name="summary">
160 <xsl:value-of select="$summary"/>
161 </xsl:attribute>
162 </xsl:when>
163
164 <!-- Otherwise, if there's a title, use that -->
165 <xsl:when test="../d:title">
166 <xsl:attribute name="summary">
167 <!-- This screws up on inline markup and footnotes, oh well... -->
168 <xsl:value-of select="string(../d:title)"/>
169 </xsl:attribute>
170 </xsl:when>
171
172 <!-- Otherwise, forget the whole idea -->
173 <xsl:otherwise><!-- nevermind --></xsl:otherwise>
174 </xsl:choose>
175
176 <xsl:if test="$cellspacing != '' or $html.cellspacing != ''">
177 <xsl:attribute name="cellspacing">
178 <xsl:choose>
179 <xsl:when test="$cellspacing != ''">
180 <xsl:value-of select="$cellspacing"/>
181 </xsl:when>
182 <xsl:otherwise>
183 <xsl:value-of select="$html.cellspacing"/>
184 </xsl:otherwise>
185 </xsl:choose>
186 </xsl:attribute>
187 </xsl:if>
188
189 <xsl:if test="$cellpadding != '' or $html.cellpadding != ''">
190 <xsl:attribute name="cellpadding">
191 <xsl:choose>
192 <xsl:when test="$cellpadding != ''">
193 <xsl:value-of select="$cellpadding"/>
194 </xsl:when>
195 <xsl:otherwise>
196 <xsl:value-of select="$html.cellpadding"/>
197 </xsl:otherwise>
198 </xsl:choose>
199 </xsl:attribute>
200 </xsl:if>
201
202 <xsl:if test="../@pgwide=1 or local-name(.) = 'entrytbl'">
203 <xsl:attribute name="width">100%</xsl:attribute>
204 </xsl:if>
205
206 <xsl:choose>
207 <xsl:when test="$table.borders.with.css != 0">
208 <xsl:choose>
209 <xsl:when test="../@frame='all' or (not(../@frame) and $default.table.frame='all')">
210 <xsl:attribute name="style">
211 <xsl:text>border-collapse: collapse;</xsl:text>
212 <xsl:call-template name="border">
213 <xsl:with-param name="side" select="'top'"/>
214 <xsl:with-param name="style" select="$table.frame.border.style"/>
215 <xsl:with-param name="color" select="$table.frame.border.color"/>
216 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
217 </xsl:call-template>
218 <xsl:call-template name="border">
219 <xsl:with-param name="side" select="'bottom'"/>
220 <xsl:with-param name="style" select="$table.frame.border.style"/>
221 <xsl:with-param name="color" select="$table.frame.border.color"/>
222 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
223 </xsl:call-template>
224 <xsl:call-template name="border">
225 <xsl:with-param name="side" select="'left'"/>
226 <xsl:with-param name="style" select="$table.frame.border.style"/>
227 <xsl:with-param name="color" select="$table.frame.border.color"/>
228 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
229 </xsl:call-template>
230 <xsl:call-template name="border">
231 <xsl:with-param name="side" select="'right'"/>
232 <xsl:with-param name="style" select="$table.frame.border.style"/>
233 <xsl:with-param name="color" select="$table.frame.border.color"/>
234 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
235 </xsl:call-template>
236 </xsl:attribute>
237 </xsl:when>
238 <xsl:when test="../@frame='topbot' or (not(../@frame) and $default.table.frame='topbot')">
239 <xsl:attribute name="style">
240 <xsl:text>border-collapse: collapse;</xsl:text>
241 <xsl:call-template name="border">
242 <xsl:with-param name="side" select="'top'"/>
243 <xsl:with-param name="style" select="$table.frame.border.style"/>
244 <xsl:with-param name="color" select="$table.frame.border.color"/>
245 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
246 </xsl:call-template>
247 <xsl:call-template name="border">
248 <xsl:with-param name="side" select="'bottom'"/>
249 <xsl:with-param name="style" select="$table.frame.border.style"/>
250 <xsl:with-param name="color" select="$table.frame.border.color"/>
251 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
252 </xsl:call-template>
253 </xsl:attribute>
254 </xsl:when>
255 <xsl:when test="../@frame='top' or (not(../@frame) and $default.table.frame='top')">
256 <xsl:attribute name="style">
257 <xsl:text>border-collapse: collapse;</xsl:text>
258 <xsl:call-template name="border">
259 <xsl:with-param name="side" select="'top'"/>
260 <xsl:with-param name="style" select="$table.frame.border.style"/>
261 <xsl:with-param name="color" select="$table.frame.border.color"/>
262 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
263 </xsl:call-template>
264 </xsl:attribute>
265 </xsl:when>
266 <xsl:when test="../@frame='bottom' or (not(../@frame) and $default.table.frame='bottom')">
267 <xsl:attribute name="style">
268 <xsl:text>border-collapse: collapse;</xsl:text>
269 <xsl:call-template name="border">
270 <xsl:with-param name="side" select="'bottom'"/>
271 <xsl:with-param name="style" select="$table.frame.border.style"/>
272 <xsl:with-param name="color" select="$table.frame.border.color"/>
273 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
274 </xsl:call-template>
275 </xsl:attribute>
276 </xsl:when>
277 <xsl:when test="../@frame='sides' or (not(../@frame) and $default.table.frame='sides')">
278 <xsl:attribute name="style">
279 <xsl:text>border-collapse: collapse;</xsl:text>
280 <xsl:call-template name="border">
281 <xsl:with-param name="side" select="'left'"/>
282 <xsl:with-param name="style" select="$table.frame.border.style"/>
283 <xsl:with-param name="color" select="$table.frame.border.color"/>
284 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
285 </xsl:call-template>
286 <xsl:call-template name="border">
287 <xsl:with-param name="side" select="'right'"/>
288 <xsl:with-param name="style" select="$table.frame.border.style"/>
289 <xsl:with-param name="color" select="$table.frame.border.color"/>
290 <xsl:with-param name="thickness" select="$table.frame.border.thickness"/>
291 </xsl:call-template>
292 </xsl:attribute>
293 </xsl:when>
294 <xsl:when test="../@frame='none'">
295 <xsl:attribute name="style">
296 <xsl:text>border: none;</xsl:text>
297 </xsl:attribute>
298 </xsl:when>
299 <xsl:otherwise>
300 <xsl:attribute name="style">
301 <xsl:text>border-collapse: collapse;</xsl:text>
302 </xsl:attribute>
303 </xsl:otherwise>
304 </xsl:choose>
305
306 </xsl:when>
307 <xsl:when test="../@frame='none' or (not(../@frame) and $default.table.frame='none') or local-name(.) = 'entrytbl'">
308 <xsl:attribute name="border">0</xsl:attribute>
309 </xsl:when>
310 <xsl:otherwise>
311 <xsl:attribute name="border">1</xsl:attribute>
312 </xsl:otherwise>
313 </xsl:choose>
314
315 <xsl:variable name="colgroup">
316 <colgroup>
317 <xsl:call-template name="generate.colgroup">
318 <xsl:with-param name="cols" select="@cols"/>
319 </xsl:call-template>
320 </colgroup>
321 </xsl:variable>
322
323 <xsl:variable name="explicit.table.width">
324 <xsl:call-template name="pi.dbhtml_table-width">
325 <xsl:with-param name="node" select=".."/>
326 </xsl:call-template>
327 </xsl:variable>
328
329 <xsl:variable name="table.width">
330 <xsl:choose>
331 <xsl:when test="$explicit.table.width != ''">
332 <xsl:value-of select="$explicit.table.width"/>
333 </xsl:when>
334 <xsl:when test="$default.table.width = ''">
335 <xsl:text>100%</xsl:text>
336 </xsl:when>
337 <xsl:otherwise>
338 <xsl:value-of select="$default.table.width"/>
339 </xsl:otherwise>
340 </xsl:choose>
341 </xsl:variable>
342
343 <xsl:if test="$default.table.width != '' or $explicit.table.width != ''">
344 <xsl:attribute name="width">
345 <xsl:choose>
346 <xsl:when test="contains($table.width, '%')">
347 <xsl:value-of select="$table.width"/>
348 </xsl:when>
349 <xsl:when test="$use.extensions != 0 and $tablecolumns.extension != 0">
350 <xsl:choose>
351 <xsl:when test="function-available('stbl:convertLength')">
352 <xsl:value-of select="stbl:convertLength($table.width)"/>
353 </xsl:when>
354 <xsl:when test="function-available('xtbl:convertLength')">
355 <xsl:value-of select="xtbl:convertLength($table.width)"/>
356 </xsl:when>
357 <xsl:otherwise>
358 <xsl:message terminate="yes">
359 <xsl:text>No convertLength function available.</xsl:text>
360 </xsl:message>
361 </xsl:otherwise>
362 </xsl:choose>
363 </xsl:when>
364 <xsl:otherwise>
365 <xsl:value-of select="$table.width"/>
366 </xsl:otherwise>
367 </xsl:choose>
368 </xsl:attribute>
369 </xsl:if>
370
371 <xsl:choose>
372 <xsl:when test="$use.extensions != 0 and $tablecolumns.extension != 0">
373 <xsl:choose>
374 <xsl:when test="function-available('stbl:adjustColumnWidths')">
375 <xsl:copy-of select="stbl:adjustColumnWidths($colgroup)"/>
376 </xsl:when>
377 <xsl:when test="function-available('xtbl:adjustColumnWidths')">
378 <xsl:copy-of select="xtbl:adjustColumnWidths($colgroup)"/>
379 </xsl:when>
380 <xsl:when test="function-available('ptbl:adjustColumnWidths')">
381 <xsl:copy-of select="ptbl:adjustColumnWidths($colgroup)"/>
382 </xsl:when>
383 <xsl:otherwise>
384 <xsl:message terminate="yes">
385 <xsl:text>No adjustColumnWidths function available.</xsl:text>
386 </xsl:message>
387 </xsl:otherwise>
388 </xsl:choose>
389 </xsl:when>
390 <xsl:otherwise>
391 <xsl:copy-of select="$colgroup"/>
392 </xsl:otherwise>
393 </xsl:choose>
394
395 <xsl:apply-templates select="d:thead"/>
396 <xsl:apply-templates select="d:tfoot"/>
397 <xsl:apply-templates select="d:tbody"/>
398
399 <xsl:if test=".//d:footnote|../d:title//d:footnote">
400 <tbody class="footnotes">
401 <tr>
402 <td colspan="{@cols}">
403 <xsl:apply-templates select=".//d:footnote|../d:title//d:footnote" mode="table.footnote.mode"/>
404 </td>
405 </tr>
406 </tbody>
407 </xsl:if>
408 </table>
409 </xsl:template>
410
411 <xsl:template match="d:tgroup/processing-instruction('dbhtml')">
412 <xsl:variable name="summary">
413 <xsl:call-template name="pi.dbhtml_table-summary"/>
414 </xsl:variable>
415
416 <!-- Suppress the table-summary PI -->
417 <xsl:if test="$summary = ''">
418 <xsl:processing-instruction name="dbhtml">
419 <xsl:value-of select="."/>
420 </xsl:processing-instruction>
421 </xsl:if>
422 </xsl:template>
423
424 <xsl:template match="d:colspec"/>
425
426 <xsl:template match="d:spanspec"/>
427
428 <xsl:template match="d:thead|d:tfoot">
429 <xsl:element name="{local-name(.)}" namespace="http://www.w3.org/1999/xhtml">
430 <xsl:if test="@align">
431 <xsl:attribute name="align">
432 <xsl:value-of select="@align"/>
433 </xsl:attribute>
434 </xsl:if>
435 <xsl:if test="@char">
436 <xsl:attribute name="char">
437 <xsl:value-of select="@char"/>
438 </xsl:attribute>
439 </xsl:if>
440 <xsl:if test="@charoff">
441 <xsl:attribute name="charoff">
442 <xsl:value-of select="@charoff"/>
443 </xsl:attribute>
444 </xsl:if>
445 <xsl:if test="@valign">
446 <xsl:attribute name="valign">
447 <xsl:value-of select="@valign"/>
448 </xsl:attribute>
449 </xsl:if>
450
451 <xsl:choose>
452 <!-- recurse on rows only if @morerows is present -->
453 <xsl:when test="d:row/d:entry/@morerows|d:row/d:entrytbl/@morerows">
454 <xsl:apply-templates select="d:row[1]">
455 <xsl:with-param name="spans">
456 <xsl:call-template name="blank.spans">
457 <xsl:with-param name="cols" select="../@cols"/>
458 </xsl:call-template>
459 </xsl:with-param>
460 <xsl:with-param name="browserows" select="'recurse'"/>
461 </xsl:apply-templates>
462 </xsl:when>
463 <xsl:otherwise>
464 <xsl:apply-templates select="d:row">
465 <xsl:with-param name="spans">
466 <xsl:call-template name="blank.spans">
467 <xsl:with-param name="cols" select="../@cols"/>
468 </xsl:call-template>
469 </xsl:with-param>
470 <xsl:with-param name="browserows" select="'loop'"/>
471 </xsl:apply-templates>
472 </xsl:otherwise>
473 </xsl:choose>
474
475 </xsl:element>
476 </xsl:template>
477
478 <xsl:template match="d:tbody">
479 <tbody>
480 <xsl:if test="@align">
481 <xsl:attribute name="align">
482 <xsl:value-of select="@align"/>
483 </xsl:attribute>
484 </xsl:if>
485 <xsl:if test="@char">
486 <xsl:attribute name="char">
487 <xsl:value-of select="@char"/>
488 </xsl:attribute>
489 </xsl:if>
490 <xsl:if test="@charoff">
491 <xsl:attribute name="charoff">
492 <xsl:value-of select="@charoff"/>
493 </xsl:attribute>
494 </xsl:if>
495 <xsl:if test="@valign">
496 <xsl:attribute name="valign">
497 <xsl:value-of select="@valign"/>
498 </xsl:attribute>
499 </xsl:if>
500
501 <xsl:choose>
502 <xsl:when test="d:row/d:entry/@morerows|d:row/d:entrytbl/@morerows">
503 <xsl:apply-templates select="d:row[1]">
504 <xsl:with-param name="spans">
505 <xsl:call-template name="blank.spans">
506 <xsl:with-param name="cols" select="../@cols"/>
507 </xsl:call-template>
508 </xsl:with-param>
509 <xsl:with-param name="browserows" select="'recurse'"/>
510 </xsl:apply-templates>
511 </xsl:when>
512 <xsl:otherwise>
513 <xsl:apply-templates select="d:row">
514 <xsl:with-param name="spans">
515 <xsl:call-template name="blank.spans">
516 <xsl:with-param name="cols" select="../@cols"/>
517 </xsl:call-template>
518 </xsl:with-param>
519 <xsl:with-param name="browserows" select="'loop'"/>
520 </xsl:apply-templates>
521 </xsl:otherwise>
522 </xsl:choose>
523
524 </tbody>
525 </xsl:template>
526
527 <xsl:template match="d:row">
528 <xsl:param name="spans"/>
529 <xsl:param name="browserows"/>
530
531 <xsl:choose>
532 <xsl:when test="contains($spans, '0')">
533 <xsl:call-template name="normal-row">
534 <xsl:with-param name="spans" select="$spans"/>
535 <xsl:with-param name="browserows" select="$browserows"/>
536 </xsl:call-template>
537 </xsl:when>
538 <xsl:otherwise>
539 <!--
540 <xsl:message>
541 <xsl:text>Ignoring row: </xsl:text>
542 <xsl:value-of select="$spans"/>
543 <xsl:text> = </xsl:text>
544 <xsl:call-template name="consume-row">
545 <xsl:with-param name="spans" select="$spans"/>
546 </xsl:call-template>
547 </xsl:message>
548 -->
549
550 <xsl:if test="normalize-space(.//text()) != ''">
551 <xsl:message>Warning: overlapped row contains content!</xsl:message>
552 </xsl:if>
553
554 <tr><xsl:comment> This row intentionally left blank </xsl:comment></tr>
555
556 <xsl:if test="$browserows = 'recurse'">
557 <xsl:apply-templates select="following-sibling::d:row[1]">
558 <xsl:with-param name="spans">
559 <xsl:call-template name="consume-row">
560 <xsl:with-param name="spans" select="$spans"/>
561 </xsl:call-template>
562 </xsl:with-param>
563 <xsl:with-param name="browserows" select="$browserows"/>
564 </xsl:apply-templates>
565 </xsl:if>
566 </xsl:otherwise>
567 </xsl:choose>
568 </xsl:template>
569
570 <xsl:template name="normal-row">
571 <xsl:param name="spans"/>
572 <xsl:param name="browserows"/>
573
574 <xsl:variable name="row-height">
575 <xsl:if test="processing-instruction('dbhtml')">
576 <xsl:call-template name="pi.dbhtml_row-height"/>
577 </xsl:if>
578 </xsl:variable>
579
580 <xsl:variable name="bgcolor">
581 <xsl:if test="processing-instruction('dbhtml')">
582 <xsl:call-template name="pi.dbhtml_bgcolor"/>
583 </xsl:if>
584 </xsl:variable>
585
586 <xsl:variable name="class">
587 <xsl:if test="processing-instruction('dbhtml')">
588 <xsl:call-template name="pi.dbhtml_class"/>
589 </xsl:if>
590 </xsl:variable>
591
592 <tr>
593 <xsl:call-template name="id.attribute"/>
594 <xsl:call-template name="tr.attributes">
595 <xsl:with-param name="rownum">
596 <xsl:number from="d:tgroup" count="d:row"/>
597 </xsl:with-param>
598 </xsl:call-template>
599
600 <xsl:if test="$row-height != ''">
601 <xsl:attribute name="height">
602 <xsl:value-of select="$row-height"/>
603 </xsl:attribute>
604 </xsl:if>
605
606 <xsl:if test="$bgcolor != ''">
607 <xsl:attribute name="bgcolor">
608 <xsl:value-of select="$bgcolor"/>
609 </xsl:attribute>
610 </xsl:if>
611
612 <xsl:if test="$class != ''">
613 <xsl:attribute name="class">
614 <xsl:value-of select="$class"/>
615 </xsl:attribute>
616 </xsl:if>
617
618 <xsl:if test="$table.borders.with.css != 0">
619 <xsl:if test="@rowsep = 1 and following-sibling::d: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>
627
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>
648
649 <xsl:apply-templates select="(d:entry|d:entrytbl)[1]">
650 <xsl:with-param name="spans" select="$spans"/>
651 </xsl:apply-templates>
652 </tr>
653
654 <xsl:if test="$browserows = 'recurse'">
655 <xsl:if test="following-sibling::d:row">
656 <xsl:variable name="nextspans">
657 <xsl:apply-templates select="(d:entry|d:entrytbl)[1]" mode="span">
658 <xsl:with-param name="spans" select="$spans"/>
659 </xsl:apply-templates>
660 </xsl:variable>
661
662 <xsl:apply-templates select="following-sibling::d:row[1]">
663 <xsl:with-param name="spans" select="$nextspans"/>
664 <xsl:with-param name="browserows" select="$browserows"/>
665 </xsl:apply-templates>
666 </xsl:if>
667 </xsl:if>
668 </xsl:template>
669
670 <xsl:template match="d:entry|d:entrytbl" name="entry">
671 <xsl:param name="col">
672 <xsl:choose>
673 <xsl:when test="@revisionflag">
674 <xsl:number from="d:row"/>
675 </xsl:when>
676 <xsl:otherwise>1</xsl:otherwise>
677 </xsl:choose>
678 </xsl:param>
679
680 <xsl:param name="spans"/>
681
682 <xsl:variable name="empty.cell" select="count(node()) = 0"/>
683
684 <xsl:variable name="named.colnum">
685 <xsl:call-template name="entry.colnum"/>
686 </xsl:variable>
687
688 <xsl:variable name="entry.colnum">
689 <xsl:choose>
690 <xsl:when test="$named.colnum &gt; 0">
691 <xsl:value-of select="$named.colnum"/>
692 </xsl:when>
693 <xsl:otherwise>
694 <xsl:value-of select="$col"/>
695 </xsl:otherwise>
696 </xsl:choose>
697 </xsl:variable>
698
699 <xsl:variable name="entry.colspan">
700 <xsl:choose>
701 <xsl:when test="@spanname or @namest">
702 <xsl:call-template name="calculate.colspan"/>
703 </xsl:when>
704 <xsl:otherwise>1</xsl:otherwise>
705 </xsl:choose>
706 </xsl:variable>
707
708 <xsl:variable name="following.spans">
709 <xsl:call-template name="calculate.following.spans">
710 <xsl:with-param name="colspan" select="$entry.colspan"/>
711 <xsl:with-param name="spans" select="$spans"/>
712 </xsl:call-template>
713 </xsl:variable>
714
715 <xsl:variable name="cellgi">
716 <xsl:choose>
717 <xsl:when test="ancestor::d:thead">th</xsl:when>
718 <xsl:when test="ancestor::d:tfoot">th</xsl:when>
719 <xsl:when test="ancestor::d:tbody and (ancestor::d:table[@rowheader = 'firstcol'] or ancestor::d:informaltable[@rowheader = 'firstcol']) and $entry.colnum = 1">
720 <xsl:text>th</xsl:text>
721 </xsl:when>
722 <xsl:otherwise>td</xsl:otherwise>
723 </xsl:choose>
724 </xsl:variable>
725
726 <xsl:variable name="rowsep">
727 <xsl:choose>
728 <!-- If this is the last row, rowsep never applies. -->
729 <xsl:when test="ancestor::d:entrytbl and not (ancestor-or-self::d:row[1]/following-sibling::d:row) and not (ancestor::d:thead)">
730 <xsl:value-of select="0"/>
731 </xsl:when>
732 <xsl:when test="not(ancestor-or-self::d:row[1]/following-sibling::d:row or ancestor-or-self::d:thead/following-sibling::d:tbody or ancestor-or-self::d:tbody/preceding-sibling::d:tfoot)">
733 <xsl:value-of select="0"/>
734 </xsl:when>
735 <!-- not last row with @morerows (thead is not last row) -->
736 <xsl:when test="not(ancestor::d:thead) and @morerows and not(@morerows &lt; count(ancestor-or-self::d:row[1]/following-sibling::d:row))">
737 <xsl:value-of select="0"/>
738 </xsl:when>
739 <xsl:otherwise>
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="'rowsep'"/>
744 </xsl:call-template>
745 </xsl:otherwise>
746 </xsl:choose>
747 </xsl:variable>
748
749 <xsl:variable name="colsep">
750 <xsl:choose>
751 <!-- If this is the last column, colsep never applies. -->
752 <xsl:when test="$following.spans = ''">0</xsl:when>
753 <xsl:otherwise>
754 <xsl:call-template name="inherited.table.attribute">
755 <xsl:with-param name="entry" select="."/>
756 <xsl:with-param name="colnum" select="$entry.colnum"/>
757 <xsl:with-param name="attribute" select="'colsep'"/>
758 </xsl:call-template>
759 </xsl:otherwise>
760 </xsl:choose>
761 </xsl:variable>
762
763 <xsl:variable name="valign">
764 <xsl:call-template name="inherited.table.attribute">
765 <xsl:with-param name="entry" select="."/>
766 <xsl:with-param name="colnum" select="$entry.colnum"/>
767 <xsl:with-param name="attribute" select="'valign'"/>
768 </xsl:call-template>
769 </xsl:variable>
770
771 <xsl:variable name="align">
772 <xsl:call-template name="inherited.table.attribute">
773 <xsl:with-param name="entry" select="."/>
774 <xsl:with-param name="colnum" select="$entry.colnum"/>
775 <xsl:with-param name="attribute" select="'align'"/>
776 </xsl:call-template>
777 </xsl:variable>
778
779 <xsl:variable name="char">
780 <xsl:call-template name="inherited.table.attribute">
781 <xsl:with-param name="entry" select="."/>
782 <xsl:with-param name="colnum" select="$entry.colnum"/>
783 <xsl:with-param name="attribute" select="'char'"/>
784 </xsl:call-template>
785 </xsl:variable>
786
787 <xsl:variable name="charoff">
788 <xsl:call-template name="inherited.table.attribute">
789 <xsl:with-param name="entry" select="."/>
790 <xsl:with-param name="colnum" select="$entry.colnum"/>
791 <xsl:with-param name="attribute" select="'charoff'"/>
792 </xsl:call-template>
793 </xsl:variable>
794
795 <xsl:choose>
796 <xsl:when test="$spans != '' and not(starts-with($spans,'0:'))">
797 <xsl:call-template name="entry">
798 <xsl:with-param name="col" select="$col+1"/>
799 <xsl:with-param name="spans" select="substring-after($spans,':')"/>
800 </xsl:call-template>
801 </xsl:when>
802
803 <xsl:when test="number($entry.colnum) &gt; $col">
804 <xsl:call-template name="empty.table.cell"/>
805 <xsl:call-template name="entry">
806 <xsl:with-param name="col" select="$col+1"/>
807 <xsl:with-param name="spans" select="substring-after($spans,':')"/>
808 </xsl:call-template>
809 </xsl:when>
810
811 <xsl:otherwise>
812 <xsl:variable name="bgcolor">
813 <xsl:if test="processing-instruction('dbhtml')">
814 <xsl:call-template name="pi.dbhtml_bgcolor"/>
815 </xsl:if>
816 </xsl:variable>
817
818 <xsl:element name="{$cellgi}" namespace="http://www.w3.org/1999/xhtml">
819 <xsl:call-template name="id.attribute"/>
820 <xsl:if test="$bgcolor != ''">
821 <xsl:attribute name="bgcolor">
822 <xsl:value-of select="$bgcolor"/>
823 </xsl:attribute>
824 </xsl:if>
825
826 <xsl:call-template name="locale.html.attributes"/>
827 <xsl:choose>
828 <xsl:when test="$entry.propagates.style != 0 and @role">
829 <xsl:apply-templates select="." mode="class.attribute">
830 <xsl:with-param name="class" select="@role"/>
831 </xsl:apply-templates>
832 </xsl:when>
833 <xsl:otherwise>
834 <xsl:apply-templates select="." mode="class.attribute">
835 <xsl:with-param name="class" select="''"/>
836 </xsl:apply-templates>
837 </xsl:otherwise>
838 </xsl:choose>
839
840 <xsl:if test="$show.revisionflag and @revisionflag">
841 <xsl:attribute name="class">
842 <xsl:value-of select="@revisionflag"/>
843 </xsl:attribute>
844 </xsl:if>
845
846 <xsl:if test="$table.borders.with.css != 0">
847 <xsl:attribute name="style">
848 <xsl:if test="$colsep &gt; 0">
849 <xsl:call-template name="border">
850 <xsl:with-param name="side" select="'right'"/>
851 </xsl:call-template>
852 </xsl:if>
853 <xsl:if test="$rowsep &gt; 0">
854 <xsl:call-template name="border">
855 <xsl:with-param name="side" select="'bottom'"/>
856 </xsl:call-template>
857 </xsl:if>
858 </xsl:attribute>
859 </xsl:if>
860
861 <xsl:if test="@morerows &gt; 0">
862 <xsl:attribute name="rowspan">
863 <xsl:value-of select="1+@morerows"/>
864 </xsl:attribute>
865 </xsl:if>
866
867 <xsl:if test="$entry.colspan &gt; 1">
868 <xsl:attribute name="colspan">
869 <xsl:value-of select="$entry.colspan"/>
870 </xsl:attribute>
871 </xsl:if>
872
873 <xsl:if test="$align != ''">
874 <xsl:attribute name="align">
875 <xsl:value-of select="$align"/>
876 </xsl:attribute>
877 </xsl:if>
878
879 <xsl:if test="$valign != ''">
880 <xsl:attribute name="valign">
881 <xsl:value-of select="$valign"/>
882 </xsl:attribute>
883 </xsl:if>
884
885 <xsl:if test="$char != ''">
886 <xsl:attribute name="char">
887 <xsl:value-of select="$char"/>
888 </xsl:attribute>
889 </xsl:if>
890
891 <xsl:if test="$charoff != ''">
892 <xsl:attribute name="charoff">
893 <xsl:value-of select="$charoff"/>
894 </xsl:attribute>
895 </xsl:if>
896
897 <xsl:if test="not(preceding-sibling::*) and (ancestor::d:row[1]/@id or ancestor::d:row[1]/@xml:id)">
898 <xsl:call-template name="anchor">
899 <xsl:with-param name="node" select="ancestor::d:row[1]"/>
900 </xsl:call-template>
901 </xsl:if>
902
903 <xsl:call-template name="anchor"/>
904
905 <xsl:choose>
906 <xsl:when test="$empty.cell">
907 <xsl:text>&#160;</xsl:text>
908 </xsl:when>
909 <xsl:when test="self::d:entrytbl">
910 <xsl:call-template name="tgroup"/>
911 </xsl:when>
912 <xsl:otherwise>
913 <xsl:apply-templates/>
914 </xsl:otherwise>
915 </xsl:choose>
916 </xsl:element>
917
918 <xsl:choose>
919 <xsl:when test="following-sibling::d:entry|following-sibling::d:entrytbl">
920 <xsl:apply-templates select="(following-sibling::d:entry |following-sibling::d:entrytbl)[1]">
921 <xsl:with-param name="col" select="$col+$entry.colspan"/>
922 <xsl:with-param name="spans" select="$following.spans"/>
923 </xsl:apply-templates>
924 </xsl:when>
925 <xsl:otherwise>
926 <xsl:call-template name="finaltd">
927 <xsl:with-param name="spans" select="$following.spans"/>
928 <xsl:with-param name="col" select="$col+$entry.colspan"/>
929 </xsl:call-template>
930 </xsl:otherwise>
931 </xsl:choose>
932 </xsl:otherwise>
933 </xsl:choose>
934 </xsl:template>
935
936 <xsl:template match="d:entry|d:entrytbl" name="sentry" mode="span">
937 <xsl:param name="col" select="1"/>
938 <xsl:param name="spans"/>
939
940 <xsl:variable name="entry.colnum">
941 <xsl:call-template name="entry.colnum"/>
942 </xsl:variable>
943
944 <xsl:variable name="entry.colspan">
945 <xsl:choose>
946 <xsl:when test="@spanname or @namest">
947 <xsl:call-template name="calculate.colspan"/>
948 </xsl:when>
949 <xsl:otherwise>1</xsl:otherwise>
950 </xsl:choose>
951 </xsl:variable>
952
953 <xsl:variable name="following.spans">
954 <xsl:call-template name="calculate.following.spans">
955 <xsl:with-param name="colspan" select="$entry.colspan"/>
956 <xsl:with-param name="spans" select="$spans"/>
957 </xsl:call-template>
958 </xsl:variable>
959
960 <xsl:choose>
961 <xsl:when test="$spans != '' and not(starts-with($spans,'0:'))">
962 <xsl:value-of select="substring-before($spans,':')-1"/>
963 <xsl:text>:</xsl:text>
964 <xsl:call-template name="sentry">
965 <xsl:with-param name="col" select="$col+1"/>
966 <xsl:with-param name="spans" select="substring-after($spans,':')"/>
967 </xsl:call-template>
968 </xsl:when>
969
970 <xsl:when test="number($entry.colnum) &gt; $col">
971 <xsl:text>0:</xsl:text>
972 <xsl:call-template name="sentry">
973 <xsl:with-param name="col" select="$col + 1"/>
974 <xsl:with-param name="spans" select="substring-after($spans,':')"/>
975 </xsl:call-template>
976 </xsl:when>
977
978 <xsl:otherwise>
979 <xsl:call-template name="copy-string">
980 <xsl:with-param name="count" select="$entry.colspan"/>
981 <xsl:with-param name="string">
982 <xsl:choose>
983 <xsl:when test="@morerows">
984 <xsl:value-of select="@morerows"/>
985 </xsl:when>
986 <xsl:otherwise>0</xsl:otherwise>
987 </xsl:choose>
988 <xsl:text>:</xsl:text>
989 </xsl:with-param>
990 </xsl:call-template>
991
992 <xsl:choose>
993 <xsl:when test="following-sibling::d:entry|following-sibling::d:entrytbl">
994 <xsl:apply-templates select="(following-sibling::d:entry |following-sibling::d:entrytbl)[1]" mode="span">
995 <xsl:with-param name="col" select="$col+$entry.colspan"/>
996 <xsl:with-param name="spans" select="$following.spans"/>
997 </xsl:apply-templates>
998 </xsl:when>
999 <xsl:otherwise>
1000 <xsl:call-template name="sfinaltd">
1001 <xsl:with-param name="spans" select="$following.spans"/>
1002 </xsl:call-template>
1003 </xsl:otherwise>
1004 </xsl:choose>
1005 </xsl:otherwise>
1006 </xsl:choose>
1007 </xsl:template>
1008
1009 <xsl:template name="generate.colgroup">
1010 <xsl:param name="cols" select="1"/>
1011 <xsl:param name="count" select="1"/>
1012 <xsl:choose>
1013 <xsl:when test="$count &gt; $cols"/>
1014 <xsl:otherwise>
1015 <xsl:call-template name="generate.col">
1016 <xsl:with-param name="countcol" select="$count"/>
1017 </xsl:call-template>
1018 <xsl:call-template name="generate.colgroup">
1019 <xsl:with-param name="cols" select="$cols"/>
1020 <xsl:with-param name="count" select="$count+1"/>
1021 </xsl:call-template>
1022 </xsl:otherwise>
1023 </xsl:choose>
1024 </xsl:template>
1025
1026 <xsl:template name="generate.col">
1027 <xsl:param name="countcol">1</xsl:param>
1028 <xsl:param name="colspecs" select="./d:colspec"/>
1029 <xsl:param name="count">1</xsl:param>
1030 <xsl:param name="colnum">1</xsl:param>
1031
1032 <xsl:choose>
1033 <xsl:when test="$count&gt;count($colspecs)">
1034 <col/>
1035 </xsl:when>
1036 <xsl:otherwise>
1037 <xsl:variable name="colspec" select="$colspecs[$count=position()]"/>
1038 <xsl:variable name="colspec.colnum">
1039 <xsl:choose>
1040 <xsl:when test="$colspec/@colnum">
1041 <xsl:value-of select="$colspec/@colnum"/>
1042 </xsl:when>
1043 <xsl:otherwise>
1044 <xsl:value-of select="$colnum"/>
1045 </xsl:otherwise>
1046 </xsl:choose>
1047 </xsl:variable>
1048
1049 <xsl:choose>
1050 <xsl:when test="$colspec.colnum=$countcol">
1051 <col>
1052 <xsl:choose>
1053 <xsl:when test="$colspec/@colwidth and $use.extensions != 0 and $tablecolumns.extension != 0">
1054 <xsl:attribute name="width">
1055 <xsl:choose>
1056 <xsl:when test="normalize-space($colspec/@colwidth) = '*'">
1057 <xsl:value-of select="'1*'"/>
1058 </xsl:when>
1059 <xsl:otherwise>
1060 <xsl:value-of select="$colspec/@colwidth"/>
1061 </xsl:otherwise>
1062 </xsl:choose>
1063 </xsl:attribute>
1064 </xsl:when>
1065 <!-- pass through to HTML if no * in colspecs -->
1066 <xsl:when test="$colspec/@colwidth and not($colspec/parent::*/d:colspec/@colwidth[contains(.,'*')])">
1067 <xsl:attribute name="width">
1068 <xsl:choose>
1069 <xsl:when test="normalize-space($colspec/@colwidth) = '*'">
1070 <xsl:value-of select="'1*'"/>
1071 </xsl:when>
1072 <xsl:otherwise>
1073 <xsl:value-of select="$colspec/@colwidth"/>
1074 </xsl:otherwise>
1075 </xsl:choose>
1076 </xsl:attribute>
1077 </xsl:when>
1078 </xsl:choose>
1079
1080 <xsl:choose>
1081 <xsl:when test="$colspec/@align">
1082 <xsl:attribute name="align">
1083 <xsl:value-of select="$colspec/@align"/>
1084 </xsl:attribute>
1085 </xsl:when>
1086 <!-- Suggested by Pavel ZAMPACH <[email protected]> -->
1087 <xsl:when test="$colspecs/ancestor::d:tgroup/@align">
1088 <xsl:attribute name="align">
1089 <xsl:value-of select="$colspecs/ancestor::d:tgroup/@align"/>
1090 </xsl:attribute>
1091 </xsl:when>
1092 </xsl:choose>
1093
1094 <xsl:if test="$colspec/@char">
1095 <xsl:attribute name="char">
1096 <xsl:value-of select="$colspec/@char"/>
1097 </xsl:attribute>
1098 </xsl:if>
1099
1100 <xsl:if test="$colspec/@charoff">
1101 <xsl:attribute name="charoff">
1102 <xsl:value-of select="$colspec/@charoff"/>
1103 </xsl:attribute>
1104 </xsl:if>
1105
1106 <xsl:if test="$colspec/@colname">
1107 <xsl:attribute name="class">
1108 <xsl:value-of select="$colspec/@colname"/>
1109 </xsl:attribute>
1110 </xsl:if>
1111 </col>
1112 </xsl:when>
1113 <xsl:otherwise>
1114 <xsl:call-template name="generate.col">
1115 <xsl:with-param name="countcol" select="$countcol"/>
1116 <xsl:with-param name="colspecs" select="$colspecs"/>
1117 <xsl:with-param name="count" select="$count+1"/>
1118 <xsl:with-param name="colnum">
1119 <xsl:choose>
1120 <xsl:when test="$colspec/@colnum">
1121 <xsl:value-of select="$colspec/@colnum + 1"/>
1122 </xsl:when>
1123 <xsl:otherwise>
1124 <xsl:value-of select="$colnum + 1"/>
1125 </xsl:otherwise>
1126 </xsl:choose>
1127 </xsl:with-param>
1128 </xsl:call-template>
1129 </xsl:otherwise>
1130 </xsl:choose>
1131 </xsl:otherwise>
1132 </xsl:choose>
1133 </xsl:template>
1134
1135 <xsl:template name="colspec.colwidth">
1136 <!-- when this macro is called, the current context must be an entry -->
1137 <xsl:param name="colname"/>
1138 <!-- .. = row, ../.. = thead|tbody, ../../.. = tgroup -->
1139 <xsl:param name="colspecs" select="../../../../d:tgroup/d:colspec"/>
1140 <xsl:param name="count">1</xsl:param>
1141 <xsl:choose>
1142 <xsl:when test="$count&gt;count($colspecs)"/>
1143 <xsl:otherwise>
1144 <xsl:variable name="colspec" select="$colspecs[$count=position()]"/>
1145 <xsl:choose>
1146 <xsl:when test="$colspec/@colname=$colname">
1147 <xsl:value-of select="$colspec/@colwidth"/>
1148 </xsl:when>
1149 <xsl:otherwise>
1150 <xsl:call-template name="colspec.colwidth">
1151 <xsl:with-param name="colname" select="$colname"/>
1152 <xsl:with-param name="colspecs" select="$colspecs"/>
1153 <xsl:with-param name="count" select="$count+1"/>
1154 </xsl:call-template>
1155 </xsl:otherwise>
1156 </xsl:choose>
1157 </xsl:otherwise>
1158 </xsl:choose>
1159 </xsl:template>
1160
1161 <!-- ====================================================================== -->
1162
1163 <xsl:template name="tr.attributes">
1164 <xsl:param name="row" select="."/>
1165 <xsl:param name="rownum" select="0"/>
1166
1167 <!-- by default, do nothing. But you might want to say:
1168
1169 <xsl:if test="$rownum mod 2 = 0">
1170 <xsl:attribute name="class">oddrow</xsl:attribute>
1171 </xsl:if>
1172
1173 -->
1174 </xsl:template>
1175
1176 </xsl:stylesheet>