source: stylesheets/lfs-xsl/docbook-xsl-1.78.1/fo/table.xsl@ 15c7d39

10.0 10.0-rc1 10.1 10.1-rc1 11.0 11.0-rc1 11.0-rc2 11.0-rc3 11.1 11.1-rc1 11.2 11.2-rc1 11.3 11.3-rc1 12.0 12.0-rc1 12.1 12.1-rc1 7.5 7.6 7.7 7.8 7.9 8.0 8.1 8.2 8.3 8.4 9.0 9.1 arm bdubbs/gcc13 ml-11.0 multilib renodr/libudev-from-systemd s6-init trunk xry111/arm64 xry111/arm64-12.0 xry111/clfs-ng xry111/lfs-next xry111/loongarch xry111/loongarch-12.0 xry111/loongarch-12.1 xry111/mips64el xry111/pip3 xry111/rust-wip-20221008 xry111/update-glibc
Last change on this file since 15c7d39 was 15c7d39, checked in by Matthew Burgess <matthew@…>, 11 years ago

Update stylesheets to docbook-xsl-1.78.1.

git-svn-id: http://svn.linuxfromscratch.org/LFS/trunk/BOOK@10355 4aa44e1e-78dd-0310-a6d2-fbcd4c07a689

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