1
<?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
3
This program is free software; you can redistribute it and/or modify it under
4
the terms of the GNU Lesser General Public License as published by the Free
5
Software Foundation; either version 2 of the License, or (at your option) any
8
This program is distributed in the hope that it will be useful, but WITHOUT
9
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10
FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13
You should have received a copy of the GNU Lesser General Public License
14
along with this program; see the file COPYING.LGPL. If not, write to the
15
Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
19
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
20
xmlns:mal="http://projectmallard.org/1.0/"
21
xmlns:str="http://exslt.org/strings"
22
xmlns="http://www.w3.org/1999/xhtml"
23
extension-element-prefixes="str"
26
<!--!!==========================================================================
27
Mallard to HTML - Table Elements
29
REMARK: Describe this module
33
<!--**==========================================================================
35
Outputs CSS that controls the appearance of tables
37
REMARK: Describe this template
39
<xsl:template name="mal2html.table.css">
42
border-collapse: collapse;
43
border-color: #555753;
47
padding: 0.1em 0.5em 0.1em 0.5em;
48
border-color: #888a85;
56
<!-- == Matched Templates == -->
59
<xsl:template mode="mal2html.block.mode" match="mal:table">
60
<xsl:variable name="cols" select="mal:col | mal:colgroup/mal:col"/>
61
<xsl:variable name="style">
62
<xsl:if test="@frame and @frame != 'none'">
64
<xsl:when test="@frame = 'all'">
65
<xsl:text>border-style: solid;</xsl:text>
68
<xsl:for-each select="str:split(@frame)">
70
<xsl:when test=". = 'top'">
71
<xsl:text>border-top-style: solid;</xsl:text>
73
<xsl:when test=". = 'bottom'">
74
<xsl:text>border-bottom-style: solid;</xsl:text>
76
<xsl:when test=". = 'left'">
77
<xsl:text>border-left-style: solid;</xsl:text>
79
<xsl:when test=". = 'right'">
80
<xsl:text>border-right-style: solid;</xsl:text>
88
<xsl:variable name="rowrules">
90
<xsl:when test="not(@rules) or @rules = 'none'">
91
<xsl:text>none</xsl:text>
93
<xsl:when test="@rules = 'all'">
94
<xsl:text>all</xsl:text>
96
<xsl:when test="@rules = 'groups'">
97
<xsl:text>groups</xsl:text>
100
<xsl:for-each select="str:split(@rules)">
102
<xsl:when test=". = 'rows'">
103
<xsl:text>all</xsl:text>
105
<xsl:when test=". = 'rowgroups'">
106
<xsl:text>groups</xsl:text>
113
<xsl:variable name="colrules">
115
<xsl:when test="not(@rules) or @rules = 'none'">
116
<xsl:text>none</xsl:text>
118
<xsl:when test="@rules = 'all'">
119
<xsl:text>all</xsl:text>
121
<xsl:when test="@rules = 'groups'">
122
<xsl:text>groups</xsl:text>
125
<xsl:for-each select="str:split(@rules)">
127
<xsl:when test=". = 'cols'">
128
<xsl:text>all</xsl:text>
130
<xsl:when test=". = 'colgroups'">
131
<xsl:text>groups</xsl:text>
138
<xsl:variable name="rowshade">
140
<xsl:when test="not(@shade) or @shade = 'none'">
141
<xsl:text>none</xsl:text>
143
<xsl:when test="@shade = 'all'">
144
<xsl:text>all</xsl:text>
146
<xsl:when test="@shade = 'groups'">
147
<xsl:text>groups</xsl:text>
150
<xsl:for-each select="str:split(@shade)">
152
<xsl:when test=". = 'rows'">
153
<xsl:text>all</xsl:text>
155
<xsl:when test=". = 'rowgroups'">
156
<xsl:text>groups</xsl:text>
163
<xsl:variable name="colshade">
165
<xsl:when test="not(@shade) or @shade = 'none'">
166
<xsl:text>none</xsl:text>
168
<xsl:when test="@shade = 'all'">
169
<xsl:text>all</xsl:text>
171
<xsl:when test="@shade = 'groups'">
172
<xsl:text>groups</xsl:text>
175
<xsl:for-each select="str:split(@shade)">
177
<xsl:when test=". = 'cols'">
178
<xsl:text>all</xsl:text>
180
<xsl:when test=". = 'colgroups'">
181
<xsl:text>groups</xsl:text>
189
<xsl:attribute name="class">
190
<xsl:text>table</xsl:text>
191
<xsl:if test="not(preceding-sibling::*)">
192
<xsl:text> first-child</xsl:text>
195
<table class="table">
196
<xsl:if test="$style != ''">
197
<xsl:attribute name="style">
198
<xsl:value-of select="$style"/>
201
<xsl:apply-templates select="mal:thead">
202
<xsl:with-param name="cols" select="$cols"/>
203
<xsl:with-param name="rowrules" select="$rowrules"/>
204
<xsl:with-param name="colrules" select="$colrules"/>
205
<xsl:with-param name="rowshade" select="$rowshade"/>
206
<xsl:with-param name="colshade" select="$colshade"/>
207
</xsl:apply-templates>
208
<xsl:apply-templates select="mal:tfoot">
209
<xsl:with-param name="cols" select="$cols"/>
210
<xsl:with-param name="rowrules" select="$rowrules"/>
211
<xsl:with-param name="colrules" select="$colrules"/>
212
<xsl:with-param name="rowshade" select="$rowshade"/>
213
<xsl:with-param name="colshade" select="$colshade"/>
214
</xsl:apply-templates>
215
<xsl:apply-templates select="mal:tr | mal:tbody">
216
<xsl:with-param name="cols" select="$cols"/>
217
<xsl:with-param name="rowrules" select="$rowrules"/>
218
<xsl:with-param name="colrules" select="$colrules"/>
219
<xsl:with-param name="rowshade" select="$rowshade"/>
220
<xsl:with-param name="colshade" select="$colshade"/>
221
</xsl:apply-templates>
227
<xsl:template match="mal:tbody">
228
<xsl:param name="cols"/>
229
<xsl:param name="rowrules"/>
230
<xsl:param name="colrules"/>
231
<xsl:param name="rowshade"/>
232
<xsl:param name="colshade"/>
234
<xsl:apply-templates select="mal:tr">
235
<xsl:with-param name="cols" select="$cols"/>
236
<xsl:with-param name="rowrules" select="$rowrules"/>
237
<xsl:with-param name="colrules" select="$colrules"/>
238
<xsl:with-param name="rowshade" select="$rowshade"/>
239
<xsl:with-param name="colshade" select="$colshade"/>
240
</xsl:apply-templates>
245
<xsl:template match="mal:thead">
246
<xsl:param name="cols"/>
247
<xsl:param name="rowrules"/>
248
<xsl:param name="colrules"/>
249
<xsl:param name="rowshade"/>
250
<xsl:param name="colshade"/>
252
<xsl:apply-templates select="mal:tr">
253
<xsl:with-param name="cols" select="$cols"/>
254
<xsl:with-param name="rowrules" select="$rowrules"/>
255
<xsl:with-param name="colrules" select="$colrules"/>
256
<xsl:with-param name="rowshade" select="$rowshade"/>
257
<xsl:with-param name="colshade" select="$colshade"/>
258
</xsl:apply-templates>
263
<xsl:template match="mal:tfoot">
264
<xsl:param name="cols"/>
265
<xsl:param name="rowrules"/>
266
<xsl:param name="colrules"/>
267
<xsl:param name="rowshade"/>
268
<xsl:param name="colshade"/>
270
<xsl:apply-templates select="mal:tr">
271
<xsl:with-param name="cols" select="$cols"/>
272
<xsl:with-param name="rowrules" select="$rowrules"/>
273
<xsl:with-param name="colrules" select="$colrules"/>
274
<xsl:with-param name="rowshade" select="$rowshade"/>
275
<xsl:with-param name="colshade" select="$colshade"/>
276
</xsl:apply-templates>
281
<xsl:template match="mal:tr">
282
<xsl:param name="cols"/>
283
<xsl:param name="rowrules"/>
284
<xsl:param name="colrules"/>
285
<xsl:param name="rowshade"/>
286
<xsl:param name="colshade"/>
288
<xsl:apply-templates select="mal:td">
289
<xsl:with-param name="cols" select="$cols"/>
290
<xsl:with-param name="rowrules" select="$rowrules"/>
291
<xsl:with-param name="colrules" select="$colrules"/>
292
<xsl:with-param name="rowshade" select="$rowshade"/>
293
<xsl:with-param name="colshade" select="$colshade"/>
294
</xsl:apply-templates>
299
<xsl:template match="mal:td">
300
<xsl:param name="cols"/>
301
<xsl:param name="rowrules"/>
302
<xsl:param name="colrules"/>
303
<xsl:param name="rowshade"/>
304
<xsl:param name="colshade"/>
305
<xsl:variable name="trpos" select="count(../preceding-sibling::mal:tr) + 1"/>
306
<xsl:variable name="tdpos" select="count(preceding-sibling::mal:td) + 1"/>
307
<!-- FIXME: this all breaks with rowspan/colspan -->
308
<xsl:variable name="shaderow">
310
<xsl:when test="$rowshade = 'all'">
312
<xsl:when test="../../self::mal:table">
313
<xsl:value-of select="($trpos + 1) mod 2"/>
316
<xsl:variable name="bodies"
317
select="../../preceding-sibling::mal:tbody |
318
../../preceding-sibling::mal:thead "/>
319
<xsl:variable name="trcount" select="count($bodies/mal:tr) + $trpos"/>
320
<xsl:value-of select="($trcount + 1) mod 2"/>
324
<xsl:when test="$rowshade = 'groups'">
325
<xsl:variable name="bodies"
326
select="../../preceding-sibling::mal:tbody |
327
../../preceding-sibling::mal:thead "/>
328
<xsl:value-of select="count($bodies) mod 2"/>
332
<xsl:variable name="shadecol">
334
<xsl:when test="$colshade = 'all'">
335
<xsl:value-of select="($tdpos + 1) mod 2"/>
337
<xsl:when test="$colshade = 'groups'">
338
<xsl:if test="count($cols) >= $tdpos">
339
<xsl:variable name="col" select="$cols[$tdpos]"/>
340
<xsl:if test="$col/../self::mal:colgroup">
342
select="count($col/../preceding-sibling::mal:colgroup) mod 2"/>
349
<xsl:variable name="style">
351
<xsl:when test="$rowrules = 'all'">
353
<xsl:when test="../../self::mal:table">
354
<xsl:if test="$trpos != 1">
355
<xsl:text>border-top-style: solid;</xsl:text>
358
<xsl:when test="$trpos != 1 or
359
../../preceding-sibling::mal:thead or
360
../../preceding-sibling::mal:tbody ">
361
<xsl:text>border-top-style: solid;</xsl:text>
365
<xsl:when test="$rowrules = 'groups'">
366
<xsl:if test="$trpos = 1">
368
<xsl:when test="../../self::mal:tbody">
369
<xsl:if test="../../../mal:thead | ../../preceding-sibling::mal:tbody">
370
<xsl:text>border-top-style: solid;</xsl:text>
373
<xsl:when test="../../self::mal:tfoot">
374
<xsl:text>border-top-style: solid;</xsl:text>
381
<xsl:when test="$tdpos = 1"/>
382
<xsl:when test="$colrules = 'all'">
383
<xsl:text>border-left-style: solid;</xsl:text>
385
<xsl:when test="$colrules = 'groups'">
386
<xsl:if test="count($cols) >= $tdpos">
387
<xsl:variable name="col" select="$cols[$tdpos]"/>
388
<xsl:if test="$col/../self::mal:colgroup and
389
not($col/preceding-sibling::mal:col)">
390
<xsl:text>border-left-style: solid;</xsl:text>
396
<xsl:when test="$shaderow = 1 and $shadecol = 1">
397
<xsl:text>background-color: #d3d7cf;</xsl:text>
399
<xsl:when test="$shaderow = 1 or $shadecol = 1">
400
<xsl:text>background-color: #eeeeec;</xsl:text>
405
<xsl:if test="$style != ''">
406
<xsl:attribute name="style">
407
<xsl:value-of select="$style"/>
410
<xsl:if test="@colspan">
411
<xsl:attribute name="colspan">
412
<xsl:value-of select="@colspan"/>
415
<xsl:if test="@rowspan">
416
<xsl:attribute name="rowspan">
417
<xsl:value-of select="@rowspan"/>
420
<xsl:apply-templates mode="mal2html.block.mode"/>