source: BOOK/stylesheets/lfs-xsl/docbook-xsl-snapshot/xhtml/table.xsl@ aa020293

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since aa020293 was f8c4e94, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Added LFS XSL Stylesheets.

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