source: clfs-embedded/BOOK/stylesheets/lfs-xsl/docbook-xsl-snapshot/fo/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: 54.1 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:fo="http://www.w3.org/1999/XSL/Format"
5 xmlns:rx="http://www.renderx.com/XSL/Extensions"
6 xmlns:stbl="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.Table"
7 xmlns:xtbl="com.nwalsh.xalan.Table"
8 xmlns:lxslt="http://xml.apache.org/xslt"
9 xmlns:ptbl="http://nwalsh.com/xslt/ext/xsltproc/python/Table"
10 exclude-result-prefixes="doc stbl xtbl lxslt ptbl"
11 version='1.0'>
12
13<xsl:include href="../common/table.xsl"/>
14
15<!-- ********************************************************************
16 $Id$
17 ********************************************************************
18
19 This file is part of the XSL DocBook Stylesheet distribution.
20 See ../README or http://docbook.sf.net/release/xsl/current/ for
21 copyright and other information.
22
23 ******************************************************************** -->
24
25<doc:reference xmlns="">
26<referenceinfo>
27<releaseinfo role="meta">
28$Id$
29</releaseinfo>
30<author><surname>Walsh</surname>
31<firstname>Norman</firstname></author>
32<copyright><year>1999</year><year>2000</year>
33<holder>Norman Walsh</holder>
34</copyright>
35</referenceinfo>
36<title>Formatting Object Table Reference</title>
37
38<partintro id="partintro">
39<title>Introduction</title>
40
41<para>This is technical reference documentation for the FO
42table-processing templates in the DocBook XSL Stylesheets.</para>
43
44<para>This is not intended to be <quote>user</quote> documentation.
45It is provided for developers writing customization layers for the
46stylesheets, and for anyone who's interested in <quote>how it
47works</quote>.</para>
48
49</partintro>
50</doc:reference>
51
52<!-- ==================================================================== -->
53
54<lxslt:component prefix="xtbl"
55 functions="adjustColumnWidths"/>
56
57<!-- ==================================================================== -->
58
59<xsl:template name="make.table.content">
60 <xsl:choose>
61 <xsl:when test="tgroup|mediaobject|graphic">
62 <xsl:call-template name="calsTable"/>
63 </xsl:when>
64 <xsl:otherwise>
65 <xsl:apply-templates select="." mode="htmlTable"/>
66 </xsl:otherwise>
67 </xsl:choose>
68</xsl:template>
69
70<!-- ==================================================================== -->
71
72<xsl:template name="calsTable">
73
74 <xsl:variable name="keep.together">
75 <xsl:call-template name="pi.dbfo_keep-together"/>
76 </xsl:variable>
77
78 <xsl:for-each select="tgroup">
79
80 <fo:table xsl:use-attribute-sets="table.table.properties">
81 <xsl:if test="$keep.together != ''">
82 <xsl:attribute name="keep-together.within-column">
83 <xsl:value-of select="$keep.together"/>
84 </xsl:attribute>
85 </xsl:if>
86 <xsl:call-template name="table.frame"/>
87 <xsl:if test="following-sibling::tgroup">
88 <xsl:attribute name="border-bottom-width">0pt</xsl:attribute>
89 <xsl:attribute name="border-bottom-style">none</xsl:attribute>
90 <xsl:attribute name="padding-bottom">0pt</xsl:attribute>
91 <xsl:attribute name="margin-bottom">0pt</xsl:attribute>
92 <xsl:attribute name="space-after">0pt</xsl:attribute>
93 <xsl:attribute name="space-after.minimum">0pt</xsl:attribute>
94 <xsl:attribute name="space-after.optimum">0pt</xsl:attribute>
95 <xsl:attribute name="space-after.maximum">0pt</xsl:attribute>
96 </xsl:if>
97 <xsl:if test="preceding-sibling::tgroup">
98 <xsl:attribute name="border-top-width">0pt</xsl:attribute>
99 <xsl:attribute name="border-top-style">none</xsl:attribute>
100 <xsl:attribute name="padding-top">0pt</xsl:attribute>
101 <xsl:attribute name="margin-top">0pt</xsl:attribute>
102 <xsl:attribute name="space-before">0pt</xsl:attribute>
103 <xsl:attribute name="space-before.minimum">0pt</xsl:attribute>
104 <xsl:attribute name="space-before.optimum">0pt</xsl:attribute>
105 <xsl:attribute name="space-before.maximum">0pt</xsl:attribute>
106 </xsl:if>
107 <xsl:apply-templates select="."/>
108 </fo:table>
109 </xsl:for-each>
110</xsl:template>
111
112<!-- ==================================================================== -->
113
114<!-- Placeholder template enables wrapping a fo:table in
115 another table for purposes of layout or applying
116 extensions such as XEP table-omit-initial-header to
117 create "continued" titles on page breaks. -->
118<xsl:template name="table.layout">
119 <xsl:param name="table.content" select="NOTANODE"/>
120
121 <xsl:copy-of select="$table.content"/>
122</xsl:template>
123
124<xsl:template name="table.block">
125 <xsl:param name="table.layout" select="NOTANODE"/>
126
127 <xsl:variable name="id">
128 <xsl:call-template name="object.id"/>
129 </xsl:variable>
130
131 <xsl:variable name="param.placement"
132 select="substring-after(normalize-space(
133 $formal.title.placement), concat(local-name(.), ' '))"/>
134
135 <xsl:variable name="placement">
136 <xsl:choose>
137 <xsl:when test="contains($param.placement, ' ')">
138 <xsl:value-of select="substring-before($param.placement, ' ')"/>
139 </xsl:when>
140 <xsl:when test="$param.placement = ''">before</xsl:when>
141 <xsl:otherwise>
142 <xsl:value-of select="$param.placement"/>
143 </xsl:otherwise>
144 </xsl:choose>
145 </xsl:variable>
146
147 <xsl:choose>
148 <xsl:when test="self::table">
149 <fo:block id="{$id}"
150 xsl:use-attribute-sets="table.properties">
151 <xsl:if test="$placement = 'before'">
152 <xsl:call-template name="formal.object.heading">
153 <xsl:with-param name="placement" select="$placement"/>
154 </xsl:call-template>
155 </xsl:if>
156 <xsl:copy-of select="$table.layout"/>
157 <xsl:call-template name="table.footnote.block"/>
158 <xsl:if test="$placement != 'before'">
159 <xsl:call-template name="formal.object.heading">
160 <xsl:with-param name="placement" select="$placement"/>
161 </xsl:call-template>
162 </xsl:if>
163 </fo:block>
164 </xsl:when>
165 <xsl:otherwise>
166 <fo:block id="{$id}"
167 xsl:use-attribute-sets="informaltable.properties">
168 <xsl:copy-of select="$table.layout"/>
169 <xsl:call-template name="table.footnote.block"/>
170 </fo:block>
171 </xsl:otherwise>
172 </xsl:choose>
173
174
175</xsl:template>
176
177<!-- Output a table's footnotes in a block -->
178<xsl:template name="table.footnote.block">
179 <xsl:if test=".//footnote">
180 <fo:block keep-with-previous.within-column="always">
181 <xsl:apply-templates select=".//footnote" mode="table.footnote.mode"/>
182 </fo:block>
183 </xsl:if>
184</xsl:template>
185
186<!-- ==================================================================== -->
187
188<xsl:template name="table.container">
189 <xsl:param name="table.block"/>
190 <xsl:choose>
191 <xsl:when test="@orient='land' and
192 $fop.extensions = 0 and
193 $passivetex.extensions = 0" >
194 <fo:block-container reference-orientation="90"
195 padding="6pt"
196 xsl:use-attribute-sets="list.block.spacing">
197 <xsl:attribute name="width">
198 <xsl:call-template name="table.width"/>
199 </xsl:attribute>
200 <fo:block start-indent="0pt" end-indent="0pt">
201 <xsl:copy-of select="$table.block"/>
202 </fo:block>
203 </fo:block-container>
204 </xsl:when>
205 <xsl:when test="@pgwide = 1">
206 <fo:block xsl:use-attribute-sets="pgwide.properties">
207 <xsl:copy-of select="$table.block"/>
208 </fo:block>
209 </xsl:when>
210 <xsl:otherwise>
211 <xsl:copy-of select="$table.block"/>
212 </xsl:otherwise>
213 </xsl:choose>
214</xsl:template>
215
216<!-- ==================================================================== -->
217
218<xsl:template name="empty.table.cell">
219 <xsl:param name="colnum" select="0"/>
220
221 <xsl:variable name="rowsep">
222 <xsl:choose>
223 <!-- If this is the last row, rowsep never applies. -->
224 <xsl:when test="not(ancestor-or-self::row[1]/following-sibling::row
225 or ancestor-or-self::thead/following-sibling::tbody
226 or ancestor-or-self::tbody/preceding-sibling::tfoot)">
227 <xsl:value-of select="0"/>
228 </xsl:when>
229 <xsl:otherwise>
230 <xsl:call-template name="inherited.table.attribute">
231 <xsl:with-param name="entry" select="NOT-AN-ELEMENT-NAME"/>
232 <xsl:with-param name="row" select="ancestor-or-self::row[1]"/>
233 <xsl:with-param name="colnum" select="$colnum"/>
234 <xsl:with-param name="attribute" select="'rowsep'"/>
235 </xsl:call-template>
236 </xsl:otherwise>
237 </xsl:choose>
238 </xsl:variable>
239
240 <xsl:variable name="colsep">
241 <xsl:choose>
242 <!-- If this is the last column, colsep never applies. -->
243 <xsl:when test="number($colnum) &gt;= ancestor::tgroup/@cols">0</xsl:when>
244 <xsl:otherwise>
245 <xsl:call-template name="inherited.table.attribute">
246 <xsl:with-param name="entry" select="NOT-AN-ELEMENT-NAME"/>
247 <xsl:with-param name="row" select="ancestor-or-self::row[1]"/>
248 <xsl:with-param name="colnum" select="$colnum"/>
249 <xsl:with-param name="attribute" select="'colsep'"/>
250 </xsl:call-template>
251 </xsl:otherwise>
252 </xsl:choose>
253 </xsl:variable>
254
255 <fo:table-cell text-align="center"
256 display-align="center"
257 xsl:use-attribute-sets="table.cell.padding">
258 <xsl:if test="$xep.extensions != 0">
259 <!-- Suggested by RenderX to workaround a bug in their implementation -->
260 <xsl:attribute name="keep-together.within-column">always</xsl:attribute>
261 </xsl:if>
262 <xsl:if test="$rowsep &gt; 0">
263 <xsl:call-template name="border">
264 <xsl:with-param name="side" select="'bottom'"/>
265 </xsl:call-template>
266 </xsl:if>
267
268 <xsl:if test="$colsep &gt; 0 and number($colnum) &lt; ancestor::tgroup/@cols">
269 <xsl:call-template name="border">
270 <xsl:with-param name="side" select="'right'"/>
271 </xsl:call-template>
272 </xsl:if>
273
274 <!-- fo:table-cell should not be empty -->
275 <fo:block/>
276 </fo:table-cell>
277</xsl:template>
278
279<!-- ==================================================================== -->
280<xsl:template name="table.frame">
281 <xsl:variable name="frame">
282 <xsl:choose>
283 <xsl:when test="../@frame">
284 <xsl:value-of select="../@frame"/>
285 </xsl:when>
286 <xsl:when test="$default.table.frame != ''">
287 <xsl:value-of select="$default.table.frame"/>
288 </xsl:when>
289 <xsl:otherwise>all</xsl:otherwise>
290 </xsl:choose>
291 </xsl:variable>
292
293 <xsl:choose>
294 <xsl:when test="$frame='all'">
295 <xsl:attribute name="border-left-style">
296 <xsl:value-of select="$table.frame.border.style"/>
297 </xsl:attribute>
298 <xsl:attribute name="border-right-style">
299 <xsl:value-of select="$table.frame.border.style"/>
300 </xsl:attribute>
301 <xsl:attribute name="border-top-style">
302 <xsl:value-of select="$table.frame.border.style"/>
303 </xsl:attribute>
304 <xsl:attribute name="border-bottom-style">
305 <xsl:value-of select="$table.frame.border.style"/>
306 </xsl:attribute>
307 <xsl:attribute name="border-left-width">
308 <xsl:value-of select="$table.frame.border.thickness"/>
309 </xsl:attribute>
310 <xsl:attribute name="border-right-width">
311 <xsl:value-of select="$table.frame.border.thickness"/>
312 </xsl:attribute>
313 <xsl:attribute name="border-top-width">
314 <xsl:value-of select="$table.frame.border.thickness"/>
315 </xsl:attribute>
316 <xsl:attribute name="border-bottom-width">
317 <xsl:value-of select="$table.frame.border.thickness"/>
318 </xsl:attribute>
319 <xsl:attribute name="border-left-color">
320 <xsl:value-of select="$table.frame.border.color"/>
321 </xsl:attribute>
322 <xsl:attribute name="border-right-color">
323 <xsl:value-of select="$table.frame.border.color"/>
324 </xsl:attribute>
325 <xsl:attribute name="border-top-color">
326 <xsl:value-of select="$table.frame.border.color"/>
327 </xsl:attribute>
328 <xsl:attribute name="border-bottom-color">
329 <xsl:value-of select="$table.frame.border.color"/>
330 </xsl:attribute>
331 </xsl:when>
332 <xsl:when test="$frame='bottom'">
333 <xsl:attribute name="border-left-style">none</xsl:attribute>
334 <xsl:attribute name="border-right-style">none</xsl:attribute>
335 <xsl:attribute name="border-top-style">none</xsl:attribute>
336 <xsl:attribute name="border-bottom-style">
337 <xsl:value-of select="$table.frame.border.style"/>
338 </xsl:attribute>
339 <xsl:attribute name="border-bottom-width">
340 <xsl:value-of select="$table.frame.border.thickness"/>
341 </xsl:attribute>
342 <xsl:attribute name="border-bottom-color">
343 <xsl:value-of select="$table.frame.border.color"/>
344 </xsl:attribute>
345 </xsl:when>
346 <xsl:when test="$frame='sides'">
347 <xsl:attribute name="border-left-style">
348 <xsl:value-of select="$table.frame.border.style"/>
349 </xsl:attribute>
350 <xsl:attribute name="border-right-style">
351 <xsl:value-of select="$table.frame.border.style"/>
352 </xsl:attribute>
353 <xsl:attribute name="border-top-style">none</xsl:attribute>
354 <xsl:attribute name="border-bottom-style">none</xsl:attribute>
355 <xsl:attribute name="border-left-width">
356 <xsl:value-of select="$table.frame.border.thickness"/>
357 </xsl:attribute>
358 <xsl:attribute name="border-right-width">
359 <xsl:value-of select="$table.frame.border.thickness"/>
360 </xsl:attribute>
361 <xsl:attribute name="border-left-color">
362 <xsl:value-of select="$table.frame.border.color"/>
363 </xsl:attribute>
364 <xsl:attribute name="border-right-color">
365 <xsl:value-of select="$table.frame.border.color"/>
366 </xsl:attribute>
367 </xsl:when>
368 <xsl:when test="$frame='top'">
369 <xsl:attribute name="border-left-style">none</xsl:attribute>
370 <xsl:attribute name="border-right-style">none</xsl:attribute>
371 <xsl:attribute name="border-top-style">
372 <xsl:value-of select="$table.frame.border.style"/>
373 </xsl:attribute>
374 <xsl:attribute name="border-bottom-style">none</xsl:attribute>
375 <xsl:attribute name="border-top-width">
376 <xsl:value-of select="$table.frame.border.thickness"/>
377 </xsl:attribute>
378 <xsl:attribute name="border-top-color">
379 <xsl:value-of select="$table.frame.border.color"/>
380 </xsl:attribute>
381 </xsl:when>
382 <xsl:when test="$frame='topbot'">
383 <xsl:attribute name="border-left-style">none</xsl:attribute>
384 <xsl:attribute name="border-right-style">none</xsl:attribute>
385 <xsl:attribute name="border-top-style">
386 <xsl:value-of select="$table.frame.border.style"/>
387 </xsl:attribute>
388 <xsl:attribute name="border-bottom-style">
389 <xsl:value-of select="$table.frame.border.style"/>
390 </xsl:attribute>
391 <xsl:attribute name="border-top-width">
392 <xsl:value-of select="$table.frame.border.thickness"/>
393 </xsl:attribute>
394 <xsl:attribute name="border-bottom-width">
395 <xsl:value-of select="$table.frame.border.thickness"/>
396 </xsl:attribute>
397 <xsl:attribute name="border-top-color">
398 <xsl:value-of select="$table.frame.border.color"/>
399 </xsl:attribute>
400 <xsl:attribute name="border-bottom-color">
401 <xsl:value-of select="$table.frame.border.color"/>
402 </xsl:attribute>
403 </xsl:when>
404 <xsl:when test="$frame='none'">
405 <xsl:attribute name="border-left-style">none</xsl:attribute>
406 <xsl:attribute name="border-right-style">none</xsl:attribute>
407 <xsl:attribute name="border-top-style">none</xsl:attribute>
408 <xsl:attribute name="border-bottom-style">none</xsl:attribute>
409 </xsl:when>
410 <xsl:otherwise>
411 <xsl:message>
412 <xsl:text>Impossible frame on table: </xsl:text>
413 <xsl:value-of select="$frame"/>
414 </xsl:message>
415 <xsl:attribute name="border-left-style">none</xsl:attribute>
416 <xsl:attribute name="border-right-style">none</xsl:attribute>
417 <xsl:attribute name="border-top-style">none</xsl:attribute>
418 <xsl:attribute name="border-bottom-style">none</xsl:attribute>
419 </xsl:otherwise>
420 </xsl:choose>
421</xsl:template>
422
423<!-- ==================================================================== -->
424
425<xsl:template name="border">
426 <xsl:param name="side" select="'left'"/>
427
428 <xsl:attribute name="border-{$side}-width">
429 <xsl:value-of select="$table.cell.border.thickness"/>
430 </xsl:attribute>
431 <xsl:attribute name="border-{$side}-style">
432 <xsl:value-of select="$table.cell.border.style"/>
433 </xsl:attribute>
434 <xsl:attribute name="border-{$side}-color">
435 <xsl:value-of select="$table.cell.border.color"/>
436 </xsl:attribute>
437</xsl:template>
438
439<!-- ==================================================================== -->
440
441<xsl:template match="tgroup" name="tgroup">
442 <xsl:if test="not(@cols) or @cols = '' or string(number(@cols)) = 'NaN'">
443 <xsl:message terminate="yes">
444 <xsl:text>Error: CALS tables must specify the number of columns.</xsl:text>
445 </xsl:message>
446 </xsl:if>
447
448 <xsl:variable name="table.width">
449 <xsl:call-template name="table.width"/>
450 </xsl:variable>
451
452 <xsl:variable name="colspecs">
453 <xsl:choose>
454 <xsl:when test="$use.extensions != 0
455 and $tablecolumns.extension != 0">
456 <xsl:call-template name="generate.colgroup.raw">
457 <xsl:with-param name="cols" select="@cols"/>
458 </xsl:call-template>
459 </xsl:when>
460 <xsl:otherwise>
461 <xsl:call-template name="generate.colgroup">
462 <xsl:with-param name="cols" select="@cols"/>
463 </xsl:call-template>
464 </xsl:otherwise>
465 </xsl:choose>
466 </xsl:variable>
467
468 <xsl:variable name="prop-columns"
469 select=".//colspec[contains(@colwidth, '*')]"/>
470 <xsl:if test="count($prop-columns) != 0 or
471 $fop.extensions != 0 or
472 $fop1.extensions != 0 or
473 $passivetex.extensions != 0">
474 <xsl:attribute name="table-layout">fixed</xsl:attribute>
475 </xsl:if>
476
477 <xsl:if test="count(preceding-sibling::tgroup) = 0">
478 <!-- If this is the first tgroup, output the width attribute for the -->
479 <!-- surrounding fo:table. (If this isn't the first tgroup, trying -->
480 <!-- to output the attribute will cause an error.) -->
481 <xsl:attribute name="width">
482 <xsl:value-of select="$table.width"/>
483 </xsl:attribute>
484 </xsl:if>
485
486 <xsl:choose>
487 <xsl:when test="$use.extensions != 0
488 and $tablecolumns.extension != 0">
489 <xsl:choose>
490 <xsl:when test="function-available('stbl:adjustColumnWidths')">
491 <xsl:copy-of select="stbl:adjustColumnWidths($colspecs)"/>
492 </xsl:when>
493 <xsl:when test="function-available('xtbl:adjustColumnWidths')">
494 <xsl:copy-of select="xtbl:adjustColumnWidths($colspecs)"/>
495 </xsl:when>
496 <xsl:when test="function-available('ptbl:adjustColumnWidths')">
497 <xsl:copy-of select="ptbl:adjustColumnWidths($colspecs)"/>
498 </xsl:when>
499 <xsl:otherwise>
500 <xsl:message terminate="yes">
501 <xsl:text>No adjustColumnWidths function available.</xsl:text>
502 </xsl:message>
503 </xsl:otherwise>
504 </xsl:choose>
505 </xsl:when>
506 <xsl:otherwise>
507 <xsl:copy-of select="$colspecs"/>
508 </xsl:otherwise>
509 </xsl:choose>
510
511 <xsl:apply-templates select="thead"/>
512 <xsl:apply-templates select="tfoot"/>
513 <xsl:apply-templates select="tbody"/>
514</xsl:template>
515
516<xsl:template match="colspec"></xsl:template>
517
518<xsl:template name="table.width">
519
520 <xsl:variable name="numcols">
521 <xsl:call-template name="widest-html-row">
522 <xsl:with-param name="rows" select=".//tr"/>
523 </xsl:call-template>
524 </xsl:variable>
525
526 <xsl:variable name="explicit.table.width">
527 <xsl:choose>
528 <xsl:when test="self::entrytbl">
529 <xsl:call-template name="pi.dbfo_table-width"/>
530 </xsl:when>
531 <xsl:when test="self::table or self::informaltable">
532 <xsl:call-template name="pi.dbfo_table-width"/>
533 </xsl:when>
534 <xsl:otherwise>
535 <!-- * no dbfo@table-width PI as a child of this table, so check -->
536 <!-- * the parent of this table to see if the table has any -->
537 <!-- * sibling dbfo@table-width PIs (FIXME: 2007-07 MikeSmith: we -->
538 <!-- * should really instead be checking here just to see if the -->
539 <!-- * first preceding sibling of this table is a -->
540 <!-- * dbfo@table-width PI) -->
541 <xsl:call-template name="pi.dbfo_table-width">
542 <xsl:with-param name="node" select=".."/>
543 </xsl:call-template>
544 </xsl:otherwise>
545 </xsl:choose>
546 </xsl:variable>
547
548 <xsl:variable name="column.sum">
549 <xsl:choose>
550 <!-- CALS table -->
551 <xsl:when test="@cols">
552 <xsl:if test="count(colspec) = @cols">
553 <xsl:for-each select="colspec">
554 <xsl:if test="position() != 1">
555 <xsl:text> + </xsl:text>
556 </xsl:if>
557 <xsl:choose>
558 <xsl:when test="not(@colwidth)">NOWIDTH</xsl:when>
559 <xsl:when test="contains(@colwidth, '*')">NOWIDTH</xsl:when>
560 <xsl:otherwise>
561 <xsl:value-of select="@colwidth"/>
562 </xsl:otherwise>
563 </xsl:choose>
564 </xsl:for-each>
565 </xsl:if>
566 </xsl:when>
567 <xsl:otherwise>
568 <!-- HTML table -->
569 <xsl:if test="count(col|colgroup/col) = $numcols">
570 <xsl:for-each select="col|colgroup/col">
571 <xsl:if test="position() != 1">
572 <xsl:text> + </xsl:text>
573 </xsl:if>
574 <xsl:choose>
575 <xsl:when test="not(@width)">NOWIDTH</xsl:when>
576 <xsl:when test="contains(@width, '%')">NOWIDTH</xsl:when>
577 <xsl:otherwise>
578 <xsl:value-of select="@width"/>
579 </xsl:otherwise>
580 </xsl:choose>
581 </xsl:for-each>
582 </xsl:if>
583 </xsl:otherwise>
584 </xsl:choose>
585 </xsl:variable>
586
587 <xsl:variable name="column.sum.width">
588 <xsl:if test="not(contains($column.sum, 'NOWIDTH'))">
589 <xsl:value-of select="$column.sum"/>
590 </xsl:if>
591 </xsl:variable>
592
593 <xsl:variable name="prop-columns"
594 select=".//colspec[contains(@colwidth, '*')]"/>
595
596 <xsl:variable name="table.width">
597 <xsl:choose>
598 <xsl:when test="$explicit.table.width != ''">
599 <xsl:value-of select="$explicit.table.width"/>
600 </xsl:when>
601 <xsl:when test="$column.sum.width != ''">
602 <xsl:value-of select="$column.sum.width"/>
603 </xsl:when>
604 <xsl:when test="$default.table.width = ''">
605 <xsl:choose>
606 <!-- These processors don't support table-layout="auto" -->
607 <xsl:when test="$fop.extensions != 0 or
608 $fop1.extensions != 0 or
609 $passivetex.extensions != 0">
610 <xsl:text>100%</xsl:text>
611 </xsl:when>
612 <!-- Proportional columns imply 100% width -->
613 <xsl:when test="count($prop-columns) != 0">
614 <xsl:text>100%</xsl:text>
615 </xsl:when>
616 <xsl:otherwise>
617 <xsl:text>auto</xsl:text>
618 </xsl:otherwise>
619 </xsl:choose>
620 </xsl:when>
621 <xsl:otherwise>
622 <xsl:value-of select="$default.table.width"/>
623 </xsl:otherwise>
624 </xsl:choose>
625 </xsl:variable>
626 <xsl:value-of select="$table.width"/>
627
628</xsl:template>
629
630<xsl:template match="spanspec"></xsl:template>
631
632<xsl:template match="thead">
633 <xsl:variable name="tgroup" select="parent::*"/>
634
635 <fo:table-header start-indent="0pt" end-indent="0pt">
636 <xsl:apply-templates select="row[1]">
637 <xsl:with-param name="spans">
638 <xsl:call-template name="blank.spans">
639 <xsl:with-param name="cols" select="../@cols"/>
640 </xsl:call-template>
641 </xsl:with-param>
642 </xsl:apply-templates>
643 </fo:table-header>
644</xsl:template>
645
646<xsl:template match="tfoot">
647 <xsl:variable name="tgroup" select="parent::*"/>
648
649 <fo:table-footer start-indent="0pt" end-indent="0pt">
650 <xsl:apply-templates select="row[1]">
651 <xsl:with-param name="spans">
652 <xsl:call-template name="blank.spans">
653 <xsl:with-param name="cols" select="../@cols"/>
654 </xsl:call-template>
655 </xsl:with-param>
656 </xsl:apply-templates>
657
658 </fo:table-footer>
659</xsl:template>
660
661<xsl:template match="tbody">
662 <xsl:variable name="tgroup" select="parent::*"/>
663
664 <fo:table-body start-indent="0pt" end-indent="0pt">
665 <xsl:apply-templates select="row[1]">
666 <xsl:with-param name="spans">
667 <xsl:call-template name="blank.spans">
668 <xsl:with-param name="cols" select="../@cols"/>
669 </xsl:call-template>
670 </xsl:with-param>
671 </xsl:apply-templates>
672 </fo:table-body>
673</xsl:template>
674
675<xsl:template match="row">
676 <xsl:param name="spans"/>
677
678 <xsl:choose>
679 <xsl:when test="contains($spans, '0')">
680 <xsl:call-template name="normal-row">
681 <xsl:with-param name="spans" select="$spans"/>
682 </xsl:call-template>
683 </xsl:when>
684 <xsl:otherwise>
685 <!--
686 <xsl:message>
687 <xsl:text>Ignoring row: </xsl:text>
688 <xsl:value-of select="$spans"/>
689 <xsl:text> = </xsl:text>
690 <xsl:call-template name="consume-row">
691 <xsl:with-param name="spans" select="$spans"/>
692 </xsl:call-template>
693 </xsl:message>
694 -->
695
696 <xsl:if test="normalize-space(.//text()) != ''">
697 <xsl:message>Warning: overlapped row contains content!</xsl:message>
698 </xsl:if>
699
700 <fo:table-row>
701 <xsl:comment> This row intentionally left blank </xsl:comment>
702 <fo:table-cell><fo:block/></fo:table-cell>
703 </fo:table-row>
704
705 <xsl:apply-templates select="following-sibling::row[1]">
706 <xsl:with-param name="spans">
707 <xsl:call-template name="consume-row">
708 <xsl:with-param name="spans" select="$spans"/>
709 </xsl:call-template>
710 </xsl:with-param>
711 </xsl:apply-templates>
712 </xsl:otherwise>
713 </xsl:choose>
714</xsl:template>
715
716<xsl:template name="normal-row">
717 <xsl:param name="spans"/>
718
719 <fo:table-row>
720 <xsl:call-template name="table.row.properties"/>
721 <xsl:call-template name="anchor"/>
722
723 <xsl:apply-templates select="(entry|entrytbl)[1]">
724 <xsl:with-param name="spans" select="$spans"/>
725 </xsl:apply-templates>
726 </fo:table-row>
727
728 <xsl:if test="following-sibling::row">
729 <xsl:variable name="nextspans">
730 <xsl:apply-templates select="(entry|entrytbl)[1]" mode="span">
731 <xsl:with-param name="spans" select="$spans"/>
732 </xsl:apply-templates>
733 </xsl:variable>
734
735 <xsl:apply-templates select="following-sibling::row[1]">
736 <xsl:with-param name="spans" select="$nextspans"/>
737 </xsl:apply-templates>
738 </xsl:if>
739</xsl:template>
740
741<!-- customize this template to add row properties -->
742<xsl:template name="table.row.properties">
743 <xsl:variable name="bgcolor">
744 <xsl:call-template name="pi.dbfo_bgcolor"/>
745 </xsl:variable>
746 <xsl:if test="$bgcolor != ''">
747 <xsl:attribute name="background-color">
748 <xsl:value-of select="$bgcolor"/>
749 </xsl:attribute>
750 </xsl:if>
751
752 <!-- Keep header row with next row -->
753 <xsl:if test="ancestor::thead">
754 <xsl:attribute name="keep-with-next.within-column">always</xsl:attribute>
755 </xsl:if>
756
757</xsl:template>
758
759<xsl:template match="entry|entrytbl" name="entry">
760 <xsl:param name="col" select="1"/>
761 <xsl:param name="spans"/>
762
763 <xsl:variable name="row" select="parent::row"/>
764 <xsl:variable name="group" select="$row/parent::*[1]"/>
765 <xsl:variable name="frame" select="ancestor::tgroup/parent::*/@frame"/>
766
767 <xsl:variable name="empty.cell" select="count(node()) = 0"/>
768
769 <xsl:variable name="named.colnum">
770 <xsl:call-template name="entry.colnum"/>
771 </xsl:variable>
772
773 <xsl:variable name="entry.colnum">
774 <xsl:choose>
775 <xsl:when test="$named.colnum &gt; 0">
776 <xsl:value-of select="$named.colnum"/>
777 </xsl:when>
778 <xsl:otherwise>
779 <xsl:value-of select="$col"/>
780 </xsl:otherwise>
781 </xsl:choose>
782 </xsl:variable>
783
784 <xsl:variable name="entry.colspan">
785 <xsl:choose>
786 <xsl:when test="@spanname or @namest">
787 <xsl:call-template name="calculate.colspan"/>
788 </xsl:when>
789 <xsl:otherwise>1</xsl:otherwise>
790 </xsl:choose>
791 </xsl:variable>
792
793 <xsl:variable name="following.spans">
794 <xsl:call-template name="calculate.following.spans">
795 <xsl:with-param name="colspan" select="$entry.colspan"/>
796 <xsl:with-param name="spans" select="$spans"/>
797 </xsl:call-template>
798 </xsl:variable>
799
800 <xsl:variable name="rowsep">
801 <xsl:choose>
802 <!-- If this is the last row, rowsep never applies. -->
803 <xsl:when test="not(ancestor-or-self::row[1]/following-sibling::row
804 or ancestor-or-self::thead/following-sibling::tbody
805 or ancestor-or-self::tbody/preceding-sibling::tfoot)">
806 <xsl:value-of select="0"/>
807 </xsl:when>
808 <!-- Check for morerows too -->
809 <xsl:when test="(@morerows and count(ancestor-or-self::row[1]/
810 following-sibling::row) = @morerows )
811 and not (ancestor-or-self::thead/following-sibling::tbody
812 or ancestor-or-self::tbody/preceding-sibling::tfoot)">
813 <xsl:value-of select="0"/>
814 </xsl:when>
815 <xsl:otherwise>
816 <xsl:call-template name="inherited.table.attribute">
817 <xsl:with-param name="entry" select="."/>
818 <xsl:with-param name="colnum" select="$entry.colnum"/>
819 <xsl:with-param name="attribute" select="'rowsep'"/>
820 </xsl:call-template>
821 </xsl:otherwise>
822 </xsl:choose>
823 </xsl:variable>
824
825<!--
826 <xsl:message><xsl:value-of select="."/>: <xsl:value-of select="$rowsep"/></xsl:message>
827-->
828
829 <xsl:variable name="colsep">
830 <xsl:choose>
831 <!-- If this is the last column, colsep never applies. -->
832 <xsl:when test="$following.spans = ''">0</xsl:when>
833 <xsl:otherwise>
834 <xsl:call-template name="inherited.table.attribute">
835 <xsl:with-param name="entry" select="."/>
836 <xsl:with-param name="colnum" select="$entry.colnum"/>
837 <xsl:with-param name="attribute" select="'colsep'"/>
838 </xsl:call-template>
839 </xsl:otherwise>
840 </xsl:choose>
841 </xsl:variable>
842
843 <xsl:variable name="valign">
844 <xsl:call-template name="inherited.table.attribute">
845 <xsl:with-param name="entry" select="."/>
846 <xsl:with-param name="colnum" select="$entry.colnum"/>
847 <xsl:with-param name="attribute" select="'valign'"/>
848 </xsl:call-template>
849 </xsl:variable>
850
851 <xsl:variable name="align">
852 <xsl:call-template name="inherited.table.attribute">
853 <xsl:with-param name="entry" select="."/>
854 <xsl:with-param name="colnum" select="$entry.colnum"/>
855 <xsl:with-param name="attribute" select="'align'"/>
856 </xsl:call-template>
857 </xsl:variable>
858
859 <xsl:variable name="char">
860 <xsl:call-template name="inherited.table.attribute">
861 <xsl:with-param name="entry" select="."/>
862 <xsl:with-param name="colnum" select="$entry.colnum"/>
863 <xsl:with-param name="attribute" select="'char'"/>
864 </xsl:call-template>
865 </xsl:variable>
866
867 <xsl:variable name="charoff">
868 <xsl:call-template name="inherited.table.attribute">
869 <xsl:with-param name="entry" select="."/>
870 <xsl:with-param name="colnum" select="$entry.colnum"/>
871 <xsl:with-param name="attribute" select="'charoff'"/>
872 </xsl:call-template>
873 </xsl:variable>
874
875 <xsl:choose>
876 <xsl:when test="$spans != '' and not(starts-with($spans,'0:'))">
877 <xsl:call-template name="entry">
878 <xsl:with-param name="col" select="$col+1"/>
879 <xsl:with-param name="spans" select="substring-after($spans,':')"/>
880 </xsl:call-template>
881 </xsl:when>
882
883 <xsl:when test="number($entry.colnum) &gt; $col">
884 <xsl:call-template name="empty.table.cell">
885 <xsl:with-param name="colnum" select="$col"/>
886 </xsl:call-template>
887 <xsl:call-template name="entry">
888 <xsl:with-param name="col" select="$col+1"/>
889 <xsl:with-param name="spans" select="substring-after($spans,':')"/>
890 </xsl:call-template>
891 </xsl:when>
892
893 <xsl:otherwise>
894 <xsl:variable name="cell.content">
895 <fo:block>
896 <xsl:call-template name="table.cell.block.properties"/>
897
898 <!-- are we missing any indexterms? -->
899 <xsl:if test="not(preceding-sibling::entry)
900 and not(parent::row/preceding-sibling::row)">
901 <!-- this is the first entry of the first row -->
902 <xsl:if test="ancestor::thead or
903 (ancestor::tbody
904 and not(ancestor::tbody/preceding-sibling::thead
905 or ancestor::tbody/preceding-sibling::tbody))">
906 <!-- of the thead or the first tbody -->
907 <xsl:apply-templates select="ancestor::tgroup/preceding-sibling::indexterm"/>
908 </xsl:if>
909 </xsl:if>
910
911 <!--
912 <xsl:text>(</xsl:text>
913 <xsl:value-of select="$rowsep"/>
914 <xsl:text>,</xsl:text>
915 <xsl:value-of select="$colsep"/>
916 <xsl:text>)</xsl:text>
917 -->
918 <xsl:choose>
919 <xsl:when test="$empty.cell">
920 <xsl:text>&#160;</xsl:text>
921 </xsl:when>
922 <xsl:when test="self::entrytbl">
923 <xsl:variable name="prop-columns"
924 select=".//colspec[contains(@colwidth, '*')]"/>
925 <fo:table xsl:use-attribute-sets="table.table.properties">
926 <xsl:if test="count($prop-columns) != 0">
927 <xsl:attribute name="table-layout">fixed</xsl:attribute>
928 </xsl:if>
929 <xsl:call-template name="tgroup"/>
930 </fo:table>
931 </xsl:when>
932 <xsl:otherwise>
933 <xsl:apply-templates/>
934 </xsl:otherwise>
935 </xsl:choose>
936 </fo:block>
937 </xsl:variable>
938
939 <xsl:variable name="cell-orientation">
940 <xsl:call-template name="pi.dbfo_orientation">
941 <xsl:with-param name="node" select="ancestor-or-self::entry"/>
942 </xsl:call-template>
943 </xsl:variable>
944
945 <xsl:variable name="row-orientation">
946 <xsl:call-template name="pi.dbfo_orientation">
947 <xsl:with-param name="node" select="ancestor-or-self::row"/>
948 </xsl:call-template>
949 </xsl:variable>
950
951 <xsl:variable name="cell-width">
952 <xsl:call-template name="pi.dbfo_rotated-width">
953 <xsl:with-param name="node" select="ancestor-or-self::entry"/>
954 </xsl:call-template>
955 </xsl:variable>
956
957 <xsl:variable name="row-width">
958 <xsl:call-template name="pi.dbfo_rotated-width">
959 <xsl:with-param name="node" select="ancestor-or-self::row"/>
960 </xsl:call-template>
961 </xsl:variable>
962
963 <xsl:variable name="orientation">
964 <xsl:choose>
965 <xsl:when test="$cell-orientation != ''">
966 <xsl:value-of select="$cell-orientation"/>
967 </xsl:when>
968 <xsl:otherwise>
969 <xsl:value-of select="$row-orientation"/>
970 </xsl:otherwise>
971 </xsl:choose>
972 </xsl:variable>
973
974 <xsl:variable name="rotated-width">
975 <xsl:choose>
976 <xsl:when test="$cell-width != ''">
977 <xsl:value-of select="$cell-width"/>
978 </xsl:when>
979 <xsl:otherwise>
980 <xsl:value-of select="$row-width"/>
981 </xsl:otherwise>
982 </xsl:choose>
983 </xsl:variable>
984
985 <xsl:variable name="bgcolor">
986 <xsl:call-template name="pi.dbfo_bgcolor">
987 <xsl:with-param name="node" select="ancestor-or-self::entry"/>
988 </xsl:call-template>
989 </xsl:variable>
990
991 <fo:table-cell xsl:use-attribute-sets="table.cell.padding">
992 <xsl:call-template name="table.cell.properties">
993 <xsl:with-param name="bgcolor.pi" select="$bgcolor"/>
994 <xsl:with-param name="rowsep.inherit" select="$rowsep"/>
995 <xsl:with-param name="colsep.inherit" select="$colsep"/>
996 <xsl:with-param name="col" select="$col"/>
997 <xsl:with-param name="valign.inherit" select="$valign"/>
998 <xsl:with-param name="align.inherit" select="$align"/>
999 <xsl:with-param name="char.inherit" select="$char"/>
1000 </xsl:call-template>
1001
1002 <xsl:call-template name="anchor"/>
1003
1004 <xsl:if test="@morerows">
1005 <xsl:attribute name="number-rows-spanned">
1006 <xsl:value-of select="@morerows+1"/>
1007 </xsl:attribute>
1008 </xsl:if>
1009
1010 <xsl:if test="$entry.colspan &gt; 1">
1011 <xsl:attribute name="number-columns-spanned">
1012 <xsl:value-of select="$entry.colspan"/>
1013 </xsl:attribute>
1014 </xsl:if>
1015
1016<!--
1017 <xsl:if test="@charoff">
1018 <xsl:attribute name="charoff">
1019 <xsl:value-of select="@charoff"/>
1020 </xsl:attribute>
1021 </xsl:if>
1022-->
1023
1024 <xsl:choose>
1025 <xsl:when test="$fop.extensions = 0 and $passivetex.extensions = 0
1026 and $orientation != ''">
1027 <fo:block-container reference-orientation="{$orientation}">
1028 <xsl:if test="$rotated-width != ''">
1029 <xsl:attribute name="width">
1030 <xsl:value-of select="$rotated-width"/>
1031 </xsl:attribute>
1032 </xsl:if>
1033 <xsl:copy-of select="$cell.content"/>
1034 </fo:block-container>
1035 </xsl:when>
1036 <xsl:otherwise>
1037 <xsl:copy-of select="$cell.content"/>
1038 </xsl:otherwise>
1039 </xsl:choose>
1040 </fo:table-cell>
1041
1042 <xsl:choose>
1043 <xsl:when test="following-sibling::entry|following-sibling::entrytbl">
1044 <xsl:apply-templates select="(following-sibling::entry
1045 |following-sibling::entrytbl)[1]">
1046 <xsl:with-param name="col" select="$col+$entry.colspan"/>
1047 <xsl:with-param name="spans" select="$following.spans"/>
1048 </xsl:apply-templates>
1049 </xsl:when>
1050 <xsl:otherwise>
1051 <xsl:call-template name="finaltd">
1052 <xsl:with-param name="spans" select="$following.spans"/>
1053 <xsl:with-param name="col" select="$col+$entry.colspan"/>
1054 </xsl:call-template>
1055 </xsl:otherwise>
1056 </xsl:choose>
1057 </xsl:otherwise>
1058 </xsl:choose>
1059</xsl:template>
1060
1061<!-- Expand this template to add properties to any fo:table-cell -->
1062<xsl:template name="table.cell.properties">
1063 <xsl:param name="bgcolor.pi" select="''"/>
1064 <xsl:param name="rowsep.inherit" select="1"/>
1065 <xsl:param name="colsep.inherit" select="1"/>
1066 <xsl:param name="col" select="1"/>
1067 <xsl:param name="valign.inherit" select="''"/>
1068 <xsl:param name="align.inherit" select="''"/>
1069 <xsl:param name="char.inherit" select="''"/>
1070
1071 <xsl:choose>
1072 <xsl:when test="ancestor::tgroup">
1073 <xsl:if test="$bgcolor.pi != ''">
1074 <xsl:attribute name="background-color">
1075 <xsl:value-of select="$bgcolor.pi"/>
1076 </xsl:attribute>
1077 </xsl:if>
1078
1079 <xsl:if test="$rowsep.inherit &gt; 0">
1080 <xsl:call-template name="border">
1081 <xsl:with-param name="side" select="'bottom'"/>
1082 </xsl:call-template>
1083 </xsl:if>
1084
1085 <xsl:if test="$colsep.inherit &gt; 0 and
1086 $col &lt; ancestor::tgroup/@cols">
1087 <xsl:call-template name="border">
1088 <xsl:with-param name="side" select="'right'"/>
1089 </xsl:call-template>
1090 </xsl:if>
1091
1092 <xsl:if test="$valign.inherit != ''">
1093 <xsl:attribute name="display-align">
1094 <xsl:choose>
1095 <xsl:when test="$valign.inherit='top'">before</xsl:when>
1096 <xsl:when test="$valign.inherit='middle'">center</xsl:when>
1097 <xsl:when test="$valign.inherit='bottom'">after</xsl:when>
1098 <xsl:otherwise>
1099 <xsl:message>
1100 <xsl:text>Unexpected valign value: </xsl:text>
1101 <xsl:value-of select="$valign.inherit"/>
1102 <xsl:text>, center used.</xsl:text>
1103 </xsl:message>
1104 <xsl:text>center</xsl:text>
1105 </xsl:otherwise>
1106 </xsl:choose>
1107 </xsl:attribute>
1108 </xsl:if>
1109
1110 <xsl:choose>
1111 <xsl:when test="$align.inherit = 'char' and $char.inherit != ''">
1112 <xsl:attribute name="text-align">
1113 <xsl:value-of select="$char.inherit"/>
1114 </xsl:attribute>
1115 </xsl:when>
1116 <xsl:when test="$align.inherit != ''">
1117 <xsl:attribute name="text-align">
1118 <xsl:value-of select="$align.inherit"/>
1119 </xsl:attribute>
1120 </xsl:when>
1121 </xsl:choose>
1122
1123 </xsl:when>
1124 <xsl:otherwise>
1125 <!-- HTML table -->
1126 <xsl:variable name="border"
1127 select="(ancestor::table |
1128 ancestor::informaltable)[last()]/@border"/>
1129 <xsl:if test="$border != '' and $border != 0">
1130 <xsl:attribute name="border">
1131 <xsl:value-of select="$table.cell.border.thickness"/>
1132 <xsl:text> </xsl:text>
1133 <xsl:value-of select="$table.cell.border.style"/>
1134 <xsl:text> </xsl:text>
1135 <xsl:value-of select="$table.cell.border.color"/>
1136 </xsl:attribute>
1137 </xsl:if>
1138 </xsl:otherwise>
1139 </xsl:choose>
1140
1141</xsl:template>
1142
1143<!-- Expand this template to add properties to any cell's block -->
1144<xsl:template name="table.cell.block.properties">
1145 <!-- highlight this entry? -->
1146 <xsl:if test="ancestor::thead or ancestor::tfoot">
1147 <xsl:attribute name="font-weight">bold</xsl:attribute>
1148 </xsl:if>
1149</xsl:template>
1150
1151<xsl:template match="entry|entrytbl" name="sentry" mode="span">
1152 <xsl:param name="col" select="1"/>
1153 <xsl:param name="spans"/>
1154
1155 <xsl:variable name="entry.colnum">
1156 <xsl:call-template name="entry.colnum"/>
1157 </xsl:variable>
1158
1159 <xsl:variable name="entry.colspan">
1160 <xsl:choose>
1161 <xsl:when test="@spanname or @namest">
1162 <xsl:call-template name="calculate.colspan"/>
1163 </xsl:when>
1164 <xsl:otherwise>1</xsl:otherwise>
1165 </xsl:choose>
1166 </xsl:variable>
1167
1168 <xsl:variable name="following.spans">
1169 <xsl:call-template name="calculate.following.spans">
1170 <xsl:with-param name="colspan" select="$entry.colspan"/>
1171 <xsl:with-param name="spans" select="$spans"/>
1172 </xsl:call-template>
1173 </xsl:variable>
1174
1175 <xsl:choose>
1176 <xsl:when test="$spans != '' and not(starts-with($spans,'0:'))">
1177 <xsl:value-of select="substring-before($spans,':')-1"/>
1178 <xsl:text>:</xsl:text>
1179 <xsl:call-template name="sentry">
1180 <xsl:with-param name="col" select="$col+1"/>
1181 <xsl:with-param name="spans" select="substring-after($spans,':')"/>
1182 </xsl:call-template>
1183 </xsl:when>
1184
1185 <xsl:when test="number($entry.colnum) &gt; $col">
1186 <xsl:text>0:</xsl:text>
1187 <xsl:call-template name="sentry">
1188 <xsl:with-param name="col" select="$col+$entry.colspan"/>
1189 <xsl:with-param name="spans" select="$following.spans"/>
1190 </xsl:call-template>
1191 </xsl:when>
1192
1193 <xsl:otherwise>
1194 <xsl:call-template name="copy-string">
1195 <xsl:with-param name="count" select="$entry.colspan"/>
1196 <xsl:with-param name="string">
1197 <xsl:choose>
1198 <xsl:when test="@morerows">
1199 <xsl:value-of select="@morerows"/>
1200 </xsl:when>
1201 <xsl:otherwise>0</xsl:otherwise>
1202 </xsl:choose>
1203 <xsl:text>:</xsl:text>
1204 </xsl:with-param>
1205 </xsl:call-template>
1206
1207 <xsl:choose>
1208 <xsl:when test="following-sibling::entry|following-sibling::entrytbl">
1209 <xsl:apply-templates select="(following-sibling::entry
1210 |following-sibling::entrytbl)[1]"
1211 mode="span">
1212 <xsl:with-param name="col" select="$col+$entry.colspan"/>
1213 <xsl:with-param name="spans" select="$following.spans"/>
1214 </xsl:apply-templates>
1215 </xsl:when>
1216 <xsl:otherwise>
1217 <xsl:call-template name="sfinaltd">
1218 <xsl:with-param name="spans" select="$following.spans"/>
1219 </xsl:call-template>
1220 </xsl:otherwise>
1221 </xsl:choose>
1222 </xsl:otherwise>
1223 </xsl:choose>
1224</xsl:template>
1225
1226<xsl:template name="generate.colgroup.raw">
1227 <xsl:param name="cols" select="1"/>
1228 <xsl:param name="count" select="1"/>
1229
1230 <xsl:choose>
1231 <xsl:when test="$count>$cols"></xsl:when>
1232 <xsl:otherwise>
1233 <xsl:call-template name="generate.col.raw">
1234 <xsl:with-param name="countcol" select="$count"/>
1235 </xsl:call-template>
1236 <xsl:call-template name="generate.colgroup.raw">
1237 <xsl:with-param name="cols" select="$cols"/>
1238 <xsl:with-param name="count" select="$count+1"/>
1239 </xsl:call-template>
1240 </xsl:otherwise>
1241 </xsl:choose>
1242</xsl:template>
1243
1244<xsl:template name="generate.colgroup">
1245 <xsl:param name="cols" select="1"/>
1246 <xsl:param name="count" select="1"/>
1247
1248 <xsl:choose>
1249 <xsl:when test="$count>$cols"></xsl:when>
1250 <xsl:otherwise>
1251 <xsl:call-template name="generate.col">
1252 <xsl:with-param name="countcol" select="$count"/>
1253 </xsl:call-template>
1254 <xsl:call-template name="generate.colgroup">
1255 <xsl:with-param name="cols" select="$cols"/>
1256 <xsl:with-param name="count" select="$count+1"/>
1257 </xsl:call-template>
1258 </xsl:otherwise>
1259 </xsl:choose>
1260</xsl:template>
1261
1262<xsl:template name="generate.col.raw">
1263 <!-- generate the table-column for column countcol -->
1264 <xsl:param name="countcol">1</xsl:param>
1265 <xsl:param name="colspecs" select="./colspec"/>
1266 <xsl:param name="count">1</xsl:param>
1267 <xsl:param name="colnum">1</xsl:param>
1268
1269 <xsl:choose>
1270 <xsl:when test="$count>count($colspecs)">
1271 <fo:table-column column-number="{$countcol}"/>
1272 </xsl:when>
1273 <xsl:otherwise>
1274 <xsl:variable name="colspec" select="$colspecs[$count=position()]"/>
1275
1276 <xsl:variable name="colspec.colnum">
1277 <xsl:choose>
1278 <xsl:when test="$colspec/@colnum">
1279 <xsl:value-of select="$colspec/@colnum"/>
1280 </xsl:when>
1281 <xsl:otherwise>
1282 <xsl:value-of select="$colnum"/>
1283 </xsl:otherwise>
1284 </xsl:choose>
1285 </xsl:variable>
1286
1287 <xsl:variable name="colspec.colwidth">
1288 <xsl:choose>
1289 <xsl:when test="$colspec/@colwidth">
1290 <xsl:value-of select="$colspec/@colwidth"/>
1291 </xsl:when>
1292 <xsl:otherwise>1*</xsl:otherwise>
1293 </xsl:choose>
1294 </xsl:variable>
1295
1296 <xsl:choose>
1297 <xsl:when test="$colspec.colnum=$countcol">
1298 <fo:table-column column-number="{$countcol}">
1299 <xsl:attribute name="column-width">
1300 <xsl:value-of select="$colspec.colwidth"/>
1301 </xsl:attribute>
1302 </fo:table-column>
1303 </xsl:when>
1304 <xsl:otherwise>
1305 <xsl:call-template name="generate.col.raw">
1306 <xsl:with-param name="countcol" select="$countcol"/>
1307 <xsl:with-param name="colspecs" select="$colspecs"/>
1308 <xsl:with-param name="count" select="$count+1"/>
1309 <xsl:with-param name="colnum">
1310 <xsl:choose>
1311 <xsl:when test="$colspec/@colnum">
1312 <xsl:value-of select="$colspec/@colnum + 1"/>
1313 </xsl:when>
1314 <xsl:otherwise>
1315 <xsl:value-of select="$colnum + 1"/>
1316 </xsl:otherwise>
1317 </xsl:choose>
1318 </xsl:with-param>
1319 </xsl:call-template>
1320 </xsl:otherwise>
1321 </xsl:choose>
1322 </xsl:otherwise>
1323 </xsl:choose>
1324</xsl:template>
1325
1326<xsl:template name="generate.col">
1327 <!-- generate the table-column for column countcol -->
1328 <xsl:param name="countcol">1</xsl:param>
1329 <xsl:param name="colspecs" select="./colspec"/>
1330 <xsl:param name="count">1</xsl:param>
1331 <xsl:param name="colnum">1</xsl:param>
1332
1333 <xsl:choose>
1334 <xsl:when test="$count>count($colspecs)">
1335 <fo:table-column column-number="{$countcol}">
1336 <xsl:variable name="colwidth">
1337 <xsl:call-template name="calc.column.width"/>
1338 </xsl:variable>
1339 <xsl:if test="$colwidth != 'proportional-column-width(1)'">
1340 <xsl:attribute name="column-width">
1341 <xsl:value-of select="$colwidth"/>
1342 </xsl:attribute>
1343 </xsl:if>
1344 </fo:table-column>
1345 </xsl:when>
1346 <xsl:otherwise>
1347 <xsl:variable name="colspec" select="$colspecs[$count=position()]"/>
1348
1349 <xsl:variable name="colspec.colnum">
1350 <xsl:choose>
1351 <xsl:when test="$colspec/@colnum">
1352 <xsl:value-of select="$colspec/@colnum"/>
1353 </xsl:when>
1354 <xsl:otherwise>
1355 <xsl:value-of select="$colnum"/>
1356 </xsl:otherwise>
1357 </xsl:choose>
1358 </xsl:variable>
1359
1360 <xsl:variable name="colspec.colwidth">
1361 <xsl:choose>
1362 <xsl:when test="$colspec/@colwidth">
1363 <xsl:value-of select="$colspec/@colwidth"/>
1364 </xsl:when>
1365 <xsl:otherwise>1*</xsl:otherwise>
1366 </xsl:choose>
1367 </xsl:variable>
1368
1369 <xsl:choose>
1370 <xsl:when test="$colspec.colnum=$countcol">
1371 <fo:table-column column-number="{$countcol}">
1372 <xsl:variable name="colwidth">
1373 <xsl:call-template name="calc.column.width">
1374 <xsl:with-param name="colwidth">
1375 <xsl:value-of select="$colspec.colwidth"/>
1376 </xsl:with-param>
1377 </xsl:call-template>
1378 </xsl:variable>
1379 <xsl:if test="$colwidth != 'proportional-column-width(1)'">
1380 <xsl:attribute name="column-width">
1381 <xsl:value-of select="$colwidth"/>
1382 </xsl:attribute>
1383 </xsl:if>
1384 </fo:table-column>
1385 </xsl:when>
1386 <xsl:otherwise>
1387 <xsl:call-template name="generate.col">
1388 <xsl:with-param name="countcol" select="$countcol"/>
1389 <xsl:with-param name="colspecs" select="$colspecs"/>
1390 <xsl:with-param name="count" select="$count+1"/>
1391 <xsl:with-param name="colnum">
1392 <xsl:choose>
1393 <xsl:when test="$colspec/@colnum">
1394 <xsl:value-of select="$colspec/@colnum + 1"/>
1395 </xsl:when>
1396 <xsl:otherwise>
1397 <xsl:value-of select="$colnum + 1"/>
1398 </xsl:otherwise>
1399 </xsl:choose>
1400 </xsl:with-param>
1401 </xsl:call-template>
1402 </xsl:otherwise>
1403 </xsl:choose>
1404 </xsl:otherwise>
1405 </xsl:choose>
1406</xsl:template>
1407
1408<doc:template name="calc.column.width" xmlns="">
1409<refpurpose>Calculate an XSL FO table column width specification from a
1410CALS table column width specification.</refpurpose>
1411
1412<refdescription>
1413<para>CALS expresses table column widths in the following basic
1414forms:</para>
1415
1416<itemizedlist>
1417<listitem>
1418<para><emphasis>99.99units</emphasis>, a fixed length specifier.</para>
1419</listitem>
1420<listitem>
1421<para><emphasis>99.99</emphasis>, a fixed length specifier without any units.</para>
1422</listitem>
1423<listitem>
1424<para><emphasis>99.99*</emphasis>, a relative length specifier.</para>
1425</listitem>
1426<listitem>
1427<para><emphasis>99.99*+99.99units</emphasis>, a combination of both.</para>
1428</listitem>
1429</itemizedlist>
1430
1431<para>The CALS units are points (pt), picas (pi), centimeters (cm),
1432millimeters (mm), and inches (in). These are the same units as XSL,
1433except that XSL abbreviates picas "pc" instead of "pi". If a length
1434specifier has no units, the CALS default unit (pt) is assumed.</para>
1435
1436<para>Relative length specifiers are represented in XSL with the
1437proportional-column-width() function.</para>
1438
1439<para>Here are some examples:</para>
1440
1441<itemizedlist>
1442<listitem>
1443<para>"36pt" becomes "36pt"</para>
1444</listitem>
1445<listitem>
1446<para>"3pi" becomes "3pc"</para>
1447</listitem>
1448<listitem>
1449<para>"36" becomes "36pt"</para>
1450</listitem>
1451<listitem>
1452<para>"3*" becomes "proportional-column-width(3)"</para>
1453</listitem>
1454<listitem>
1455<para>"3*+2pi" becomes "proportional-column-width(3)+2pc"</para>
1456</listitem>
1457<listitem>
1458<para>"1*+2" becomes "proportional-column-width(1)+2pt"</para>
1459</listitem>
1460</itemizedlist>
1461</refdescription>
1462
1463<refparameter>
1464<variablelist>
1465<varlistentry><term>colwidth</term>
1466<listitem>
1467<para>The CALS column width specification.</para>
1468</listitem>
1469</varlistentry>
1470</variablelist>
1471</refparameter>
1472
1473<refreturn>
1474<para>The XSL column width specification.</para>
1475</refreturn>
1476</doc:template>
1477
1478<xsl:template name="calc.column.width">
1479 <xsl:param name="colwidth">1*</xsl:param>
1480
1481 <!-- Ok, the colwidth could have any one of the following forms: -->
1482 <!-- 1* = proportional width -->
1483 <!-- * = same as 1* -->
1484 <!-- 1unit = 1.0 units wide -->
1485 <!-- 1 = 1pt wide -->
1486 <!-- 1*+1unit = proportional width + some fixed width -->
1487 <!-- 1*+1 = proportional width + some fixed width -->
1488
1489 <!-- If it has a proportional width, translate it to XSL -->
1490 <xsl:if test="contains($colwidth, '*')">
1491 <xsl:text>proportional-column-width(</xsl:text>
1492 <xsl:choose>
1493 <xsl:when test="substring-before($colwidth, '*') != ''">
1494 <xsl:value-of select="substring-before($colwidth, '*')"/>
1495 </xsl:when>
1496 <xsl:otherwise>
1497 <xsl:text>1.00</xsl:text>
1498 </xsl:otherwise>
1499 </xsl:choose>
1500 <xsl:text>)</xsl:text>
1501 </xsl:if>
1502
1503 <!-- Now grab the non-proportional part of the specification -->
1504 <xsl:variable name="width-units">
1505 <xsl:choose>
1506 <xsl:when test="contains($colwidth, '*')">
1507 <xsl:value-of
1508 select="normalize-space(substring-after($colwidth, '*'))"/>
1509 </xsl:when>
1510 <xsl:otherwise>
1511 <xsl:value-of select="normalize-space($colwidth)"/>
1512 </xsl:otherwise>
1513 </xsl:choose>
1514 </xsl:variable>
1515
1516 <!-- Ok, now the width-units could have any one of the following forms: -->
1517 <!-- = <empty string> -->
1518 <!-- 1unit = 1.0 units wide -->
1519 <!-- 1 = 1pt wide -->
1520 <!-- with an optional leading sign -->
1521
1522 <!-- Grab the width part by blanking out the units part and discarding -->
1523 <!-- whitespace. It's not pretty, but it works. -->
1524 <xsl:variable name="width"
1525 select="normalize-space(translate($width-units,
1526 '+-0123456789.abcdefghijklmnopqrstuvwxyz',
1527 '+-0123456789.'))"/>
1528
1529 <!-- Grab the units part by blanking out the width part and discarding -->
1530 <!-- whitespace. It's not pretty, but it works. -->
1531 <xsl:variable name="units"
1532 select="normalize-space(translate($width-units,
1533 'abcdefghijklmnopqrstuvwxyz+-0123456789.',
1534 'abcdefghijklmnopqrstuvwxyz'))"/>
1535
1536 <!-- Output the width -->
1537 <xsl:value-of select="$width"/>
1538
1539 <!-- Output the units, translated appropriately -->
1540 <xsl:choose>
1541 <xsl:when test="$units = 'pi'">pc</xsl:when>
1542 <xsl:when test="$units = '' and $width != ''">pt</xsl:when>
1543 <xsl:otherwise><xsl:value-of select="$units"/></xsl:otherwise>
1544 </xsl:choose>
1545</xsl:template>
1546
1547<!-- ==================================================================== -->
1548
1549</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.