source: trunk/Distribution/XSL/html/table.xsl@ 2

Last change on this file since 2 was 2, checked in by jkacer, 18 years ago

Added all DocBook Framework stuff:

  • DocBook DTD
  • Transformation software FOP 0.20.5 and Saxon 6
  • XSL styles
  • Rexx scripts

Also added some WarpIN-related stuff for creation of WarpIN installation packages.
This state corresponds to version 1.0.0 from November 2005, just slightly modified to carry versioning information (Rexx scripts).

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