Debian Codegraph @

xslt/docbook/html/db2html-table.xsl

raw
1 <?xml version='1.0' encoding='UTF-8'?><!-- -*- indent-tabs-mode: nil -*- -->
2 <!--
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
6 later version.
7
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
11 details.
12
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, see <http://www.gnu.org/licenses/>.
15 -->
16
17 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
18 xmlns:db="http://docbook.org/ns/docbook"
19 xmlns="http://www.w3.org/1999/xhtml"
20 exclude-result-prefixes="db"
21 version="1.0">
22
23 <!--!!==========================================================================
24 DocBook to HTML - Tables
25
26 REMARK: This needs lots of talk about CALS
27 -->
28
29
30 <!--**==========================================================================
31 db2html.row
32 Creates a `tr` element for a `row` element
33
34 [xsl:params]
35 $row: The `row` element to process
36 $colspecs: The `colspec` elements currently in scope
37 $spanspecs: The `spanspec` elements currently in scope
38 $colsep: Whether column separators are currently enabled
39 $rowsep: Whether column separators are currently enabled
40 $spanstr: The string representation of the row spans
41
42 FIXME
43 -->
44 <xsl:template name="db2html.row">
45 <xsl:param name="row" select="."/>
46 <xsl:param name="colspecs"/>
47 <xsl:param name="spanspecs"/>
48 <xsl:param name="colsep" select="''"/>
49 <xsl:param name="rowsep" select="''"/>
50 <xsl:param name="spanstr"/>
51 <tr>
52 <xsl:call-template name="html.class.attr">
53 <xsl:with-param name="node" select="$row"/>
54 <xsl:with-param name="class">
55 <xsl:if test="($row/../self::tbody and (count($row/preceding-sibling::row) mod 2 = 1)) or
56 ($row/../self::db:tbody and (count($row/preceding-sibling::db:row) mod 2 = 1))">
57 <xsl:text>shade</xsl:text>
58 </xsl:if>
59 </xsl:with-param>
60 </xsl:call-template>
61 <xsl:if test="$row/*[1]">
62 <xsl:call-template name="db2html.entry">
63 <xsl:with-param name="entry" select="$row/*[1]"/>
64 <xsl:with-param name="colspecs" select="$colspecs"/>
65 <xsl:with-param name="spanspecs" select="$spanspecs"/>
66 <xsl:with-param name="colsep" select="$colsep"/>
67 <xsl:with-param name="rowsep">
68 <xsl:choose>
69 <xsl:when test="$row/@rowsep">
70 <xsl:value-of select="$row/@rowsep"/>
71 </xsl:when>
72 <xsl:otherwise>
73 <xsl:value-of select="$rowsep"/>
74 </xsl:otherwise>
75 </xsl:choose>
76 </xsl:with-param>
77 <xsl:with-param name="spanstr" select="$spanstr"/>
78 </xsl:call-template>
79 </xsl:if>
80 </tr>
81 <xsl:variable name="following" select="$row/following-sibling::row[1] |
82 $row/following-sibling::db:row[1]"/>
83 <xsl:if test="$following">
84 <xsl:call-template name="db2html.row">
85 <xsl:with-param name="row" select="$following"/>
86 <xsl:with-param name="colspecs" select="$colspecs"/>
87 <xsl:with-param name="spanspecs" select="$spanspecs"/>
88 <xsl:with-param name="colsep" select="$colsep"/>
89 <xsl:with-param name="rowsep" select="$rowsep"/>
90 <xsl:with-param name="spanstr">
91 <xsl:call-template name="db2html.spanstr">
92 <xsl:with-param name="row" select="$row"/>
93 <xsl:with-param name="colspecs" select="$colspecs"/>
94 <xsl:with-param name="spanspecs" select="$spanspecs"/>
95 <xsl:with-param name="spanstr" select="$spanstr"/>
96 </xsl:call-template>
97 </xsl:with-param>
98 </xsl:call-template>
99 </xsl:if>
100 </xsl:template>
101
102
103 <!--**==========================================================================
104 db2html.entry
105 Creates a `td` element for an `entry` element
106
107 [xsl:params]
108 $entry: The `entry` element to process
109 $colspecs: The `colspec` elements currently in scope
110 $spanspecs: The `spanspec` elements currently in scope
111 $colsep: Whether column separators are currently enabled
112 $rowsep: Whether column separators are currently enabled
113 $colpos: The output column position currently being considered
114 $colnum: The actual column number of $entry
115 $spanstr: The string representation of the row spans
116
117 This template processes a single `entry` element and generates `td` elements
118 as needed. It then calls itself on the following `entry` element, adjusting
119 parameters as necessary. Under certain conditions, this template may not be
120 able to output a `td` element immediately. In these cases, it makes whatever
121 adjustments are needed and calls itself or {db2html.entry.implicit} (which,
122 in turn, calls this template again when it's finished).
123
124 Three parameters are used to determine whether a `td` element can be output.
125 The $spanstr parameter provides infomation about row spans in effect from
126 entries in previous rows; the $colpos parameter specifies which column we
127 would output to if we created a `td`; and the $colnum parameter specifies
128 which column this `entry` should be in, according to any relevant `colspec`
129 or `spanspec` elemets.
130
131 There are two conditions that cause this template not to output a `td` element
132 immediately: if the $spanstr parameter does not start with `0:`, and if the
133 $colpos parameter is less than the $colnum parameter.
134
135 The $spanstr parameter specifies the row spans in effect from entries in
136 previous rows. As this template iterates over the `entry` elements, it strips
137 off parts of $spanstr so that only the parts relevant to the `entry` are
138 present. If $spanstr does not start with `0:`, then an entry in a previous
139 row occupies this column position. In this case, that value is removed from
140 $spanstr, the $colpos parameter is incremented, and {db2html.entry} is
141 called again. Additionally, since {db2html.entry.colnum} doesn't consider
142 row spans, the $colnum parameter may be incremented as well.
143
144 If the $colpos parameter is less than the $colnum parameter, then the
145 document has skipped entries by explicitly referencing a column. This is
146 allowed in CALS tables, but not in HTML. To fill the blank spaces, we call
147 {db2html.entry.implicit}, which outputs an empty `td` element spanning as
148 many columns as necessary to fill in the blanks. The {db2html.entry.implicit}
149 template then calls this template again with appropriate parameter values.
150
151 When this template is finally able to output a `td` element, it calculates
152 appropriate values for the `style` and `class` attribute based on DocBook
153 attributes on the `entry`, the relevant `colspec` or `spanspec`, and any
154 relevant ancestor elements. It then calls itself on the following `entry`
155 element to output the next `td`.
156 -->
157 <xsl:template name="db2html.entry">
158 <xsl:param name="entry" select="."/>
159 <xsl:param name="colspecs"/>
160 <xsl:param name="spanspecs"/>
161 <xsl:param name="colsep" select="''"/>
162 <xsl:param name="rowsep" select="''"/>
163 <xsl:param name="colpos" select="1"/>
164 <xsl:param name="colnum">
165 <xsl:call-template name="db2html.entry.colnum">
166 <xsl:with-param name="entry" select="$entry"/>
167 <xsl:with-param name="colspecs" select="$colspecs"/>
168 <xsl:with-param name="spanspecs" select="$spanspecs"/>
169 <xsl:with-param name="colpos" select="$colpos"/>
170 </xsl:call-template>
171 </xsl:param>
172 <xsl:param name="spanstr"/>
173 <xsl:variable name="colspan">
174 <xsl:choose>
175 <xsl:when test="$entry/@spanname or $entry/@namest">
176 <xsl:call-template name="db2html.entry.colspan">
177 <xsl:with-param name="entry" select="$entry"/>
178 <xsl:with-param name="colspecs" select="$colspecs"/>
179 <xsl:with-param name="spanspecs" select="$spanspecs"/>
180 </xsl:call-template>
181 </xsl:when>
182 <xsl:otherwise>1</xsl:otherwise>
183 </xsl:choose>
184 </xsl:variable>
185 <xsl:choose>
186 <!-- Another entry has a rowspan that covers this column position -->
187 <xsl:when test="$spanstr != '' and not(starts-with($spanstr, '0:'))">
188 <xsl:choose>
189 <xsl:when test="$colnum = $colpos">
190 <xsl:call-template name="db2html.entry">
191 <xsl:with-param name="entry" select="$entry"/>
192 <xsl:with-param name="colspecs" select="$colspecs"/>
193 <xsl:with-param name="spanspecs" select="$spanspecs"/>
194 <xsl:with-param name="colsep" select="$colsep"/>
195 <xsl:with-param name="rowsep" select="$rowsep"/>
196 <xsl:with-param name="colpos" select="$colpos + 1"/>
197 <xsl:with-param name="colnum" select="$colnum + 1"/>
198 <xsl:with-param name="colspan" select="$colspan"/>
199 <xsl:with-param name="spanstr" select="substring-after($spanstr, ':')"/>
200 </xsl:call-template>
201 </xsl:when>
202 <xsl:otherwise>
203 <xsl:call-template name="db2html.entry">
204 <xsl:with-param name="entry" select="$entry"/>
205 <xsl:with-param name="colspecs" select="$colspecs"/>
206 <xsl:with-param name="spanspecs" select="$spanspecs"/>
207 <xsl:with-param name="colsep" select="$colsep"/>
208 <xsl:with-param name="rowsep" select="$rowsep"/>
209 <xsl:with-param name="colpos" select="$colpos + 1"/>
210 <xsl:with-param name="colnum" select="$colnum"/>
211 <xsl:with-param name="colspan" select="$colspan"/>
212 <xsl:with-param name="spanstr" select="substring-after($spanstr, ':')"/>
213 </xsl:call-template>
214 </xsl:otherwise>
215 </xsl:choose>
216 </xsl:when>
217 <!-- We need to insert implicit td elements to cover blank space -->
218 <xsl:when test="$colnum &gt; $colpos">
219 <xsl:call-template name="db2html.entry.implicit">
220 <xsl:with-param name="entry" select="$entry"/>
221 <xsl:with-param name="colspecs" select="$colspecs"/>
222 <xsl:with-param name="spanspecs" select="$spanspecs"/>
223 <xsl:with-param name="colsep" select="$colsep"/>
224 <xsl:with-param name="rowsep" select="$rowsep"/>
225 <xsl:with-param name="colpos" select="$colpos"/>
226 <xsl:with-param name="colnum" select="$colnum"/>
227 <xsl:with-param name="colspan" select="1"/>
228 <xsl:with-param name="spanstr" select="$spanstr"/>
229 </xsl:call-template>
230 </xsl:when>
231 <!-- We can output the td for this entry -->
232 <xsl:otherwise>
233 <xsl:if test="$colnum &lt; $colpos">
234 <xsl:message>Column positions are not aligned.</xsl:message>
235 </xsl:if>
236 <xsl:variable name="element">
237 <xsl:choose>
238 <xsl:when test="$entry/../../self::thead or $entry/../../self::tfoot">th</xsl:when>
239 <xsl:when test="$entry/../../self::db:thead or $entry/../../self::db:tfoot">th</xsl:when>
240 <xsl:otherwise>td</xsl:otherwise>
241 </xsl:choose>
242 </xsl:variable>
243 <xsl:variable name="rowspan">
244 <xsl:choose>
245 <xsl:when test="$entry/@morerows">
246 <xsl:value-of select="$entry/@morerows + 1"/>
247 </xsl:when>
248 <xsl:otherwise>
249 <xsl:value-of select="1"/>
250 </xsl:otherwise>
251 </xsl:choose>
252 </xsl:variable>
253 <xsl:variable name="align">
254 <xsl:choose>
255 <xsl:when test="$entry/@align">
256 <xsl:value-of select="$entry/@align"/>
257 </xsl:when>
258 <xsl:when test="$colspecs[@colname = $entry/@colname]/@align">
259 <xsl:value-of select="$colspecs[@colname = $entry/@colname]/@align"/>
260 </xsl:when>
261 <xsl:when test="$colspecs[@colname = $entry/@namest]/@align">
262 <xsl:value-of select="$colspecs[@colname = $entry/@namest]/@align"/>
263 </xsl:when>
264 <xsl:when test="$spanspecs[@spanname = $entry/@spanname]/@align">
265 <xsl:value-of select="$spanspecs[@spanname = $entry/@spanname]/@align"/>
266 </xsl:when>
267 <xsl:when test="$colspecs[position() = $colnum]/@align">
268 <xsl:value-of select="$colspecs[position() = $colnum]/@align"/>
269 </xsl:when>
270 <xsl:when test="$entry/../../../@align">
271 <xsl:value-of select="$entry/../../../@align"/>
272 </xsl:when>
273 </xsl:choose>
274 </xsl:variable>
275 <xsl:variable name="valign">
276 <xsl:choose>
277 <xsl:when test="$entry/@valign">
278 <xsl:value-of select="$entry/@valign"/>
279 </xsl:when>
280 <xsl:when test="$colspecs[@colname = $entry/@colname]/@valign">
281 <xsl:value-of
282 select="$colspecs[@colname = $entry/@colname]/@valign"/>
283 </xsl:when>
284 <xsl:when test="$colspecs[@colname = $entry/@namest]/@valign">
285 <xsl:value-of select="$colspecs[@colname = $entry/@namest]/@valign"/>
286 </xsl:when>
287 <xsl:when test="$spanspecs[@spanname = $entry/@spanname]/@valign">
288 <xsl:value-of select="$spanspecs[@spanname = $entry/@spanname]/@valign"/>
289 </xsl:when>
290 <xsl:when test="$colspecs[position() = $colnum]/@valign">
291 <xsl:value-of select="$colspecs[position() = $colnum]/@valign"/>
292 </xsl:when>
293 <xsl:when test="$entry/../@valign">
294 <xsl:value-of select="$entry/../@valign"/>
295 </xsl:when>
296 <xsl:when test="$entry/../../@valign">
297 <xsl:value-of select="$entry/../../@valign"/>
298 </xsl:when>
299 </xsl:choose>
300 </xsl:variable>
301 <xsl:variable name="char">
302 <xsl:choose>
303 <xsl:when test="$align != 'char'"/>
304 <xsl:when test="$entry/@char">
305 <xsl:value-of select="$entry/@char"/>
306 </xsl:when>
307 <xsl:when test="$colspecs[@colname = $entry/@colname]/@char">
308 <xsl:value-of select="$colspecs[@colname = $entry/@colname]/@char"/>
309 </xsl:when>
310 <xsl:when test="$colspecs[@colname = $entry/@namest]/@char">
311 <xsl:value-of select="$colspecs[@colname = $entry/@namest]/@char"/>
312 </xsl:when>
313 <xsl:when test="$spanspecs[@spanname = $entry/@spanname]/@char">
314 <xsl:value-of select="$spanspecs[@spanname = $entry/@spanname]/@char"/>
315 </xsl:when>
316 <xsl:when test="$colspecs[position() = $colnum]/@char">
317 <xsl:value-of select="$colspecs[position() = $colnum]/@char"/>
318 </xsl:when>
319 <xsl:when test="$entry/../../../@char">
320 <xsl:value-of select="$entry/../../@char"/>
321 </xsl:when>
322 </xsl:choose>
323 </xsl:variable>
324 <xsl:variable name="charoff">
325 <xsl:choose>
326 <xsl:when test="$align != 'char'"/>
327 <xsl:when test="$entry/@charoff">
328 <xsl:value-of select="$entry/@charoff"/>
329 </xsl:when>
330 <xsl:when test="$colspecs[@colname = $entry/@colname]/@charoff">
331 <xsl:value-of select="$colspecs[@colname = $entry/@colname]/@charoff"/>
332 </xsl:when>
333 <xsl:when test="$colspecs[@colname = $entry/@namest]/@charoff">
334 <xsl:value-of select="$colspecs[@colname = $entry/@namest]/@charoff"/>
335 </xsl:when>
336 <xsl:when test="$spanspecs[@spanname = $entry/@spanname]/@charoff">
337 <xsl:value-of select="$spanspecs[@spanname = $entry/@spanname]/@charoff"/>
338 </xsl:when>
339 <xsl:when test="$colspecs[position() = $colnum]/@charoff">
340 <xsl:value-of select="$colspecs[position() = $colnum]/@charoff"/>
341 </xsl:when>
342 <xsl:when test="$entry/../../../@charoff">
343 <xsl:value-of select="$entry/../../@charoff"/>
344 </xsl:when>
345 </xsl:choose>
346 </xsl:variable>
347 <xsl:variable name="style">
348 <xsl:if test="$align != ''">
349 <xsl:value-of select="concat('text-align: ', $align, ';')"/>
350 </xsl:if>
351 <xsl:if test="$valign != ''">
352 <xsl:value-of select="concat('vertical-align: ', $valign, ';')"/>
353 </xsl:if>
354 </xsl:variable>
355 <xsl:variable name="class">
356 <!-- td-colsep: whether to show a column separator -->
357 <xsl:choose>
358 <!-- FIXME: we need to handle @cols better -->
359 <xsl:when test="number($colpos) + number($colspan) &gt; number($entry/ancestor::tgroup[1]/@cols)"/>
360 <xsl:when test="number($colpos) + number($colspan) &gt; number($entry/ancestor::db:tgroup[1]/@cols)"/>
361 <xsl:when test="$entry/@colsep">
362 <xsl:if test="$entry/@colsep = '1'">
363 <xsl:text> td-colsep</xsl:text>
364 </xsl:if>
365 </xsl:when>
366 <xsl:when test="$entry/@spanname and $spanspecs[@spanname = $entry/@spanname]/@colsep">
367 <xsl:if test="$spanspecs[@spanname = $entry/@spanname]/@colsep = '1'">
368 <xsl:text> td-colsep</xsl:text>
369 </xsl:if>
370 </xsl:when>
371 <xsl:when test="$entry/@colname and $colspecs[@colname = $entry/@colname]/@colsep">
372 <xsl:if test="$colspecs[@colname = $entry/@colname]/@colsep = '1'">
373 <xsl:text> td-colsep</xsl:text>
374 </xsl:if>
375 </xsl:when>
376 <xsl:when test="$entry/@nameend and $colspecs[@colname = $entry/@nameend]/@colsep">
377 <xsl:if test="$colspecs[@colname = $entry/@nameend]/@colsep = '1'">
378 <xsl:text> td-colsep</xsl:text>
379 </xsl:if>
380 </xsl:when>
381 <xsl:when test="$colspecs[position() = $colnum]/@colsep">
382 <xsl:if test="$colspecs[position() = $colnum]/@colsep = '1'">
383 <xsl:text> td-colsep</xsl:text>
384 </xsl:if>
385 </xsl:when>
386 <xsl:when test="$colsep = '0'"/>
387 <xsl:otherwise>
388 <xsl:text> td-colsep</xsl:text>
389 </xsl:otherwise>
390 </xsl:choose>
391 <!-- td-rowsep: whether to show a row separator -->
392 <xsl:choose>
393 <xsl:when test="(count($entry/../following-sibling::row) +
394 count($entry/../following-sibling::db:row)) &lt;
395 number($rowspan)"/>
396 <xsl:when test="$entry/@rowsep">
397 <xsl:if test="$entry/@rowsep = '1'">
398 <xsl:text> td-rowsep</xsl:text>
399 </xsl:if>
400 </xsl:when>
401 <xsl:when test="$entry/@spanname and $spanspecs[@spanname = $entry/@spanname]/@rowsep">
402 <xsl:if test="$spanspecs[@spanname = $entry/@spanname]/@rowsep = '1'">
403 <xsl:text> td-rowsep</xsl:text>
404 </xsl:if>
405 </xsl:when>
406 <xsl:when test="$entry/@colname and $colspecs[@colname = $entry/@colname]/@rowsep">
407 <xsl:if test="$colspecs[@colname = $entry/@colname]/@rowsep = '1'">
408 <xsl:text> td-rowsep</xsl:text>
409 </xsl:if>
410 </xsl:when>
411 <xsl:when test="$entry/@nameend and $colspecs[@colname = $entry/@nameend]/@rowsep">
412 <xsl:if test="$colspecs[@colname = $entry/@nameend]/@rowsep = '1'">
413 <xsl:text> td-rowsep</xsl:text>
414 </xsl:if>
415 </xsl:when>
416 <xsl:when test="$colspecs[position() = $colnum]/@rowsep">
417 <xsl:if test="$colspecs[position() = $colnum]/@rowsep = '1'">
418 <xsl:text> td-rowsep</xsl:text>
419 </xsl:if>
420 </xsl:when>
421 <xsl:when test="$rowsep = '1'">
422 <xsl:text> td-rowsep</xsl:text>
423 </xsl:when>
424 </xsl:choose>
425 </xsl:variable>
426 <!-- Finally, output the td or th element -->
427 <xsl:element name="{$element}" namespace="{$html.namespace}">
428 <xsl:call-template name="html.lang.attrs">
429 <xsl:with-param name="parent" select=".."/>
430 </xsl:call-template>
431 <xsl:call-template name="html.class.attr">
432 <xsl:with-param name="node" select="$entry"/>
433 <xsl:with-param name="class" select="$class"/>
434 </xsl:call-template>
435 <xsl:if test="$style != ''">
436 <xsl:attribute name="style">
437 <xsl:value-of select="normalize-space($style)"/>
438 </xsl:attribute>
439 </xsl:if>
440 <xsl:if test="number($rowspan) &gt; 1">
441 <xsl:attribute name="rowspan">
442 <xsl:value-of select="$rowspan"/>
443 </xsl:attribute>
444 </xsl:if>
445 <xsl:if test="$colspan &gt; 1">
446 <xsl:attribute name="colspan">
447 <xsl:value-of select="$colspan"/>
448 </xsl:attribute>
449 </xsl:if>
450 <xsl:if test="$char != ''">
451 <xsl:attribute name="char">
452 <xsl:value-of select="$char"/>
453 </xsl:attribute>
454 </xsl:if>
455 <xsl:if test="$charoff != ''">
456 <xsl:attribute name="charoff">
457 <xsl:value-of select="$charoff"/>
458 </xsl:attribute>
459 </xsl:if>
460 <xsl:choose>
461 <xsl:when test="$entry/self::entrytbl">
462 <xsl:apply-templates select="$entry"/>
463 </xsl:when>
464 <xsl:when test="$entry/self::db:entrytbl">
465 <xsl:apply-templates select="$entry"/>
466 </xsl:when>
467 <xsl:otherwise>
468 <xsl:apply-templates select="$entry/node()"/>
469 </xsl:otherwise>
470 </xsl:choose>
471 </xsl:element>
472 <!-- And process the next entry -->
473 <xsl:variable name="following" select="$entry/following-sibling::*[1]"/>
474 <xsl:if test="$following">
475 <xsl:call-template name="db2html.entry">
476 <xsl:with-param name="entry" select="$following"/>
477 <xsl:with-param name="colspecs" select="$colspecs"/>
478 <xsl:with-param name="spanspecs" select="$spanspecs"/>
479 <xsl:with-param name="colsep" select="$colsep"/>
480 <xsl:with-param name="rowsep" select="$rowsep"/>
481 <xsl:with-param name="colpos" select="$colpos + $colspan"/>
482 <xsl:with-param name="spanstr">
483 <xsl:call-template name="db2html.spanstr.pop">
484 <xsl:with-param name="colspecs" select="$colspecs"/>
485 <xsl:with-param name="spanspecs" select="$spanspecs"/>
486 <xsl:with-param name="colspan" select="$colspan"/>
487 <xsl:with-param name="spanstr" select="$spanstr"/>
488 </xsl:call-template>
489 </xsl:with-param>
490 </xsl:call-template>
491 </xsl:if>
492 </xsl:otherwise>
493 </xsl:choose>
494 </xsl:template>
495
496
497 <!--**==========================================================================
498 db2html.entry.implicit
499 Creates an implicit `td` element to fill up unoccupied columns
500
501 [xsl:params]
502 $entry: The `entry` element currently being processed
503 $colspecs: The `colspec` elements currently in scope
504 $spanspecs: The `spanspec` elements currently in scope
505 $colsep: Whether column separators are currently enabled
506 $rowsep: Whether column separators are currently enabled
507 $colpos: The output column position currently being considered
508 $colnum: The actual column number of $entry
509 $colspan: How many columns the implicit `td` currently spans
510 $spanstr: The string representation of the row spans
511
512 CALS tables in DocBook don't need to have `entry` elements for each column
513 in each row, even when the column is not covered by a row-spanning entry from
514 a previous row. An `entry` can explicitly specify which column it's in, and
515 any previous unfilled columns are considered blank. Since HTML tables don't
516 have this mechanism, we have to insert blank `td` elements to fill the gaps.
517
518 When {db2html.entry} detects a blank entry, it will call this template with
519 the approprite parameters. This template then calls itself recursively, each
520 time adjusting the $colpos, $colspan, and $spanstr parameters, until it
521 comes across the last column that needs to be filled. It then outputs a `td`
522 element with an appropriate `colspan` attribute.
523
524 Finally, this template calls {db2html.entry} again on $entry. With the
525 values of $colpos and $spanstr suitably adjusted, that template is then
526 able to output the `td` for the `entry` element.
527 -->
528 <xsl:template name="db2html.entry.implicit">
529 <xsl:param name="entry"/>
530 <xsl:param name="colspecs"/>
531 <xsl:param name="spanspecs"/>
532 <xsl:param name="colsep" select="''"/>
533 <xsl:param name="rowsep" select="''"/>
534 <xsl:param name="colpos" select="1"/>
535 <xsl:param name="colnum">
536 <xsl:call-template name="db2html.entry.colnum">
537 <xsl:with-param name="entry" select="$entry"/>
538 <xsl:with-param name="colspecs" select="$colspecs"/>
539 <xsl:with-param name="spanspecs" select="$spanspecs"/>
540 <xsl:with-param name="colpos" select="$colpos"/>
541 </xsl:call-template>
542 </xsl:param>
543 <xsl:param name="colspan"/>
544 <xsl:param name="spanstr"/>
545
546 <xsl:variable name="element">
547 <xsl:choose>
548 <xsl:when test="$entry/../../self::thead or $entry/../../self::tfoot">th</xsl:when>
549 <xsl:when test="$entry/../../self::db:thead or $entry/../../self::db:tfoot">th</xsl:when>
550 <xsl:otherwise>td</xsl:otherwise>
551 </xsl:choose>
552 </xsl:variable>
553 <xsl:variable name="class">
554 <xsl:if test="$colsep != '0'">
555 <xsl:text> td-colsep</xsl:text>
556 </xsl:if>
557 <xsl:if test="($rowsep = '1' and $entry/../following-sibling::row) or
558 ($rowsep = '1' and $entry/../following-sibling::db:row)">
559 <xsl:text> td-rowsep</xsl:text>
560 </xsl:if>
561 </xsl:variable>
562
563 <xsl:choose>
564 <xsl:when test="$spanstr != '' and not(starts-with($spanstr, '0:'))">
565 <xsl:element name="{$element}" namespace="{$html.namespace}">
566 <xsl:if test="$class != ''">
567 <xsl:attribute name="class">
568 <xsl:value-of select="normalize-space($class)"/>
569 </xsl:attribute>
570 </xsl:if>
571 <xsl:attribute name="colspan">
572 <xsl:value-of select="$colspan - 1"/>
573 </xsl:attribute>
574 <xsl:text>&#160;</xsl:text>
575 </xsl:element>
576 <xsl:call-template name="db2html.entry">
577 <xsl:with-param name="entry" select="$entry"/>
578 <xsl:with-param name="colspecs" select="$colspecs"/>
579 <xsl:with-param name="spanspecs" select="$spanspecs"/>
580 <xsl:with-param name="colsep" select="$colsep"/>
581 <xsl:with-param name="rowsep" select="$rowsep"/>
582 <xsl:with-param name="colpos" select="$colpos"/>
583 <xsl:with-param name="colnum" select="$colnum"/>
584 <xsl:with-param name="spanstr" select="$spanstr"/>
585 </xsl:call-template>
586 </xsl:when>
587 <xsl:when test="$colnum - $colpos = 1">
588 <xsl:element name="{$element}" namespace="{$html.namespace}">
589 <xsl:if test="$class != ''">
590 <xsl:attribute name="class">
591 <xsl:value-of select="normalize-space($class)"/>
592 </xsl:attribute>
593 </xsl:if>
594 <xsl:attribute name="colspan">
595 <xsl:value-of select="$colspan"/>
596 </xsl:attribute>
597 <xsl:text>&#160;</xsl:text>
598 </xsl:element>
599 <xsl:call-template name="db2html.entry">
600 <xsl:with-param name="entry" select="$entry"/>
601 <xsl:with-param name="colspecs" select="$colspecs"/>
602 <xsl:with-param name="spanspecs" select="$spanspecs"/>
603 <xsl:with-param name="colsep" select="$colsep"/>
604 <xsl:with-param name="rowsep" select="$rowsep"/>
605 <xsl:with-param name="colpos" select="$colpos + 1"/>
606 <xsl:with-param name="colnum" select="$colnum"/>
607 <xsl:with-param name="spanstr" select="substring-after($spanstr, ':')"/>
608 </xsl:call-template>
609 </xsl:when>
610 <xsl:otherwise>
611 <xsl:call-template name="db2html.entry.implicit">
612 <xsl:with-param name="entry" select="$entry"/>
613 <xsl:with-param name="colspecs" select="$colspecs"/>
614 <xsl:with-param name="spanspecs" select="$spanspecs"/>
615 <xsl:with-param name="colsep" select="$colsep"/>
616 <xsl:with-param name="rowsep" select="$rowsep"/>
617 <xsl:with-param name="colpos" select="$colpos + 1"/>
618 <xsl:with-param name="colnum" select="$colnum"/>
619 <xsl:with-param name="colspan" select="$colspan + 1"/>
620 <xsl:with-param name="spanstr" select="substring-after($spanstr, ':')"/>
621 </xsl:call-template>
622 </xsl:otherwise>
623 </xsl:choose>
624 </xsl:template>
625
626
627 <!--**==========================================================================
628 db2html.entry.colnum
629 Calculates the actual column number for an `entry` element
630
631 [xsl:params]
632 $entry: The `entry` element to process
633 $colspecs: The `colspec` elements currently in scope
634 $spanspecs: The `spanspec` elements currently in scope
635 $colpos: The column position, as passed by the preceding `entry`
636
637 FIXME
638 -->
639 <xsl:template name="db2html.entry.colnum">
640 <xsl:param name="entry" select="."/>
641 <xsl:param name="colspecs"/>
642 <xsl:param name="spanspecs"/>
643 <xsl:param name="colpos" select="0"/>
644 <xsl:choose>
645 <xsl:when test="$entry/@spanname">
646 <xsl:variable name="spanspec"
647 select="$spanspecs[@spanname = $entry/@spanname]"/>
648 <xsl:variable name="colspec"
649 select="$colspecs[@colname = $spanspec/@namest]"/>
650 <xsl:call-template name="db2html.colspec.colnum">
651 <xsl:with-param name="colspec" select="$colspec"/>
652 <xsl:with-param name="colspecs" select="$colspecs"/>
653 <xsl:with-param name="spanspecs" select="$spanspecs"/>
654 </xsl:call-template>
655 </xsl:when>
656 <xsl:when test="$entry/@colname">
657 <xsl:variable name="colspec"
658 select="$colspecs[@colname = $entry/@colname]"/>
659 <xsl:call-template name="db2html.colspec.colnum">
660 <xsl:with-param name="colspec" select="$colspec"/>
661 <xsl:with-param name="colspecs" select="$colspecs"/>
662 <xsl:with-param name="spanspecs" select="$spanspecs"/>
663 </xsl:call-template>
664 </xsl:when>
665 <xsl:when test="$entry/@namest">
666 <xsl:variable name="colspec"
667 select="$colspecs[@colname = $entry/@namest]"/>
668 <xsl:call-template name="db2html.colspec.colnum">
669 <xsl:with-param name="colspec" select="$colspec"/>
670 <xsl:with-param name="colspecs" select="$colspecs"/>
671 <xsl:with-param name="spanspecs" select="$spanspecs"/>
672 </xsl:call-template>
673 </xsl:when>
674 <xsl:otherwise>
675 <xsl:value-of select="$colpos"/>
676 </xsl:otherwise>
677 </xsl:choose>
678 </xsl:template>
679
680
681 <!--**==========================================================================
682 db2html.colspec.colnum
683 Calculates the column number for a `colspec` element
684
685 [xsl:params]
686 $colspec: The `colspec` element to process
687 $colspecs: The `colspec` elements currently in scope
688 $spanspecs: The `spanspec` elements currently in scope
689
690 FIXME
691 -->
692 <xsl:template name="db2html.colspec.colnum">
693 <xsl:param name="colspec" select="."/>
694 <xsl:param name="colspecs"/>
695 <xsl:param name="spanspecs"/>
696 <xsl:choose>
697 <xsl:when test="$colspec/@colnum">
698 <xsl:value-of select="$colspec/@colnum"/>
699 </xsl:when>
700 <xsl:when test="$colspec/preceding-sibling::colspec or
701 $colspec/preceding-sibling::db:colspec">
702 <xsl:variable name="prec.colspec.colnum">
703 <xsl:call-template name="db2html.colspec.colnum">
704 <xsl:with-param name="colspec"
705 select="$colspec/preceding-sibling::colspec[1] |
706 $colspec/preceding-sibling::db:colspec[1]"/>
707 <xsl:with-param name="colspecs" select="$colspecs"/>
708 <xsl:with-param name="spanspecs" select="$spanspecs"/>
709 </xsl:call-template>
710 </xsl:variable>
711 <xsl:value-of select="$prec.colspec.colnum + 1"/>
712 </xsl:when>
713 <xsl:otherwise>1</xsl:otherwise>
714 </xsl:choose>
715 </xsl:template>
716
717
718 <!--**==========================================================================
719 db2html.entry.colspan
720 Calculates the `colspan` for an `entry` element
721
722 [xsl:params]
723 $entry: The `entry` element to process
724 $colspecs: The `colspec` elements currently in scope
725 $spanspecs: The `spanspec` elements currently in scope
726
727 This template calculates how many columns an `entry` element should span.
728 In CALS tables, column spanning is done by specifying starting and ending
729 `colspec` elements, or by specifying a `spanspec` element which specifies
730 starting and ending `colspec` elements.
731 -->
732 <xsl:template name="db2html.entry.colspan">
733 <xsl:param name="entry" select="."/>
734 <xsl:param name="colspecs"/>
735 <xsl:param name="spanspecs"/>
736 <xsl:variable name="namest">
737 <xsl:choose>
738 <xsl:when test="$entry/@spanname">
739 <xsl:value-of
740 select="$spanspecs[@spanname = $entry/@spanname]/@namest"/>
741 </xsl:when>
742 <xsl:otherwise>
743 <xsl:value-of select="$entry/@namest"/>
744 </xsl:otherwise>
745 </xsl:choose>
746 </xsl:variable>
747 <xsl:variable name="nameend">
748 <xsl:choose>
749 <xsl:when test="$entry/@spanname">
750 <xsl:value-of
751 select="$spanspecs[@spanname = $entry/@spanname]/@nameend"/>
752 </xsl:when>
753 <xsl:otherwise>
754 <xsl:value-of select="$entry/@nameend"/>
755 </xsl:otherwise>
756 </xsl:choose>
757 </xsl:variable>
758 <xsl:variable name="colnumst">
759 <xsl:call-template name="db2html.colspec.colnum">
760 <xsl:with-param name="colspec" select="$colspecs[@colname = $namest]"/>
761 <xsl:with-param name="colspecs" select="$colspecs"/>
762 <xsl:with-param name="spanspecs" select="$spanspecs"/>
763 </xsl:call-template>
764 </xsl:variable>
765 <xsl:variable name="colnumend">
766 <xsl:call-template name="db2html.colspec.colnum">
767 <xsl:with-param name="colspec" select="$colspecs[@colname = $nameend]"/>
768 <xsl:with-param name="colspecs" select="$colspecs"/>
769 <xsl:with-param name="spanspecs" select="$spanspecs"/>
770 </xsl:call-template>
771 </xsl:variable>
772 <xsl:choose>
773 <xsl:when test="$namest = '' or $nameend = ''">1</xsl:when>
774 <xsl:when test="$colnumend &gt; $colnumst">
775 <xsl:value-of select="$colnumend - $colnumst + 1"/>
776 </xsl:when>
777 <xsl:otherwise>
778 <xsl:value-of select="$colnumst - $colnumend + 1"/>
779 </xsl:otherwise>
780 </xsl:choose>
781 </xsl:template>
782
783
784
785
786 <!-- FIXME below -->
787
788
789 <!--**==========================================================================
790 db2html.spanstr
791 Generates a string specifying the row spans in effect
792
793 [xsl:params]
794 $colspecs: The `colspec` elements currently in scope
795 $spanspecs: The `spanspec` elements currently in scope
796 $spanstr: The $spanstr parameter used by the previous row
797
798 REMARK: This template needs to be explained in detail, but I forgot how it works.
799 -->
800 <xsl:template name="db2html.spanstr">
801 <xsl:param name="row" select="."/>
802 <xsl:param name="entry" select="$row/*[1]"/>
803 <xsl:param name="colspecs"/>
804 <xsl:param name="spanspecs"/>
805 <xsl:param name="spanstr"/>
806 <xsl:param name="colpos" select="1"/>
807 <xsl:param name="colnum">
808 <xsl:call-template name="db2html.entry.colnum">
809 <xsl:with-param name="entry" select="$entry"/>
810 <xsl:with-param name="colspecs" select="$colspecs"/>
811 <xsl:with-param name="spanspecs" select="$spanspecs"/>
812 </xsl:call-template>
813 </xsl:param>
814 <xsl:param name="colspan">
815 <xsl:choose>
816 <xsl:when test="$entry/@spanname or $entry/@namest">
817 <xsl:call-template name="db2html.entry.colspan">
818 <xsl:with-param name="colspecs" select="$colspecs"/>
819 <xsl:with-param name="spanspecs" select="$spanspecs"/>
820 <xsl:with-param name="entry" select="$entry"/>
821 </xsl:call-template>
822 </xsl:when>
823 <xsl:otherwise>1</xsl:otherwise>
824 </xsl:choose>
825 </xsl:param>
826 <xsl:variable name="following.spanstr">
827 <xsl:call-template name="db2html.spanstr.pop">
828 <xsl:with-param name="colspecs" select="$colspecs"/>
829 <xsl:with-param name="spanspecs" select="$spanspecs"/>
830 <xsl:with-param name="colnum" select="$colnum"/>
831 <xsl:with-param name="colspan" select="$colspan"/>
832 <xsl:with-param name="spanstr" select="$spanstr"/>
833 </xsl:call-template>
834 </xsl:variable>
835 <xsl:choose>
836 <xsl:when test="$spanstr != '' and not(starts-with($spanstr, '0:'))">
837 <xsl:value-of select="substring-before($spanstr, ':') - 1"/>
838 <xsl:text>:</xsl:text>
839 <xsl:call-template name="db2html.spanstr">
840 <xsl:with-param name="row" select="$row"/>
841 <xsl:with-param name="entry" select="$entry"/>
842 <xsl:with-param name="colspecs" select="$colspecs"/>
843 <xsl:with-param name="spanspecs" select="$spanspecs"/>
844 <xsl:with-param name="spanstr" select="substring-after($spanstr, ':')"/>
845 <xsl:with-param name="colpos" select="$colpos + 1"/>
846 <xsl:with-param name="colnum" select="$colnum"/>
847 <xsl:with-param name="colspan" select="$colspan"/>
848 </xsl:call-template>
849 </xsl:when>
850 <xsl:when test="$colnum &gt; $colpos">
851 <xsl:text>0:</xsl:text>
852 <xsl:call-template name="db2html.spanstr">
853 <xsl:with-param name="row" select="$row"/>
854 <xsl:with-param name="entry" select="$entry"/>
855 <xsl:with-param name="colspecs" select="$colspecs"/>
856 <xsl:with-param name="spanspecs" select="$spanspecs"/>
857 <xsl:with-param name="spanstr" select="$following.spanstr"/>
858 <xsl:with-param name="colpos" select="$colpos + $colspan"/>
859 <xsl:with-param name="colnum" select="$colnum"/>
860 <xsl:with-param name="colspan" select="$colspan"/>
861 </xsl:call-template>
862 </xsl:when>
863 <xsl:otherwise>
864 <xsl:call-template name="utils.repeat_string">
865 <xsl:with-param name="string">
866 <xsl:choose>
867 <xsl:when test="$entry/@morerows">
868 <xsl:value-of select="$entry/@morerows"/>
869 </xsl:when>
870 <xsl:otherwise>0</xsl:otherwise>
871 </xsl:choose>
872 <xsl:text>:</xsl:text>
873 </xsl:with-param>
874 <xsl:with-param name="number" select="$colspan"/>
875 </xsl:call-template>
876 <xsl:choose>
877 <xsl:when test="$entry/following-sibling::*[1]">
878 <xsl:call-template name="db2html.spanstr">
879 <xsl:with-param name="row" select="$row"/>
880 <xsl:with-param name="entry" select="$entry/following-sibling::*[1]"/>
881 <xsl:with-param name="colspecs" select="$colspecs"/>
882 <xsl:with-param name="spanspecs" select="$spanspecs"/>
883 <xsl:with-param name="spanstr" select="$following.spanstr"/>
884 <xsl:with-param name="colpos" select="$colpos + $colspan"/>
885 </xsl:call-template>
886 </xsl:when>
887 <xsl:when test="$following.spanstr != ''">
888 <xsl:call-template name="db2html.spanstr.decrement">
889 <xsl:with-param name="spanstr" select="$following.spanstr"/>
890 </xsl:call-template>
891 </xsl:when>
892 </xsl:choose>
893 </xsl:otherwise>
894 </xsl:choose>
895 </xsl:template>
896
897
898 <!--**==========================================================================
899 db2html.spanstr.pop
900 Calculates the remaining spans after an `entry` element
901
902 [xsl:params]
903 $colspecs: The `colspec` elements currently in scope
904 $spanspecs: The `spanspec` elements currently in scope
905 $colspan: The number of columns to pop
906 $spanstr: The string representation of the column spans
907
908 REMARK: This template needs to be explained in detail, but I forgot how it works.
909 -->
910 <xsl:template name="db2html.spanstr.pop">
911 <xsl:param name="colspecs"/>
912 <xsl:param name="spanspecs"/>
913 <xsl:param name="colspan" select="1"/>
914 <xsl:param name="spanstr" select="''"/>
915 <xsl:choose>
916 <xsl:when test="$colspan &gt; 0">
917 <xsl:call-template name="db2html.spanstr.pop">
918 <xsl:with-param name="colspecs" select="$colspecs"/>
919 <xsl:with-param name="spanspecs" select="$spanspecs"/>
920 <xsl:with-param name="colspan" select="$colspan - 1"/>
921 <xsl:with-param name="spanstr" select="substring-after($spanstr, ':')"/>
922 </xsl:call-template>
923 </xsl:when>
924 <xsl:otherwise>
925 <xsl:value-of select="$spanstr"/>
926 </xsl:otherwise>
927 </xsl:choose>
928 </xsl:template>
929
930 <!--#* db2html.spanstr.decrement -->
931 <xsl:template name="db2html.spanstr.decrement">
932 <xsl:param name="spanstr"/>
933 <xsl:if test="$spanstr != ''">
934 <xsl:choose>
935 <xsl:when test="starts-with($spanstr, '0:')">
936 <xsl:text>0:</xsl:text>
937 </xsl:when>
938 <xsl:otherwise>
939 <xsl:variable name="span" select="substring-before($spanstr, ':')"/>
940 <xsl:value-of select="$span - 1"/>
941 <xsl:text>:</xsl:text>
942 </xsl:otherwise>
943 </xsl:choose>
944 <xsl:call-template name="db2html.spanstr.decrement">
945 <xsl:with-param name="spanstr" select="substring-after($spanstr, ':')"/>
946 </xsl:call-template>
947 </xsl:if>
948 </xsl:template>
949
950 <!-- = entrytbl = -->
951 <xsl:template match="entrytbl | db:entrytbl">
952 <xsl:variable name="colsep">
953 <xsl:choose>
954 <xsl:when test="@colsep">
955 <xsl:value-of select="string(@colsep)"/>
956 </xsl:when>
957 <xsl:when test="not(.//*[@colsep][1])"/>
958 <xsl:otherwise>
959 <xsl:text>0</xsl:text>
960 </xsl:otherwise>
961 </xsl:choose>
962 </xsl:variable>
963 <xsl:variable name="rowsep">
964 <xsl:choose>
965 <xsl:when test="@rowsep">
966 <xsl:value-of select="string(@rowsep)"/>
967 </xsl:when>
968 <xsl:when test="not(//*[@rowsep][1])"/>
969 <xsl:otherwise>
970 <xsl:text>0</xsl:text>
971 </xsl:otherwise>
972 </xsl:choose>
973 </xsl:variable>
974 <table>
975 <xsl:call-template name="html.class.attr"/>
976 <xsl:call-template name="html.lang.attrs"/>
977 <xsl:apply-templates select="thead | db:thead">
978 <xsl:with-param name="colspecs" select="colspec | db:colspec"/>
979 <xsl:with-param name="spanspecs" select="spanspec | db:spanspec"/>
980 <xsl:with-param name="colsep" select="$colsep"/>
981 <xsl:with-param name="rowsep" select="$rowsep"/>
982 </xsl:apply-templates>
983 <xsl:apply-templates select="tbody | db:tbody">
984 <xsl:with-param name="colspecs" select="colspec | db:colspec"/>
985 <xsl:with-param name="spanspecs" select="spanspec | db:spanspec"/>
986 <xsl:with-param name="colsep" select="$colsep"/>
987 <xsl:with-param name="rowsep" select="$rowsep"/>
988 </xsl:apply-templates>
989 </table>
990 </xsl:template>
991
992 <!-- = table = -->
993 <xsl:template match="table | informaltable | db:table | db:informaltable">
994 <xsl:variable name="if"><xsl:call-template name="db.profile.test"/></xsl:variable>
995 <xsl:if test="$if != ''">
996 <div>
997 <xsl:call-template name="html.class.attr">
998 <xsl:with-param name="class" select="'table'"/>
999 </xsl:call-template>
1000 <xsl:call-template name="html.lang.attrs"/>
1001 <xsl:call-template name="db2html.anchor"/>
1002 <xsl:apply-templates select="title | db:title | db:info/db:title"/>
1003 <!-- FIXME: I have no idea what I'm supposed to do with textobject -->
1004 <xsl:choose>
1005 <xsl:when test="graphic | mediaobject">
1006 <xsl:apply-templates select="graphic | mediaobject"/>
1007 </xsl:when>
1008 <xsl:when test="db:graphic | db:mediaobject">
1009 <xsl:apply-templates select="db:graphic | db:mediaobject"/>
1010 </xsl:when>
1011 <xsl:when test="tgroup">
1012 <xsl:apply-templates select="tgroup"/>
1013 </xsl:when>
1014 <xsl:when test="db:tgroup">
1015 <xsl:apply-templates select="db:tgroup"/>
1016 </xsl:when>
1017 <xsl:otherwise>
1018 <xsl:call-template name="db2html.table.table">
1019 <xsl:with-param name="node" select="."/>
1020 <xsl:with-param name="table" select="."/>
1021 </xsl:call-template>
1022 <xsl:apply-templates select="caption | db:caption"/>
1023 </xsl:otherwise>
1024 </xsl:choose>
1025 </div>
1026 </xsl:if>
1027 </xsl:template>
1028
1029 <!-- = tgroup = -->
1030 <xsl:template match="tgroup | db:tgroup">
1031 <xsl:call-template name="db2html.table.table">
1032 <xsl:with-param name="node" select="."/>
1033 <xsl:with-param name="table" select=".."/>
1034 </xsl:call-template>
1035 </xsl:template>
1036
1037 <xsl:template name="db2html.table.table">
1038 <xsl:param name="node" select="."/>
1039 <xsl:param name="table" select="$node"/>
1040 <xsl:variable name="colsep">
1041 <xsl:choose>
1042 <xsl:when test="$node/@colsep">
1043 <xsl:value-of select="string($node/@colsep)"/>
1044 </xsl:when>
1045 <xsl:when test="not($node//*[@colsep][1])"/>
1046 <xsl:otherwise>
1047 <xsl:text>0</xsl:text>
1048 </xsl:otherwise>
1049 </xsl:choose>
1050 </xsl:variable>
1051 <xsl:variable name="rowsep">
1052 <xsl:choose>
1053 <xsl:when test="$node/@rowsep">
1054 <xsl:value-of select="string($node/@rowsep)"/>
1055 </xsl:when>
1056 <xsl:when test="not($node//*[@rowsep][1])"/>
1057 <xsl:otherwise>
1058 <xsl:text>0</xsl:text>
1059 </xsl:otherwise>
1060 </xsl:choose>
1061 </xsl:variable>
1062 <xsl:variable name="style">
1063 <xsl:if test="$table/@frame = 'all' or $table/@frame = 'border' or not($table/@frame)">
1064 <xsl:text>border: solid 1px; </xsl:text>
1065 </xsl:if>
1066 <xsl:if test="$table/@frame = 'none'">
1067 <xsl:text>border: none; </xsl:text>
1068 </xsl:if>
1069 <xsl:if test="$table/@frame = 'bottom' or $table/@frame = 'topbot'">
1070 <xsl:text>border-bottom: solid 1px; </xsl:text>
1071 </xsl:if>
1072 <xsl:if test="$table/@frame = 'top' or $table/@frame = 'topbot'">
1073 <xsl:text>border-top: solid 1px; </xsl:text>
1074 </xsl:if>
1075 <xsl:if test="$table/@frame = 'sides'">
1076 <xsl:text>border-left: solid 1px; border-right: solid 1px; </xsl:text>
1077 </xsl:if>
1078 </xsl:variable>
1079 <xsl:variable name="class">
1080 <xsl:if test="$table/@pgwide = '1'">
1081 <xsl:text>table-pgwide</xsl:text>
1082 </xsl:if>
1083 <xsl:if test="$table/@rules = 'groups'">
1084 <xsl:text> table-rules-groups</xsl:text>
1085 </xsl:if>
1086 <xsl:if test="$table/@rules = 'rows'">
1087 <xsl:text> table-rules-rows</xsl:text>
1088 </xsl:if>
1089 <xsl:if test="$table/@rules = 'cols'">
1090 <xsl:text> table-rules-cols</xsl:text>
1091 </xsl:if>
1092 <xsl:if test="$table/@rules = 'all'">
1093 <xsl:text> table-rules-rows table-rules-cols</xsl:text>
1094 </xsl:if>
1095 </xsl:variable>
1096 <table>
1097 <xsl:call-template name="html.class.attr">
1098 <xsl:with-param name="node" select="$node"/>
1099 <xsl:with-param name="class" select="$class"/>
1100 </xsl:call-template>
1101 <xsl:call-template name="html.lang.attrs">
1102 <xsl:with-param name="node" select="$node"/>
1103 </xsl:call-template>
1104 <xsl:if test="$table/title or $table/db:title or $table/db:info/db:title">
1105 <xsl:attribute name="summary">
1106 <xsl:value-of select="$table/title | $table/db:title | $table/db:info/db:title"/>
1107 </xsl:attribute>
1108 </xsl:if>
1109 <xsl:if test="$style != ''">
1110 <xsl:attribute name="style">
1111 <xsl:value-of select="normalize-space($style)"/>
1112 </xsl:attribute>
1113 </xsl:if>
1114 <xsl:choose>
1115 <xsl:when test="tr | db:tr">
1116 <tbody>
1117 <xsl:apply-templates select="$node/tr | $node/db:tr">
1118 <xsl:with-param name="colsep" select="$colsep"/>
1119 <xsl:with-param name="rowsep" select="$rowsep"/>
1120 </xsl:apply-templates>
1121 </tbody>
1122 </xsl:when>
1123 <xsl:otherwise>
1124 <xsl:apply-templates select="$node/thead | $node/db:thead">
1125 <xsl:with-param name="colspecs" select="$node/colspec | $node/db:colspec"/>
1126 <xsl:with-param name="spanspecs" select="$node/spanspec | $node/db:spanspec"/>
1127 <xsl:with-param name="colsep" select="$colsep"/>
1128 <xsl:with-param name="rowsep" select="$rowsep"/>
1129 </xsl:apply-templates>
1130 <xsl:apply-templates select="$node/tbody | $node/db:tbody">
1131 <xsl:with-param name="colspecs" select="$node/colspec | $node/db:colspec"/>
1132 <xsl:with-param name="spanspecs" select="$node/spanspec | $node/db:spanspec"/>
1133 <xsl:with-param name="colsep" select="$colsep"/>
1134 <xsl:with-param name="rowsep" select="$rowsep"/>
1135 </xsl:apply-templates>
1136 <xsl:apply-templates select="$node/tfoot | $node/db:tfoot">
1137 <xsl:with-param name="colspecs" select="$node/colspec | $node/db:colspec"/>
1138 <xsl:with-param name="spanspecs" select="$node/spanspec | $node/db:spanspec"/>
1139 <xsl:with-param name="colsep" select="$colsep"/>
1140 <xsl:with-param name="rowsep" select="$rowsep"/>
1141 </xsl:apply-templates>
1142 </xsl:otherwise>
1143 </xsl:choose>
1144 </table>
1145 </xsl:template>
1146
1147 <!-- = tbody | tfoot | thead = -->
1148 <xsl:template match="tbody | tfoot | thead | db:tbody | db:tfoot | db:thead">
1149 <xsl:param name="colspecs"/>
1150 <xsl:param name="spanspecs"/>
1151 <xsl:param name="colsep" select="''"/>
1152 <xsl:param name="rowsep" select="''"/>
1153 <xsl:element name="{local-name(.)}" namespace="{$html.namespace}">
1154 <xsl:call-template name="html.lang.attrs"/>
1155 <xsl:call-template name="html.class.attr"/>
1156 <xsl:if test="@valign">
1157 <xsl:attribute name="valign">
1158 <xsl:value-of select="@valign"/>
1159 </xsl:attribute>
1160 </xsl:if>
1161 <xsl:choose>
1162 <xsl:when test="tr">
1163 <xsl:apply-templates select="tr"/>
1164 </xsl:when>
1165 <xsl:when test="db:tr">
1166 <xsl:apply-templates select="db:tr"/>
1167 </xsl:when>
1168 <xsl:when test="colspec | db:colspec">
1169 <xsl:call-template name="db2html.row">
1170 <xsl:with-param name="row" select="row[1] | db:row[1]"/>
1171 <xsl:with-param name="colspecs" select="colspec | db:colspec"/>
1172 <xsl:with-param name="spanspecs" select="spanspec | db:spanspec"/>
1173 <xsl:with-param name="colsep" select="$colsep"/>
1174 <xsl:with-param name="rowsep" select="$rowsep"/>
1175 </xsl:call-template>
1176 </xsl:when>
1177 <xsl:otherwise>
1178 <xsl:call-template name="db2html.row">
1179 <xsl:with-param name="row" select="row[1] | db:row[1]"/>
1180 <xsl:with-param name="colspecs" select="$colspecs"/>
1181 <xsl:with-param name="spanspecs" select="$spanspecs"/>
1182 <xsl:with-param name="colsep" select="$colsep"/>
1183 <xsl:with-param name="rowsep" select="$rowsep"/>
1184 </xsl:call-template>
1185 </xsl:otherwise>
1186 </xsl:choose>
1187 </xsl:element>
1188 </xsl:template>
1189
1190 <!-- = tr = -->
1191 <xsl:template match="tr | db:tr">
1192 <tr>
1193 <xsl:call-template name="html.lang.attrs"/>
1194 <xsl:call-template name="html.class.attr"/>
1195 <xsl:choose>
1196 <xsl:when test="@align = 'left' or @align = 'center' or
1197 @align = 'right' or @align = 'justify' ">
1198 <xsl:attribute name="style">
1199 <xsl:text>text-align: </xsl:text>
1200 <xsl:value-of select="@align"/>
1201 </xsl:attribute>
1202 </xsl:when>
1203 <xsl:when test="@align = 'char'">
1204 <xsl:attribute name="style">
1205 <xsl:text>text-align: "</xsl:text>
1206 <xsl:choose>
1207 <xsl:when test="@char != ''">
1208 <xsl:value-of select="@char"/>
1209 </xsl:when>
1210 <xsl:otherwise>
1211 <xsl:text>.</xsl:text>
1212 </xsl:otherwise>
1213 </xsl:choose>
1214 <xsl:text>"</xsl:text>
1215 </xsl:attribute>
1216 </xsl:when>
1217 </xsl:choose>
1218 <xsl:apply-templates/>
1219 </tr>
1220 </xsl:template>
1221
1222 <!-- = td | th = -->
1223 <xsl:template match="td | th | db:td | db:th">
1224 <xsl:element name="{local-name(.)}" namespace="{$html.namespace}">
1225 <xsl:call-template name="html.lang.attrs"/>
1226 <xsl:call-template name="html.class.attr"/>
1227 <xsl:copy-of select="@valign | @rowspan | @colspan | @scope"/>
1228 <xsl:choose>
1229 <xsl:when test="@align = 'left' or @align = 'center' or
1230 @align = 'right' or @align = 'justify' ">
1231 <xsl:attribute name="style">
1232 <xsl:text>text-align: </xsl:text>
1233 <xsl:value-of select="@align"/>
1234 </xsl:attribute>
1235 </xsl:when>
1236 <xsl:when test="@align = 'char'">
1237 <xsl:attribute name="style">
1238 <xsl:text>text-align: "</xsl:text>
1239 <xsl:choose>
1240 <xsl:when test="@char != ''">
1241 <xsl:value-of select="@char"/>
1242 </xsl:when>
1243 <xsl:otherwise>
1244 <xsl:text>.</xsl:text>
1245 </xsl:otherwise>
1246 </xsl:choose>
1247 <xsl:text>"</xsl:text>
1248 </xsl:attribute>
1249 </xsl:when>
1250 </xsl:choose>
1251 <xsl:apply-templates/>
1252 </xsl:element>
1253 </xsl:template>
1254
1255
1256 </xsl:stylesheet>