source: clfs-embedded/BOOK/stylesheets/lfs-xsl/docbook-xsl-snapshot/xhtml/table.xsl@ c2f4c89

Last change on this file since c2f4c89 was 9882b55, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Added the new lfs-xsl stylesheets.

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