syncing up to 3.0.0rc1
[Samba.git] / docs / docbook / xslt / table.mod.xsl
blobb20752d91dcb995d73af54d6ce78cb996534f552
1 <?xml version='1.0'?>
2 <!--#############################################################################
3 |- #############################################################################
4 |
5 | PURPOSE:
6 + ############################################################################## -->
7 <xsl:stylesheet
8 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
9 xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
10 exclude-result-prefixes="doc" version='1.0'>
14 <!--############################################################################# -->
15 <!-- DOCUMENTATION -->
16 <doc:reference id="table" xmlns="">
17 <referenceinfo>
18 <releaseinfo role="meta">
19 </releaseinfo>
20 <authorgroup>
21 <firstname>Ramon</firstname> <surname>Casellas</surname>
22 <firstname>James</firstname> <surname>Devenish</surname>
23 </authorgroup>
24 <copyright>
25 <year>2000</year> <year>2001</year> <year>2002</year> <year>2003</year>
26 <holder>Ramon Casellas</holder>
27 </copyright>
28 </referenceinfo>
30 <title>Tables <filename>table.mod.xsl</filename></title>
31 <partintro>
32 <section><title>Introduction</title>
33 <para></para>
34 </section>
35 </partintro>
36 </doc:reference>
41 <!--############################################################################# -->
42 <!-- DOCUMENTATION -->
43 <doc:template match="table|informaltable" xmlns="">
44 <refpurpose>XSL template for docbook tables. </refpurpose>
45 <refdescription>
46 <para></para>
47 <formalpara><title>Remarks and Bugs</title>
48 <itemizedlist>
49 </itemizedlist>
50 </formalpara>
51 <formalpara><title>Default Behaviour</title>
52 <screen></screen>
53 </formalpara>
54 </refdescription>
55 </doc:template>
56 <!--############################################################################# -->
58 <xsl:template match="table">
59 <xsl:variable name="placement">
60 <xsl:call-template name="generate.formal.title.placement">
61 <xsl:with-param name="object" select="local-name(.)" />
62 </xsl:call-template>
63 </xsl:variable>
64 <xsl:variable name="caption">
65 <xsl:text>\caption{</xsl:text>
66 <xsl:apply-templates select="title" mode="caption.mode"/>
67 <xsl:text>}&#10;</xsl:text>
68 </xsl:variable>
69 <xsl:call-template name="map.begin"/>
70 <xsl:if test="$placement='before'">
71 <xsl:text>\captionswapskip{}</xsl:text>
72 <xsl:value-of select="$caption" />
73 <xsl:text>\captionswapskip{}</xsl:text>
74 </xsl:if>
75 <xsl:apply-templates/>
76 <xsl:if test="$placement!='before'"><xsl:value-of select="$caption" /></xsl:if>
77 <xsl:call-template name="map.end"/>
78 </xsl:template>
80 <xsl:template match="table/title"/>
81 <xsl:template match="table/title" mode="caption.mode"><xsl:apply-templates /></xsl:template>
83 <xsl:template match="informaltable">
84 <xsl:call-template name="map.begin"/>
85 <xsl:apply-templates/>
86 <xsl:call-template name="map.end"/>
87 </xsl:template>
90 <xsl:template name="table.format.tabularx">
91 <xsl:param name="cols" select="1"/>
92 <xsl:param name="i" select="1"/>
93 <xsl:param name="colsep" select="1"/>
94 <!-- sum of numeric portions in 1*-like colwidths -->
95 <xsl:param name="starfactor" select="0"/>
96 <xsl:choose>
97 <!-- Out of the recursive iteration -->
98 <xsl:when test="$i > $cols"></xsl:when>
99 <!-- There are still columns to count -->
100 <xsl:otherwise>
101 <xsl:variable name="width">
102 <xsl:variable name="userchoice" select="colspec[@colnum=$i]/@colwidth"/>
103 <xsl:variable name="cells" select="thead/row/entry[$i]|tbody/row/entry[$i]"/>
104 <xsl:choose>
105 <xsl:when test="string-length($userchoice)=0 and count($cells//itemizedlist|$cells//orderedlist|$cells//variablelist)&gt;0">
106 <!-- In these specific circumstances, we MUST use a line-wrapped column
107 and yet the user hasn't specified one. -->
108 <xsl:value-of select="'1*'"/>
109 </xsl:when>
110 <xsl:otherwise>
111 <!-- In the general case, we just do what the user wants (may even
112 have no pre-specified width). -->
113 <xsl:value-of select="$userchoice"/>
114 </xsl:otherwise>
115 </xsl:choose>
116 </xsl:variable>
117 <!-- Try to take heed of colspecs -->
118 <xsl:choose>
119 <xsl:when test="$width!=''">
120 <xsl:text>&gt;{</xsl:text>
121 <xsl:if test="contains($width,'*')">
122 <!-- see tabularx documentation -->
123 <xsl:text>\hsize=</xsl:text>
124 <xsl:value-of select="substring-before($width,'*') * $starfactor" />
125 <xsl:text>\hsize</xsl:text>
126 </xsl:if>
127 <xsl:choose>
128 <xsl:when test="colspec[@colnum=$i]/@align='left'"><xsl:text>\RaggedRight</xsl:text></xsl:when>
129 <xsl:when test="colspec[@colnum=$i]/@align='right'"><xsl:text>\RaggedLeft</xsl:text></xsl:when>
130 <xsl:when test="colspec[@colnum=$i]/@align='center'"><xsl:text>\Centering</xsl:text></xsl:when>
131 <xsl:when test="colspec[@colnum=$i]/@align='char'"><xsl:message>Table column char alignment is not supported.</xsl:message></xsl:when>
132 </xsl:choose>
133 <xsl:text>}</xsl:text>
134 <xsl:choose>
135 <xsl:when test="contains($width,'*')">
136 <xsl:text>X</xsl:text>
137 </xsl:when>
138 <xsl:otherwise>
139 <xsl:text>p{</xsl:text><xsl:value-of select="$width" /><xsl:text>}</xsl:text>
140 </xsl:otherwise>
141 </xsl:choose>
142 <xsl:if test="$i&lt;$cols and $colsep='1'">
143 <xsl:text>|</xsl:text>
144 </xsl:if>
145 </xsl:when>
146 <xsl:otherwise>
147 <xsl:choose>
148 <xsl:when test="colspec[@colnum=$i]/@align='left'"><xsl:text>l</xsl:text></xsl:when>
149 <xsl:when test="colspec[@colnum=$i]/@align='right'"><xsl:text>r</xsl:text></xsl:when>
150 <xsl:when test="colspec[@colnum=$i]/@align='center'"><xsl:text>c</xsl:text></xsl:when>
151 <xsl:when test="colspec[@colnum=$i]/@align='justify'"><xsl:text>X</xsl:text></xsl:when>
152 <xsl:when test="colspec[@colnum=$i]/@align='char'"><xsl:text>c</xsl:text><xsl:message>Table column char alignment is not supported.</xsl:message></xsl:when>
153 <xsl:otherwise><xsl:text>X</xsl:text></xsl:otherwise>
154 </xsl:choose>
155 <xsl:if test="$i&lt;$cols and $colsep='1'">
156 <xsl:text>|</xsl:text>
157 </xsl:if>
158 </xsl:otherwise>
159 </xsl:choose>
160 <!-- Recursive for next column -->
161 <xsl:call-template name="table.format.tabularx">
162 <xsl:with-param name="i" select="$i+1"/>
163 <xsl:with-param name="cols" select="$cols"/>
164 <xsl:with-param name="starfactor" select="$starfactor"/>
165 </xsl:call-template>
166 </xsl:otherwise>
167 </xsl:choose>
168 </xsl:template>
171 <!-- FIX THIS -->
172 <xsl:template name="table.format.tabular">
173 <xsl:param name="cols" select="1"/>
174 <xsl:param name="i" select="1"/>
175 <xsl:param name="colsep" select="1"/>
176 <xsl:choose>
177 <!-- Out of the recursive iteration -->
178 <xsl:when test="$i > $cols"></xsl:when>
179 <!-- There are still columns to count -->
180 <xsl:otherwise>
181 <!-- Try to take heed of colspecs -->
182 <xsl:choose>
183 <!-- RC 2003/03/19 : Added first 'test' : colspec[@colnum=$i] for xsltproc
184 Before this patch, parsing the doc with xsltproc the xsl:when clause
185 was evaluated to 'true' even if there was no colspec for the column
187 <xsl:when test="colspec[@colnum=$i] and colspec[@colnum=$i]/@colwidth!='' and not(contains(colspec[@colnum=$i]/@colwidth,'*'))">
188 <xsl:choose>
189 <xsl:when test="colspec[@colnum=$i]/@align='left'"><xsl:text>&gt;{\RaggedRight}</xsl:text></xsl:when>
190 <xsl:when test="colspec[@colnum=$i]/@align='right'"><xsl:text>&gt;{\RaggedLeft}</xsl:text></xsl:when>
191 <xsl:when test="colspec[@colnum=$i]/@align='center'"><xsl:text>&gt;{\Centering}</xsl:text></xsl:when>
192 <xsl:when test="colspec[@colnum=$i]/@align='char'"><xsl:message>Table column char alignment is not supported.</xsl:message></xsl:when>
193 </xsl:choose>
194 <xsl:text>p{</xsl:text><xsl:value-of select="colspec[@colnum=$i]/@colwidth" /><xsl:text>}</xsl:text>
195 <xsl:if test="$i&lt;$cols and $colsep='1'">
196 <xsl:text>|</xsl:text>
197 </xsl:if>
198 </xsl:when>
199 <xsl:otherwise>
200 <xsl:choose>
201 <xsl:when test="colspec[@colnum=$i]/@align='left'"><xsl:text>l</xsl:text></xsl:when>
202 <xsl:when test="colspec[@colnum=$i]/@align='right'"><xsl:text>r</xsl:text></xsl:when>
203 <xsl:when test="colspec[@colnum=$i]/@align='center'"><xsl:text>c</xsl:text></xsl:when>
204 <xsl:when test="colspec[@colnum=$i]/@align='justify'"><xsl:text>l</xsl:text></xsl:when>
205 <xsl:when test="colspec[@colnum=$i]/@align='char'"><xsl:text>c</xsl:text><xsl:message>Table column char alignment is not supported.</xsl:message></xsl:when>
206 <xsl:otherwise><xsl:text>c</xsl:text></xsl:otherwise>
207 </xsl:choose>
208 <xsl:if test="$i&lt;$cols and $colsep='1'">
209 <xsl:text>|</xsl:text>
210 </xsl:if>
211 </xsl:otherwise>
212 </xsl:choose>
213 <!-- Recursive for next column -->
214 <xsl:call-template name="table.format.tabular">
215 <xsl:with-param name="i" select="$i+1"/>
216 <xsl:with-param name="cols" select="$cols"/>
217 </xsl:call-template>
218 </xsl:otherwise>
219 </xsl:choose>
220 </xsl:template>
224 <!-- See tabularx documentation. -->
225 <!-- For example, if we have a 1* column and a 3* column, then the
226 the hsizes for each column are (1/(1+3)*2) and (3/(1+3)*2).
227 The ratio of these to the star values (star values being 1 and 3)
228 is 2/(1+3).
229 BUT it is now very complicated because it takes into account columns
230 where the user has not specified a width but LaTeX requires a
231 fixed-width column (i.e. specialcols may vary).
232 Relies on there being (a) colspecs for every column or (b) no
233 colspecs.
235 <xsl:template name="generate.starfactor">
236 <xsl:param name="i" select="1"/>
237 <xsl:param name="cols" select="count(colspec)"/>
238 <xsl:param name="sum" select="0"/>
239 <xsl:param name="specialcols" select="count(colspec[contains(@colwidth,'*')])"/>
240 <xsl:choose>
241 <xsl:when test="$i&lt;=$cols and colspec[position()=$i and contains(@colwidth,'*')]">
242 <!-- a * column -->
243 <xsl:call-template name="generate.starfactor">
244 <xsl:with-param name="i" select="$i+1"/>
245 <xsl:with-param name="cols" select="$cols"/>
246 <xsl:with-param name="sum" select="$sum+substring-before(colspec[$i]/@colwidth,'*')"/>
247 <xsl:with-param name="specialcols" select="$specialcols"/>
248 </xsl:call-template>
249 </xsl:when>
250 <xsl:when test="$i&lt;=$cols">
251 <!-- not a * column, but we are going to pretend that it is -->
252 <xsl:variable name="cells" select="thead/row/entry[$i]|tbody/row/entry[$i]"/>
253 <xsl:variable name="problems" select="count($cells//itemizedlist|$cells//orderedlist|$cells//variablelist)"/>
254 <xsl:choose>
255 <xsl:when test="$problems &gt; 0">
256 <xsl:call-template name="generate.starfactor">
257 <xsl:with-param name="i" select="$i+1"/>
258 <xsl:with-param name="cols" select="$cols"/>
259 <xsl:with-param name="sum" select="$sum+1"/>
260 <xsl:with-param name="specialcols" select="$specialcols+1"/>
261 </xsl:call-template>
262 </xsl:when>
263 <xsl:otherwise>
264 <xsl:call-template name="generate.starfactor">
265 <xsl:with-param name="i" select="$i+1"/>
266 <xsl:with-param name="cols" select="$cols"/>
267 <xsl:with-param name="sum" select="$sum"/>
268 <xsl:with-param name="specialcols" select="$specialcols"/>
269 </xsl:call-template>
270 </xsl:otherwise>
271 </xsl:choose>
272 </xsl:when>
273 <xsl:otherwise>
274 <xsl:value-of select="$specialcols div $sum"/>
275 </xsl:otherwise>
276 </xsl:choose>
277 </xsl:template>
280 <xsl:template match="tgroup">
281 <xsl:variable name="align" select="@align"/>
282 <xsl:variable name="frame">
283 <xsl:choose>
284 <xsl:when test="string-length(../@frame)&lt;1">all</xsl:when>
285 <xsl:otherwise>
286 <xsl:value-of select="../@frame"/>
287 </xsl:otherwise>
288 </xsl:choose>
289 </xsl:variable>
290 <xsl:variable name="colspecs" select="./colspec"/>
291 <xsl:variable name="usex">
292 <xsl:choose>
293 <!-- if there are lists within cells, we need tabularx -->
294 <xsl:when test="$latex.use.tabularx=1 and (descendant::itemizedlist|descendant::orderedlist|descendant::variablelist)">
295 <xsl:text>1</xsl:text>
296 </xsl:when>
297 <!-- if there are instances of 1*-style colwidths, we need tabularx -->
298 <xsl:when test="$latex.use.tabularx=1 and contains(colspec/@colwidth,'*')">
299 <xsl:text>1</xsl:text>
300 </xsl:when>
301 <!-- if there are colspecs with 'justify' alignment and no explicit width, we need tabularx -->
302 <xsl:when test="$latex.use.tabularx=1 and count(colspec[@align='justify'])&gt;0">
303 <xsl:text>1</xsl:text>
304 </xsl:when>
305 <xsl:otherwise>
306 <xsl:text>1</xsl:text>
307 </xsl:otherwise>
308 </xsl:choose>
309 </xsl:variable>
310 <xsl:variable name="useminipage">
311 <!-- Hack to get around LaTeX issue with tabular (not necessary with tabularx).
312 This is NOT a good solution, and has problems of its own, but at least the footnotes
313 do not actually disappear (which is what would otherwise happen). -->
314 <xsl:if test="count(.//footnote)!=0">1</xsl:if>
315 </xsl:variable>
316 <xsl:choose>
317 <xsl:when test="$usex='1'">
318 <xsl:text>\begin{tabularx}{\linewidth}{</xsl:text>
319 </xsl:when>
320 <xsl:otherwise>
321 <xsl:if test="$useminipage='1'"><xsl:text>\begin{minipage}{\linewidth}&#10;</xsl:text></xsl:if>
322 <xsl:text>\begin{tabular}{</xsl:text>
323 </xsl:otherwise>
324 </xsl:choose>
325 <xsl:if test="$frame='all' or $frame='sides'">
326 <xsl:text>|</xsl:text>
327 </xsl:if>
328 <xsl:choose>
329 <xsl:when test="$usex=1">
330 <xsl:call-template name="table.format.tabularx">
331 <xsl:with-param name="cols" select="@cols"/>
332 <xsl:with-param name="starfactor">
333 <xsl:call-template name="generate.starfactor">
334 <xsl:with-param name="cols" select="@cols"/>
335 </xsl:call-template>
336 </xsl:with-param>
337 </xsl:call-template>
338 </xsl:when>
339 <xsl:otherwise>
340 <xsl:call-template name="table.format.tabular">
341 <xsl:with-param name="cols" select="@cols"/>
342 </xsl:call-template>
343 </xsl:otherwise>
344 </xsl:choose>
345 <xsl:if test="$frame='all' or $frame='sides'">
346 <xsl:text>|</xsl:text>
347 </xsl:if>
348 <xsl:text>}&#10;</xsl:text>
349 <xsl:if test="$frame!='sides' and $frame!='none' and $frame!='bottom'">
350 <xsl:text>\hline &#10;</xsl:text>
351 </xsl:if>
352 <!-- APPLY TEMPLATES -->
353 <xsl:apply-templates/>
354 <!-- -->
355 <xsl:if test="$frame!='sides' and $frame!='none' and $frame!='top'">
356 <xsl:text>\hline &#10;</xsl:text>
357 </xsl:if>
358 <xsl:choose>
359 <xsl:when test="$usex=1">
360 <xsl:text>\end{tabularx}&#10;</xsl:text>
361 </xsl:when>
362 <xsl:otherwise>
363 <xsl:text>\end{tabular}&#10;</xsl:text>
364 <xsl:if test="$useminipage='1'"><xsl:text>\end{minipage}&#10;</xsl:text></xsl:if>
365 </xsl:otherwise>
366 </xsl:choose>
367 </xsl:template>
371 <!--
372 <xsl:template name="generate.col">
373 <xsl:param name="countcol">1</xsl:param>
374 </xsl:template>
377 <xsl:template match="colspec"></xsl:template>
378 <xsl:template match="spanspec"></xsl:template>
383 <xsl:template match="thead|tfoot">
384 <xsl:if test="@align">
385 <xsl:attribute name="align">
386 <xsl:value-of select="@align"/>
387 </xsl:attribute>
388 </xsl:if>
389 <xsl:if test="@char">
390 <xsl:attribute name="char">
391 <xsl:value-of select="@char"/>
392 </xsl:attribute>
393 </xsl:if>
394 <xsl:if test="@charoff">
395 <xsl:attribute name="charoff">
396 <xsl:value-of select="@charoff"/>
397 </xsl:attribute>
398 </xsl:if>
399 <xsl:if test="@valign">
400 <xsl:attribute name="valign">
401 <xsl:value-of select="@valign"/>
402 </xsl:attribute>
403 </xsl:if>
404 <xsl:apply-templates/>
405 </xsl:template>
407 <xsl:template match="thead/row/entry|tfoot/row/entry">
408 <xsl:call-template name="latex.entry.prealign"/>
409 <xsl:call-template name="latex.thead.row.entry"/>
410 <xsl:call-template name="latex.entry.postalign"/>
411 <xsl:choose>
412 <xsl:when test="position()=last()"><xsl:text> \tabularnewline&#10;</xsl:text></xsl:when>
413 <xsl:otherwise><xsl:call-template name="generate.latex.cell.separator"/></xsl:otherwise>
414 </xsl:choose>
415 </xsl:template>
417 <xsl:template match="tbody">
418 <xsl:apply-templates/>
419 </xsl:template>
421 <xsl:template match="row">
422 <xsl:apply-templates/>
423 </xsl:template>
425 <xsl:template match="tbody/row|thead/row|tfoot/row">
426 <xsl:apply-templates/>
427 <!-- The rule below the last row in the table is controlled by the
428 Frame attribute of the enclosing Table or InformalTable and the RowSep
429 of the last row is ignored. If unspecified, this attribute is
430 inherited from enclosing elements, rowsep=1 by default. -->
431 <xsl:variable name="parent_position" select="count(../preceding-sibling::node())+1"/>
432 <xsl:variable name="grandparent_children" select="count(../../child::node())"/>
433 <xsl:if test="(count(@rowsep)=0 or @rowsep='1') and (position() != last() or $parent_position &lt; $grandparent_children)">
434 <xsl:text> \hline &#10;</xsl:text>
435 </xsl:if>
436 </xsl:template>
439 <xsl:template match="tbody/row/entry">
440 <xsl:call-template name="latex.entry.prealign"/>
441 <xsl:apply-templates/>
442 <xsl:call-template name="latex.entry.postalign"/>
443 <xsl:choose>
444 <xsl:when test="position()=last()"><xsl:text> \tabularnewline&#10;</xsl:text></xsl:when>
445 <xsl:otherwise><xsl:call-template name="generate.latex.cell.separator"/></xsl:otherwise>
446 </xsl:choose>
447 </xsl:template>
450 <xsl:template name="latex.entry.prealign">
451 <xsl:variable name="span">
452 <xsl:choose>
453 <xsl:when test="@spanname!=''">
454 <xsl:call-template name="calculate.colspan">
455 <xsl:with-param name="namest" select="../../../spanspec[@spanname=@spanname]/@namest"/>
456 <xsl:with-param name="nameend" select="../../../spanspec[@spanname=@spanname]/@nameend"/>
457 </xsl:call-template>
458 </xsl:when>
459 <xsl:when test="@namest!=''">
460 <xsl:call-template name="calculate.colspan"/>
461 </xsl:when>
462 <xsl:otherwise>-1</xsl:otherwise>
463 </xsl:choose>
464 </xsl:variable>
465 <xsl:if test="$span &gt; 1">
466 <xsl:text>\multicolumn{</xsl:text>
467 <xsl:value-of select="$span"/>
468 <xsl:text>|}{</xsl:text><!-- TODO take heed of @colsep -->
469 <xsl:choose>
470 <xsl:when test="@align='left'"><xsl:text>l</xsl:text></xsl:when>
471 <xsl:when test="@align='right'"><xsl:text>r</xsl:text></xsl:when>
472 <xsl:when test="@align='center'"><xsl:text>c</xsl:text></xsl:when>
473 <xsl:when test="@align='char'">c<xsl:message>Table entry char alignment is not supported.</xsl:message></xsl:when>
474 <xsl:otherwise>c</xsl:otherwise>
475 </xsl:choose>
476 <!-- use this as a hook for some general warnings -->
477 <xsl:text>}</xsl:text>
478 </xsl:if>
479 <!-- this is used when the entry's align spec wants to override the column default -->
480 <xsl:if test="$span &lt; 1">
481 <xsl:choose>
482 <xsl:when test="@align='left'"><xsl:text>\docbooktolatexalignll </xsl:text></xsl:when>
483 <xsl:when test="@align='right'"><xsl:text>\docbooktolatexalignrl </xsl:text></xsl:when>
484 <xsl:when test="@align='center'"><xsl:text>\docbooktolatexaligncl </xsl:text></xsl:when>
485 <xsl:when test="@align='char'"><xsl:message>Table entry char alignment is not supported.</xsl:message></xsl:when>
486 </xsl:choose>
487 </xsl:if>
488 <xsl:text>{</xsl:text>
489 <xsl:if test="@rotate='1'">
490 <xsl:text>\rotatebox{90}</xsl:text>
491 <xsl:if test="@align!=''"><xsl:message>entry[@rotate='1' and @align!=''] probably doesn't work.</xsl:message></xsl:if>
492 </xsl:if>
493 <xsl:text>{</xsl:text>
494 <!-- use this as a hook for some general warnings -->
495 <xsl:if test="@morerows!=''"><xsl:message>The morerows attribute is not supported.</xsl:message></xsl:if>
496 </xsl:template>
498 <xsl:template name="latex.entry.postalign">
499 <xsl:text>}}</xsl:text>
500 <!-- this is used when the entry's align spec wants to override the column default -->
501 <xsl:if test="@namest='' and @spanspec=''"><!-- TODO improve -->
502 <xsl:choose>
503 <xsl:when test="@align='left'"><xsl:text>\docbooktolatexalignlr </xsl:text></xsl:when>
504 <xsl:when test="@align='right'"><xsl:text>\docbooktolatexalignrr </xsl:text></xsl:when>
505 <xsl:when test="@align='center'"><xsl:text>\docbooktolatexaligncr </xsl:text></xsl:when>
506 </xsl:choose>
507 </xsl:if>
508 </xsl:template>
522 <xsl:template name="process.cell">
523 <xsl:param name="cellgi">td</xsl:param>
524 <xsl:variable name="empty.cell" select="count(node()) = 0"/>
526 <xsl:element name="{$cellgi}">
527 <xsl:if test="@morerows">
528 <xsl:attribute name="rowspan">
529 <xsl:value-of select="@morerows+1"/>
530 </xsl:attribute>
531 </xsl:if>
532 <xsl:if test="@namest">
533 <xsl:attribute name="colspan">
534 <xsl:call-template name="calculate.colspan"/>
535 </xsl:attribute>
536 </xsl:if>
537 <xsl:if test="@align">
538 <xsl:attribute name="align">
539 <xsl:value-of select="@align"/>
540 </xsl:attribute>
541 </xsl:if>
542 <xsl:if test="@char">
543 <xsl:attribute name="char">
544 <xsl:value-of select="@char"/>
545 </xsl:attribute>
546 </xsl:if>
547 <xsl:if test="@charoff">
548 <xsl:attribute name="charoff">
549 <xsl:value-of select="@charoff"/>
550 </xsl:attribute>
551 </xsl:if>
552 <xsl:if test="@valign">
553 <xsl:attribute name="valign">
554 <xsl:value-of select="@valign"/>
555 </xsl:attribute>
556 </xsl:if>
558 <xsl:choose>
559 <xsl:when test="$empty.cell">
560 <xsl:text>&#160;</xsl:text>
561 </xsl:when>
562 <xsl:otherwise>
563 <xsl:apply-templates/>
564 </xsl:otherwise>
565 </xsl:choose>
566 </xsl:element>
567 </xsl:template>
569 <xsl:template name="generate.colgroup">
570 <xsl:param name="cols" select="1"/>
571 <xsl:param name="count" select="1"/>
572 <xsl:choose>
573 <xsl:when test="$count>$cols"></xsl:when>
574 <xsl:otherwise>
575 <xsl:call-template name="generate.col">
576 <xsl:with-param name="countcol" select="$count"/>
577 </xsl:call-template>
578 <xsl:call-template name="generate.colgroup">
579 <xsl:with-param name="cols" select="$cols"/>
580 <xsl:with-param name="count" select="$count+1"/>
581 </xsl:call-template>
582 </xsl:otherwise>
583 </xsl:choose>
584 </xsl:template>
586 <xsl:template name="generate.col">
587 <xsl:param name="countcol">1</xsl:param>
588 <xsl:param name="colspecs" select="./colspec"/>
589 <xsl:param name="count">1</xsl:param>
590 <xsl:param name="colnum">1</xsl:param>
592 <xsl:choose>
593 <xsl:when test="$count>count($colspecs)">
594 <col/>
595 </xsl:when>
596 <xsl:otherwise>
597 <xsl:variable name="colspec" select="$colspecs[$count=position()]"/>
598 <xsl:variable name="colspec.colnum">
599 <xsl:choose>
600 <xsl:when test="$colspec/@colnum">
601 <xsl:value-of select="$colspec/@colnum"/>
602 </xsl:when>
603 <xsl:otherwise>
604 <xsl:value-of select="$colnum"/>
605 </xsl:otherwise>
606 </xsl:choose>
607 </xsl:variable>
609 <xsl:choose>
610 <xsl:when test="$colspec.colnum=$countcol">
611 <col>
612 <xsl:if test="$colspec/@align">
613 <xsl:attribute name="align">
614 <xsl:value-of select="$colspec/@align"/>
615 </xsl:attribute>
616 </xsl:if>
617 <xsl:if test="$colspec/@char">
618 <xsl:attribute name="char">
619 <xsl:value-of select="$colspec/@char"/>
620 </xsl:attribute>
621 </xsl:if>
622 <xsl:if test="$colspec/@charoff">
623 <xsl:attribute name="charoff">
624 <xsl:value-of select="$colspec/@charoff"/>
625 </xsl:attribute>
626 </xsl:if>
627 </col>
628 </xsl:when>
629 <xsl:otherwise>
630 <xsl:call-template name="generate.col">
631 <xsl:with-param name="countcol" select="$countcol"/>
632 <xsl:with-param name="colspecs" select="$colspecs"/>
633 <xsl:with-param name="count" select="$count+1"/>
634 <xsl:with-param name="colnum">
635 <xsl:choose>
636 <xsl:when test="$colspec/@colnum">
637 <xsl:value-of select="$colspec/@colnum + 1"/>
638 </xsl:when>
639 <xsl:otherwise>
640 <xsl:value-of select="$colnum + 1"/>
641 </xsl:otherwise>
642 </xsl:choose>
643 </xsl:with-param>
644 </xsl:call-template>
645 </xsl:otherwise>
646 </xsl:choose>
647 </xsl:otherwise>
648 </xsl:choose>
650 </xsl:template>
652 <xsl:template name="colspec.colnum">
653 <!-- when this macro is called, the current context must be an entry -->
654 <xsl:param name="colname"></xsl:param>
655 <!-- .. = row, ../.. = thead|tbody, ../../.. = tgroup -->
656 <xsl:param name="colspecs" select="../../../../tgroup/colspec"/>
657 <xsl:param name="count">1</xsl:param>
658 <xsl:param name="colnum">1</xsl:param>
659 <xsl:choose>
660 <xsl:when test="$count>count($colspecs)"></xsl:when>
661 <xsl:otherwise>
662 <xsl:variable name="colspec" select="$colspecs[$count=position()]"/>
663 <!--
664 <xsl:value-of select="$count"/>:
665 <xsl:value-of select="$colspec/@colname"/>=
666 <xsl:value-of select="$colnum"/>
668 <xsl:choose>
669 <xsl:when test="$colspec/@colname=$colname">
670 <xsl:choose>
671 <xsl:when test="$colspec/@colnum">
672 <xsl:value-of select="$colspec/@colnum"/>
673 </xsl:when>
674 <xsl:otherwise>
675 <xsl:value-of select="$colnum"/>
676 </xsl:otherwise>
677 </xsl:choose>
678 </xsl:when>
679 <xsl:otherwise>
680 <xsl:call-template name="colspec.colnum">
681 <xsl:with-param name="colname" select="$colname"/>
682 <xsl:with-param name="colspecs" select="$colspecs"/>
683 <xsl:with-param name="count" select="$count+1"/>
684 <xsl:with-param name="colnum">
685 <xsl:choose>
686 <xsl:when test="$colspec/@colnum">
687 <xsl:value-of select="$colspec/@colnum + 1"/>
688 </xsl:when>
689 <xsl:otherwise>
690 <xsl:value-of select="$colnum + 1"/>
691 </xsl:otherwise>
692 </xsl:choose>
693 </xsl:with-param>
694 </xsl:call-template>
695 </xsl:otherwise>
696 </xsl:choose>
697 </xsl:otherwise>
698 </xsl:choose>
699 </xsl:template>
701 <xsl:template name="colspec.colwidth">
702 <!-- when this macro is called, the current context must be an entry -->
703 <xsl:param name="colname"></xsl:param>
704 <!-- .. = row, ../.. = thead|tbody, ../../.. = tgroup -->
705 <xsl:param name="colspecs" select="../../../../tgroup/colspec"/>
706 <xsl:param name="count">1</xsl:param>
707 <xsl:choose>
708 <xsl:when test="$count>count($colspecs)"></xsl:when>
709 <xsl:otherwise>
710 <xsl:variable name="colspec" select="$colspecs[$count=position()]"/>
711 <xsl:choose>
712 <xsl:when test="$colspec/@colname=$colname">
713 <xsl:value-of select="$colspec/@colwidth"/>
714 </xsl:when>
715 <xsl:otherwise>
716 <xsl:call-template name="colspec.colwidth">
717 <xsl:with-param name="colname" select="$colname"/>
718 <xsl:with-param name="colspecs" select="$colspecs"/>
719 <xsl:with-param name="count" select="$count+1"/>
720 </xsl:call-template>
721 </xsl:otherwise>
722 </xsl:choose>
723 </xsl:otherwise>
724 </xsl:choose>
725 </xsl:template>
727 <xsl:template name="calculate.colspan">
728 <xsl:param name="namest" select="@namest"/>
729 <xsl:param name="nameend" select="@nameend"/>
730 <xsl:variable name="scol">
731 <xsl:call-template name="colspec.colnum">
732 <xsl:with-param name="colname" select="$namest"/>
733 </xsl:call-template>
734 </xsl:variable>
735 <xsl:variable name="ecol">
736 <xsl:call-template name="colspec.colnum">
737 <xsl:with-param name="colname" select="$nameend"/>
738 </xsl:call-template>
739 </xsl:variable>
740 <xsl:value-of select="$ecol - $scol + 1"/>
741 </xsl:template>
743 </xsl:stylesheet>