source: BOOK/stylesheets/lfs-xsl/docbook-xsl-snapshot/fo/table.xsl@ 0a4f15b

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

Updated DocBook-XSL code to version 1.73.2

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