1
<?xml version='1.0' encoding="utf-8" ?>
4
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5
xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
6
xmlns:exsl="http://exslt.org/common"
7
exclude-result-prefixes="doc exsl" version='1.0'>
9
<xsl:param name="default.table.rules">none</xsl:param>
13
<xsl:template match="table|informaltable" mode="htmlTable">
14
<xsl:param name="tabletype">tabular</xsl:param>
15
<xsl:param name="tablewidth">\linewidth-2\tabcolsep</xsl:param>
16
<xsl:param name="tableframe">all</xsl:param>
18
<xsl:variable name="numcols">
19
<xsl:call-template name="widest-html-row">
20
<xsl:with-param name="rows" select=".//tr"/>
24
<!-- Get the specified table width -->
25
<xsl:variable name="table.width">
26
<xsl:call-template name="table.width">
27
<xsl:with-param name="fullwidth" select="$tablewidth"/>
31
<!-- Find the table width -->
32
<xsl:variable name="width">
34
<xsl:when test="not(contains($table.width,'auto'))">
35
<xsl:value-of select="$table.width"/>
38
<xsl:call-template name="table.width">
39
<xsl:with-param name="fullwidth" select="$tablewidth"/>
40
<xsl:with-param name="exclude" select="'auto'"/>
46
<!-- Now the frame style -->
47
<xsl:variable name="frame">
49
<xsl:when test="@frame">
50
<xsl:call-template name="cals.frame">
51
<xsl:with-param name="frame" select="@frame"/>
54
<xsl:otherwise><xsl:value-of select="$tableframe"/></xsl:otherwise>
58
<xsl:variable name="colspec">
59
<xsl:apply-templates select="(colgroup|col)[1]"
61
<xsl:with-param name="colnum" select="1"/>
62
<xsl:with-param name="colmax" select="$numcols"/>
63
</xsl:apply-templates>
66
<!-- Build the <row>s from the <tr>s -->
67
<xsl:variable name="rows-head" select="tr[child::th]"/>
68
<xsl:variable name="rows-body" select="tr[not(child::th)]"/>
70
<xsl:variable name="rows">
71
<!-- First the header -->
73
<xsl:when test="thead">
74
<xsl:apply-templates select="thead" mode="htmlTable">
75
<xsl:with-param name="colspec" select="exsl:node-set($colspec)"/>
76
</xsl:apply-templates>
79
<xsl:apply-templates select="$rows-head[1]" mode="htmlTable">
80
<xsl:with-param name="colspec" select="exsl:node-set($colspec)"/>
81
<xsl:with-param name="rownum" select="1"/>
82
<xsl:with-param name="context" select="'thead'"/>
83
</xsl:apply-templates>
87
<!-- Then the body -->
89
<xsl:when test="tbody">
90
<xsl:apply-templates select="tbody" mode="htmlTable">
91
<xsl:with-param name="colspec" select="exsl:node-set($colspec)"/>
92
</xsl:apply-templates>
95
<xsl:apply-templates select="$rows-body[1]" mode="htmlTable">
96
<xsl:with-param name="colspec" select="exsl:node-set($colspec)"/>
97
<xsl:with-param name="rownum" select="count($rows-head) +
99
</xsl:apply-templates>
102
<xsl:apply-templates select="tfoot/tr[1]" mode="htmlTable">
103
<xsl:with-param name="colspec" select="exsl:node-set($colspec)"/>
104
<xsl:with-param name="rownum" select="count(.//tr[not(parent::tfoot)])+1"/>
105
</xsl:apply-templates>
108
<!-- Complete the colspecs @width from the fully expended <row>s -->
109
<xsl:variable name="colspec2">
110
<xsl:call-template name="build.colwidth">
111
<xsl:with-param name="colspec" select="exsl:node-set($colspec)"/>
112
<xsl:with-param name="rows" select="exsl:node-set($rows)"/>
116
<!-- TIP: to check the built RTF elements, uncomment and call testtbl.xsl
117
<xsl:copy-of select="exsl:node-set($colspec2)"/>
118
<xsl:copy-of select="exsl:node-set($rows)"/>
121
<xsl:variable name="t.rows" select="exsl:node-set($rows)"/>
123
<xsl:text>\begingroup% </xsl:text>
125
<!-- Set cellpadding -->
126
<xsl:if test="@cellpadding">
127
<xsl:text>\setlength{\tabcolsep}{</xsl:text>
128
<xsl:value-of select="@cellpadding"/>
129
<xsl:text>}% </xsl:text>
132
<xsl:text>\setlength{\tablewidth}{</xsl:text>
133
<xsl:value-of select="$width"/>
134
<xsl:text>}% </xsl:text>
136
<xsl:if test="$tabletype != 'tabularx'">
137
<xsl:call-template name="tbl.sizes">
138
<xsl:with-param name="colspec" select="exsl:node-set($colspec2)"/>
139
<xsl:with-param name="width" select="$width"/>
143
<xsl:if test="$tabletype = 'tabularx'">
144
<xsl:call-template name="tbl.valign.x">
145
<xsl:with-param name="valign" select="@valign"/>
149
<!-- Translate the table to latex -->
151
<!-- Start the table declaration -->
152
<xsl:call-template name="tbl.begin">
153
<xsl:with-param name="colspec" select="exsl:node-set($colspec2)"/>
154
<xsl:with-param name="tabletype" select="$tabletype"/>
155
<xsl:with-param name="width" select="$width"/>
158
<!-- Need a top line? -->
159
<xsl:if test="$frame = 'all' or $frame = 'top' or $frame = 'topbot'">
160
<xsl:text>\hline</xsl:text>
162
<xsl:text> </xsl:text>
164
<!-- First, the head rows -->
165
<xsl:variable name="headrows">
166
<xsl:apply-templates select="$t.rows/*[@type='thead']"
168
<xsl:with-param name="colspec" select="exsl:node-set($colspec2)"/>
169
<xsl:with-param name="context" select="'thead'"/>
170
<xsl:with-param name="frame" select="$frame"/>
171
</xsl:apply-templates>
174
<xsl:apply-templates select="." mode="newtbl.endhead">
175
<xsl:with-param name="tabletype" select="$tabletype"/>
176
<xsl:with-param name="headrows" select="$headrows"/>
177
</xsl:apply-templates>
179
<!-- Then, the body rows -->
180
<xsl:apply-templates select="$t.rows/*[@type!='thead']"
182
<xsl:with-param name="colspec" select="exsl:node-set($colspec2)"/>
183
<xsl:with-param name="context" select="'tbody'"/>
184
<xsl:with-param name="frame" select="$frame"/>
185
</xsl:apply-templates>
187
<!-- Need a bottom line? -->
188
<xsl:if test="$frame = 'all' or $frame = 'bottom' or $frame = 'topbot'">
189
<xsl:text>\hline</xsl:text>
191
<xsl:text> </xsl:text>
193
<xsl:text>\end{</xsl:text>
194
<xsl:value-of select="$tabletype"/>
195
<xsl:text>}\endgroup% </xsl:text>
200
<!-- Build the latex row from the <row> element -->
201
<xsl:template match="row" mode="htmlTable">
202
<xsl:param name="colspec"/>
203
<xsl:param name="context"/>
204
<xsl:param name="frame"/>
206
<xsl:apply-templates mode="newtbl">
207
<xsl:with-param name="colspec" select="$colspec"/>
208
<xsl:with-param name="context" select="$context"/>
209
<xsl:with-param name="frame" select="$frame"/>
210
<xsl:with-param name="rownum" select="@rownum"/>
211
</xsl:apply-templates>
213
<!-- End this row -->
214
<xsl:text>\tabularnewline </xsl:text>
216
<!-- Now process rowseps only if not the last row -->
217
<xsl:if test="@rowsep=1">
219
<xsl:when test="$newtbl.use.hhline='1'">
220
<xsl:call-template name="hhline.build">
221
<xsl:with-param name="entries" select="."/>
222
<xsl:with-param name="rownum" select="@rownum"/>
226
<xsl:call-template name="clines.build">
227
<xsl:with-param name="entries" select="."/>
228
<xsl:with-param name="rownum" select="@rownum"/>
236
<xsl:template match="thead" mode="htmlTable">
237
<xsl:param name="colspec"/>
238
<xsl:apply-templates select="tr[1]" mode="htmlTable">
239
<xsl:with-param name="colspec" select="$colspec"/>
240
<xsl:with-param name="rownum" select="1"/>
241
</xsl:apply-templates>
245
<xsl:template match="tbody" mode="htmlTable">
246
<xsl:param name="colspec"/>
247
<xsl:apply-templates select="tr[1]" mode="htmlTable">
248
<xsl:with-param name="colspec" select="$colspec"/>
249
<xsl:with-param name="rownum"
250
select="count(preceding-sibling::*[self::tbody or
252
</xsl:apply-templates>
256
<!-- Build an intermediate <row> element from a <tr> only if the row
257
has the required 'context'
259
<xsl:template match="tr" mode="htmlTable">
260
<xsl:param name="rownum"/>
261
<xsl:param name="colspec"/>
262
<xsl:param name="oldentries"/>
263
<xsl:param name="context"/>
265
<xsl:variable name="type">
267
<xsl:when test="parent::thead">thead</xsl:when>
268
<xsl:when test="parent::tbody">tbody</xsl:when>
269
<xsl:when test="parent::tfoot">tfoot</xsl:when>
270
<!-- 'tr' contain 'th' and is not in a t* group -->
271
<xsl:when test="th">thead</xsl:when>
272
<xsl:otherwise>tbody</xsl:otherwise>
276
<xsl:if test="$context='' or $type=$context">
277
<xsl:variable name="entries">
278
<xsl:apply-templates select="(td|th)[1]" mode="htmlTable">
279
<xsl:with-param name="colspec" select="$colspec"/>
280
<xsl:with-param name="rownum" select="$rownum"/>
281
<xsl:with-param name="colnum" select="1"/>
282
<xsl:with-param name="entries" select="exsl:node-set($oldentries)"/>
283
</xsl:apply-templates>
286
<row type='{$type}' rownum='{$rownum}'>
287
<xsl:call-template name="html.table.row.rules"/>
288
<xsl:copy-of select="$entries"/>
291
<xsl:apply-templates select="following-sibling::tr[1]" mode="htmlTable">
292
<xsl:with-param name="colspec" select="$colspec"/>
293
<xsl:with-param name="rownum" select="$rownum + 1"/>
294
<xsl:with-param name="oldentries" select="$entries"/>
295
<xsl:with-param name="context" select="$context"/>
296
</xsl:apply-templates>
301
<!-- ==================================================================== -->
303
<!-- This template writes rowsep equivalant for html tables -->
304
<xsl:template name="html.table.row.rules">
305
<xsl:variable name="border"
306
select="(ancestor::table |
307
ancestor::informaltable)[last()]/@border"/>
308
<xsl:variable name="table.rules"
309
select="(ancestor::table |
310
ancestor::informaltable)[last()]/@rules"/>
312
<xsl:variable name="rules">
314
<xsl:when test="$table.rules != ''">
315
<xsl:value-of select="$table.rules"/>
317
<xsl:when test="$border != '' and number($border) != 0">
318
<xsl:value-of select="'all'"/>
320
<xsl:when test="$border != '' and number($border) = 0">
321
<xsl:value-of select="'none'"/>
323
<xsl:when test="$default.table.rules != ''">
324
<xsl:value-of select="$default.table.rules"/>
331
<xsl:when test="$rules = 'none'">
332
<xsl:attribute name="rowsep">0</xsl:attribute>
335
<xsl:when test="$rules = 'cols'">
336
<xsl:attribute name="rowsep">0</xsl:attribute>
339
<!-- If not the last row, add border below -->
340
<xsl:when test="$rules = 'rows' or $rules = 'all'">
341
<xsl:variable name="rowborder">
343
<!-- If in thead and tbody has rows, add border -->
344
<xsl:when test="parent::thead/
345
following-sibling::tbody/tr">1</xsl:when>
346
<!-- If in tbody and tfoot has rows, add border -->
347
<xsl:when test="parent::tbody/
348
following-sibling::tfoot/tr">1</xsl:when>
349
<!-- If in thead and table has body rows, add border -->
350
<xsl:when test="parent::thead/
351
following-sibling::tr">1</xsl:when>
352
<xsl:when test="parent::tbody/
353
preceding-sibling::tfoot/tr">1</xsl:when>
354
<xsl:when test="preceding-sibling::tfoot/tr">1</xsl:when>
355
<!-- If following rows, but not rowspan reaches last row -->
356
<xsl:when test="following-sibling::tr and
357
not(@rowspan = count(following-sibling::tr) + 1)">1</xsl:when>
358
<xsl:otherwise>0</xsl:otherwise>
362
<xsl:if test="$rowborder = 1">
363
<xsl:attribute name="rowsep">1</xsl:attribute>
367
<!-- rules only between 'thead' and 'tbody', or 'tbody' and 'tfoot' -->
368
<xsl:when test="$rules = 'groups' and parent::thead
369
and not(following-sibling::tr)">
370
<xsl:attribute name="rowsep">1</xsl:attribute>
372
<xsl:when test="$rules = 'groups' and parent::tfoot
373
and not(preceding-sibling::tr)">
374
<xsl:attribute name="rowsep">1</xsl:attribute>
379
<xsl:template name="html.table.column.rules">
380
<xsl:param name="colnum"/>
381
<xsl:param name="colmax"/>
383
<xsl:variable name="border"
384
select="(ancestor::table |
385
ancestor::informaltable)[last()]/@border"/>
386
<xsl:variable name="table.rules"
387
select="(ancestor::table |
388
ancestor::informaltable)[last()]/@rules"/>
390
<xsl:variable name="rules">
392
<xsl:when test="$table.rules != ''">
393
<xsl:value-of select="$table.rules"/>
395
<xsl:when test="$border != '' and number($border) != 0">
396
<xsl:value-of select="'all'"/>
398
<xsl:when test="$border != '' and number($border) = 0">
399
<xsl:value-of select="'none'"/>
401
<xsl:when test="$default.table.rules != ''">
402
<xsl:value-of select="$default.table.rules"/>
408
<xsl:when test="$rules = 'none'">
409
<xsl:attribute name="colsep">0</xsl:attribute>
411
<xsl:when test="$rules = 'rows'">
412
<xsl:attribute name="colsep">0</xsl:attribute>
414
<xsl:when test="$rules = 'groups'">
415
<xsl:attribute name="colsep">0</xsl:attribute>
417
<!-- If not the last column, add border after -->
418
<xsl:when test="($rules = 'cols' or $rules = 'all') and
419
($colnum < $colmax)">
420
<xsl:attribute name="colsep">1</xsl:attribute>
425
<!-- ==================================================================== -->
427
<xsl:template match="td|th" mode="htmlTable">
428
<xsl:param name="rownum"/>
429
<xsl:param name="colnum"/>
430
<xsl:param name="colspec"/>
431
<xsl:param name="entries"/>
433
<xsl:variable name="cols" select="count($colspec/*)"/>
435
<xsl:if test="$colnum <= $cols">
437
<xsl:variable name="entry"
438
select="$entries/*[self::entry or self::entrytbl]
439
[@colstart=$colnum and
440
@rowend >= $rownum]"/>
442
<!-- Do we have an existing entry element from a previous row that -->
443
<!-- should be copied into this row? -->
444
<xsl:choose><xsl:when test="$entry">
445
<!-- Just copy this entry then -->
446
<xsl:copy-of select="$entry"/>
448
<!-- Process the next column using this current entry -->
449
<xsl:apply-templates mode="htmlTable" select=".">
450
<xsl:with-param name="colnum"
451
select="$entries/entry[@colstart=$colnum]/@colend + 1"/>
452
<xsl:with-param name="rownum" select="$rownum"/>
453
<xsl:with-param name="colspec" select="$colspec"/>
454
<xsl:with-param name="entries" select="$entries"/>
455
</xsl:apply-templates>
456
</xsl:when><xsl:otherwise>
458
<xsl:variable name="colstart" select="$colnum"/>
460
<xsl:variable name="colend">
462
<xsl:when test="@colspan">
463
<xsl:value-of select="@colspan + $colnum -1"/>
466
<xsl:value-of select="$colnum"/>
471
<xsl:variable name="rowend">
473
<xsl:when test="@rowspan">
474
<xsl:value-of select="@rowspan + $rownum -1"/>
477
<xsl:value-of select="$rownum"/>
482
<xsl:variable name="rowcolor" select="parent::tr/@bgcolor"/>
484
<xsl:variable name="col" select="$colspec/colspec[@colnum=$colstart]"/>
486
<xsl:variable name="bgcolor">
488
<xsl:when test="$rowcolor != ''">
489
<xsl:value-of select="$rowcolor"/>
491
<xsl:when test="$col/@bgcolor">
492
<xsl:value-of select="$col/@bgcolor"/>
494
<xsl:when test="ancestor::*[@bgcolor]">
495
<xsl:value-of select="ancestor::*[@bgcolor][last()]/@bgcolor"/>
500
<xsl:variable name="valign">
502
<xsl:when test="../@valign">
503
<xsl:value-of select="../@valign"/>
505
<xsl:when test="$col/@valign">
506
<xsl:value-of select="$col/@valign"/>
508
<xsl:when test="ancestor::*[@valign]">
509
<xsl:value-of select="ancestor::*[@valign][last()]/@valign"/>
514
<xsl:variable name="align">
516
<xsl:when test="../@align">
517
<xsl:value-of select="../@align"/>
519
<xsl:when test="$col/@align">
520
<xsl:value-of select="$col/@align"/>
522
<xsl:when test="ancestor::*[@align]">
523
<xsl:value-of select="ancestor::*[@align][last()]/@align"/>
529
<xsl:for-each select="@*"><xsl:copy/></xsl:for-each>
530
<xsl:attribute name="colstart">
531
<xsl:value-of select="$colstart"/>
533
<xsl:attribute name="colend">
534
<xsl:value-of select="$colend"/>
536
<xsl:attribute name="rowstart">
537
<xsl:value-of select="$rownum"/>
539
<xsl:attribute name="rowend">
540
<xsl:value-of select="$rowend"/>
542
<xsl:if test="$rowend > $rownum">
543
<xsl:attribute name="morerows">
544
<xsl:value-of select="$rowend - $rownum"/>
547
<xsl:if test="$col/@colsep = 1">
548
<xsl:attribute name="colsep">
549
<xsl:value-of select="1"/>
552
<xsl:if test="not(@bgcolor) and $bgcolor != ''">
553
<xsl:attribute name="bgcolor">
554
<xsl:value-of select="$bgcolor"/>
557
<xsl:if test="not(@valign) and $valign != ''">
558
<xsl:attribute name="valign">
559
<xsl:value-of select="$valign"/>
562
<xsl:if test="not(@align) and $align != ''">
563
<xsl:attribute name="align">
564
<xsl:value-of select="$align"/>
567
<xsl:element name="output">
568
<xsl:apply-templates select="." mode="output"/>
573
<xsl:when test="following-sibling::*[self::td or self::th]">
576
select="following-sibling::*[self::td or self::th][1]"
578
<xsl:with-param name="colspec" select="$colspec"/>
579
<xsl:with-param name="rownum" select="$rownum"/>
580
<xsl:with-param name="colnum" select="$colend + 1"/>
581
<xsl:with-param name="entries" select="$entries"/>
582
</xsl:apply-templates>
585
<xsl:when test="$colend < $cols">
586
<!-- Create more blank entries to pad the row -->
587
<xsl:call-template name="tbl.blankentry">
588
<xsl:with-param name="colnum" select="$colend + 1"/>
589
<xsl:with-param name="colend" select="$cols"/>
590
<xsl:with-param name="colspec" select="$colspec"/>
591
<xsl:with-param name="rownum" select="$rownum"/>
592
<xsl:with-param name="entries" select="$entries"/>
593
<xsl:with-param name="rowcolor" select="$rowcolor"/>
598
</xsl:otherwise></xsl:choose>
602
<!-- ==================================================================== -->
604
<xsl:template match="tr" mode="span">
605
<xsl:param name="currow"/>
606
<xsl:variable name="tr.pos" select="position()"/>
607
<xsl:variable name="spantds" select="td[@rowspan][$tr.pos + @rowspan >
609
<xsl:if test="$spantds">
610
<span rownum="{$currow}" p="{$tr.pos}">
611
<xsl:attribute name="value">
613
select="sum($spantds/@colspan)+count($spantds[not(@colspan)])"/>
620
<xsl:template name="widest-html-row">
621
<xsl:param name="rows" select="''"/>
622
<xsl:param name="count" select="0"/>
623
<xsl:param name="currow" select="1"/>
624
<xsl:variable name="row" select="$rows[position()=$currow]"/>
626
<xsl:when test="not($row)">
627
<xsl:value-of select="$count"/>
630
<xsl:variable name="count1" select="count($row/*[not(@colspan)])"/>
631
<xsl:variable name="count2" select="sum($row/*/@colspan)"/>
632
<xsl:variable name="countn" select="$count1 + $count2"/>
634
<!-- retrieve the previous <td>s that contain a @rowspan
635
that span over the current row -->
636
<xsl:variable name="spantds">
638
select="$rows[position() < $currow]"
640
<xsl:with-param name="currow" select="$currow"/>
641
</xsl:apply-templates>
644
<!-- get the additional columns implied by the upward spanning <td> -->
645
<xsl:variable name="addcols"
646
select="sum(exsl:node-set($spantds)/*/@value)"/>
648
<!-- TIP: uncomment to debug the column count algorithm
649
<foo> <xsl:copy-of select="$spantds"/> </foo>
652
<xsl:text>p=</xsl:text><xsl:value-of select="$currow"/>
653
<xsl:text> c=</xsl:text><xsl:value-of select="$count"/>
654
<xsl:text> s=</xsl:text><xsl:value-of select="$addcols"/>
659
<xsl:when test="$count > ($countn + $addcols)">
660
<xsl:call-template name="widest-html-row">
661
<xsl:with-param name="rows" select="$rows"/>
662
<xsl:with-param name="count" select="$count"/>
663
<xsl:with-param name="currow" select="$currow + 1"/>
667
<xsl:call-template name="widest-html-row">
668
<xsl:with-param name="rows" select="$rows"/>
669
<xsl:with-param name="count" select="$countn + $addcols"/>
670
<xsl:with-param name="currow" select="$currow + 1"/>
678
<!-- ==================================================================== -->
680
<xsl:template name="build.colwidth">
681
<xsl:param name="colspec"/>
682
<xsl:param name="rows"/>
684
<xsl:for-each select="$colspec/*">
685
<xsl:variable name="pos" select="position()"/>
686
<xsl:variable name="colentries"
687
select="$rows/row/entry[@colstart <= $pos and
688
@colend >= $pos][@width]"/>
690
<xsl:variable name="pct">
691
<xsl:call-template name="max.percent">
692
<xsl:with-param name="entries" select="$colentries"/>
693
<xsl:with-param name="maxpct">
695
<xsl:when test="substring(@width,string-length(@width))='%'">
696
<xsl:value-of select="number(substring-before(@width, '%'))"/>
699
<xsl:value-of select="0"/>
705
<xsl:variable name="fixed">
706
<xsl:call-template name="max.value">
707
<xsl:with-param name="entries" select="$colentries"/>
708
<xsl:with-param name="maxval">
710
<xsl:when test="string(number(@width))!='NaN'">
711
<xsl:value-of select="number(@width)"/>
714
<xsl:value-of select="0"/>
720
<xsl:variable name="star">
722
<xsl:when test="substring(@width,string-length(@width))='*'">
723
<xsl:value-of select="number(substring-before(@width, '*'))"/>
726
<!-- '0*' is allowed and meaningfull, so use a negative number to
727
signify a missing star -->
728
<xsl:value-of select="-1"/>
735
<xsl:value-of select="$pos"/>
736
<xsl:text>, </xsl:text>
737
<xsl:value-of select="count($colentries)"/>
738
<xsl:text> pct=</xsl:text><xsl:value-of select="$pct"/>
739
<xsl:text> val=</xsl:text><xsl:value-of select="$fixed"/>
740
<xsl:text> star=</xsl:text><xsl:value-of select="$star"/>
745
<xsl:for-each select="@*"><xsl:copy/></xsl:for-each>
747
<!-- Now, make precedences between the found width types -->
749
<!-- the special form "0*" means to use the column's content width -->
750
<xsl:when test="$star = 0">
751
<xsl:attribute name="autowidth">1</xsl:attribute>
752
<!-- set a star to reserve some default space for the column -->
753
<xsl:attribute name="colwidth">
754
<xsl:text>\newtblstarfactor</xsl:text>
756
<xsl:attribute name="star">
757
<xsl:value-of select="1"/>
760
<xsl:when test="$star > 0">
761
<xsl:attribute name="colwidth">
762
<xsl:value-of select="$star"/>
763
<xsl:text>\newtblstarfactor</xsl:text>
765
<xsl:attribute name="star">
766
<xsl:value-of select="$star"/>
769
<xsl:when test="$pct > 0">
770
<xsl:variable name="width">
771
<xsl:value-of select="$pct div 100"/>
772
<xsl:text>\tablewidth</xsl:text>
774
<xsl:attribute name="fixedwidth">
775
<xsl:value-of select="$width"/>
777
<xsl:attribute name="colwidth">
778
<xsl:value-of select="$width"/>
781
<xsl:when test="$fixed > 0">
782
<!-- the width is expressed in 'px' bus is seen as 'pt' for tex -->
783
<xsl:variable name="width">
784
<xsl:value-of select="$fixed"/>
785
<xsl:text>pt</xsl:text>
787
<xsl:attribute name="fixedwidth">
788
<xsl:value-of select="$width"/>
790
<xsl:attribute name="colwidth">
791
<xsl:value-of select="$width"/>
795
<!-- no width specified: equivalent to a '*' -->
796
<xsl:attribute name="colwidth">
797
<xsl:text>\newtblstarfactor</xsl:text>
799
<xsl:attribute name="star">1</xsl:attribute>
807
<!-- Find the maximum width expressed in percentage in column entries -->
808
<xsl:template name="max.percent">
809
<xsl:param name="entries"/>
810
<xsl:param name="maxpct" select="0"/>
813
<xsl:when test="$entries">
814
<xsl:variable name="width" select="$entries[1]/@width"/>
816
<xsl:variable name="newpct">
818
<xsl:when test="substring($width,string-length($width))='%'">
819
<xsl:variable name="pct" select="number(substring-before($width, '%'))"/>
821
<xsl:when test="$pct > $maxpct">
822
<xsl:value-of select="$pct"/>
825
<xsl:value-of select="$maxpct"/>
830
<xsl:value-of select="$maxpct"/>
834
<xsl:call-template name="max.percent">
835
<xsl:with-param name="maxpct" select="$newpct"/>
836
<xsl:with-param name="entries" select="$entries[position() > 1]"/>
840
<xsl:value-of select="$maxpct"/>
845
<!-- Find the maximum width expressed in numbers in column entries -->
846
<xsl:template name="max.value">
847
<xsl:param name="entries"/>
848
<xsl:param name="maxval" select="0"/>
851
<xsl:when test="$entries">
852
<xsl:variable name="width" select="$entries[1]/@width"/>
854
<xsl:variable name="newval">
856
<xsl:when test="string(number($width))!='NaN'">
857
<xsl:variable name="val" select="number($width)"/>
859
<xsl:when test="$val > $maxval">
860
<xsl:value-of select="$val"/>
863
<xsl:value-of select="$maxval"/>
868
<xsl:value-of select="$maxval"/>
872
<xsl:call-template name="max.value">
873
<xsl:with-param name="maxval" select="$newval"/>
874
<xsl:with-param name="entries" select="$entries[position() > 1]"/>
878
<xsl:value-of select="$maxval"/>
883
<!-- ==================================================================== -->
885
<!-- Build the equivalent <colspec>s elements from <colgroup>s and <col>s
886
and use default colspec for undefined <col>s in order to have a colspec
890
<xsl:template match="colgroup" mode="make.colspec">
891
<xsl:param name="done" select="0"/>
892
<xsl:param name="colnum"/>
893
<xsl:param name="colmax"/>
896
<xsl:when test="col">
897
<!-- the spec are handled by <col>s -->
898
<xsl:apply-templates select="col[1]" mode="make.colspec">
899
<xsl:with-param name="colnum" select="$colnum"/>
900
<xsl:with-param name="colmax" select="$colmax"/>
901
</xsl:apply-templates>
905
<xsl:variable name="span">
907
<xsl:when test="@span">
908
<xsl:value-of select="@span"/>
911
<xsl:value-of select="1"/>
917
<xsl:when test="$done < $span">
918
<!-- bgcolor specified via a PI -->
919
<xsl:variable name="bgcolor">
920
<xsl:if test="processing-instruction('dblatex')">
921
<xsl:call-template name="pi-attribute">
922
<xsl:with-param name="pis"
923
select="processing-instruction('dblatex')"/>
924
<xsl:with-param name="attribute" select="'bgcolor'"/>
930
<xsl:for-each select="@*"><xsl:copy/></xsl:for-each>
931
<xsl:attribute name="colnum">
932
<xsl:value-of select="$colnum"/>
934
<xsl:if test="$bgcolor != ''">
935
<xsl:attribute name="bgcolor"><xsl:value-of select="$bgcolor"/>
938
<xsl:call-template name="html.table.column.rules">
939
<xsl:with-param name="colnum" select="$colnum"/>
940
<xsl:with-param name="colmax" select="$colmax"/>
944
<xsl:apply-templates select="." mode="make.colspec">
945
<xsl:with-param name="done" select="$done + 1"/>
946
<xsl:with-param name="colnum" select="$colnum + 1"/>
947
<xsl:with-param name="colmax" select="$colmax"/>
948
</xsl:apply-templates>
950
<xsl:when test="following-sibling::*[self::colgroup or self::col]">
951
<xsl:apply-templates select="following-sibling::*[self::colgroup or
954
<xsl:with-param name="colnum" select="$colnum"/>
955
<xsl:with-param name="colmax" select="$colmax"/>
956
</xsl:apply-templates>
958
<!-- build empty default <colspec>s for missing columns -->
959
<xsl:when test="$colnum <= $colmax">
961
<xsl:attribute name="colnum">
962
<xsl:value-of select="$colnum"/>
964
<xsl:call-template name="html.table.column.rules">
965
<xsl:with-param name="colnum" select="$colnum"/>
966
<xsl:with-param name="colmax" select="$colmax"/>
970
<xsl:apply-templates select="." mode="make.colspec">
971
<xsl:with-param name="colnum" select="$colnum + 1"/>
972
<xsl:with-param name="colmax" select="$colmax"/>
973
<xsl:with-param name="done" select="$colmax"/>
974
</xsl:apply-templates>
981
<xsl:template match="col" mode="make.colspec">
982
<xsl:param name="done" select="0"/>
983
<xsl:param name="colnum"/>
984
<xsl:param name="colmax"/>
988
<xsl:text>p=</xsl:text>
989
<xsl:value-of select="local-name()"/>
990
<xsl:text> </xsl:text>
991
<xsl:value-of select="generate-id()"/>
992
<xsl:text> r=</xsl:text>
993
<xsl:value-of select="$colnum"/>
997
<xsl:variable name="span">
999
<xsl:when test="@span">
1000
<xsl:value-of select="@span"/>
1003
<xsl:value-of select="1"/>
1009
<!-- clone the same <colspec> span times -->
1010
<xsl:when test="$done < $span">
1011
<!-- bgcolor specified via a PI or a colgroup parent PI -->
1012
<xsl:variable name="bgcolor">
1014
<xsl:when test="processing-instruction('dblatex')">
1015
<xsl:call-template name="pi-attribute">
1016
<xsl:with-param name="pis"
1017
select="processing-instruction('dblatex')"/>
1018
<xsl:with-param name="attribute" select="'bgcolor'"/>
1019
</xsl:call-template>
1021
<xsl:when test="../processing-instruction('dblatex')">
1022
<xsl:call-template name="pi-attribute">
1023
<xsl:with-param name="pis"
1024
select="../processing-instruction('dblatex')"/>
1025
<xsl:with-param name="attribute" select="'bgcolor'"/>
1026
</xsl:call-template>
1032
<xsl:for-each select="parent::colgroup/@*"><xsl:copy/></xsl:for-each>
1033
<xsl:for-each select="@*"><xsl:copy/></xsl:for-each>
1034
<xsl:attribute name="colnum">
1035
<xsl:value-of select="$colnum"/>
1037
<xsl:if test="$bgcolor != ''">
1038
<xsl:attribute name="bgcolor"><xsl:value-of select="$bgcolor"/>
1041
<xsl:call-template name="html.table.column.rules">
1042
<xsl:with-param name="colnum" select="$colnum"/>
1043
<xsl:with-param name="colmax" select="$colmax"/>
1044
</xsl:call-template>
1047
<xsl:apply-templates select="." mode="make.colspec">
1048
<xsl:with-param name="done" select="$done + 1"/>
1049
<xsl:with-param name="colnum" select="$colnum + 1"/>
1050
<xsl:with-param name="colmax" select="$colmax"/>
1051
</xsl:apply-templates>
1053
<!-- process the next following <col*> -->
1054
<xsl:when test="following-sibling::*[self::colgroup or self::col]">
1055
<xsl:apply-templates
1056
select="following-sibling::*[self::col or self::colgroup][1]"
1057
mode="make.colspec">
1058
<xsl:with-param name="colnum" select="$colnum"/>
1059
<xsl:with-param name="colmax" select="$colmax"/>
1060
</xsl:apply-templates>
1062
<!-- if <col> is a <colgroup> child, process the next <col*> at the parent
1064
<xsl:when test="parent::colgroup[following-sibling::*[self::colgroup or
1066
<xsl:apply-templates select="parent::colgroup/
1067
following-sibling::*[self::col or
1069
mode="make.colspec">
1070
<xsl:with-param name="colnum" select="$colnum"/>
1071
<xsl:with-param name="colmax" select="$colmax"/>
1072
</xsl:apply-templates>
1074
<!-- build empty default <colspec>s for missing columns -->
1075
<xsl:when test="$colnum <= $colmax">
1077
<xsl:attribute name="colnum">
1078
<xsl:value-of select="$colnum"/>
1080
<xsl:call-template name="html.table.column.rules">
1081
<xsl:with-param name="colnum" select="$colnum"/>
1082
<xsl:with-param name="colmax" select="$colmax"/>
1083
</xsl:call-template>
1086
<xsl:apply-templates select="." mode="make.colspec">
1087
<xsl:with-param name="colnum" select="$colnum + 1"/>
1088
<xsl:with-param name="colmax" select="$colmax"/>
1089
<xsl:with-param name="done" select="$colmax"/>
1090
</xsl:apply-templates>