Embed db2latex as interim solution before migration to dblatex
[Samba/gbeck.git] / docs / xslt / db2latex-xsl / xsl / table.mod.xsl
blob10a36e75e257617e206673b7a1be0dc86ccf7d03
1 <?xml version='1.0'?>
2 <!DOCTYPE xsl:stylesheet [ <!ENTITY % xsldoc.ent SYSTEM "./xsldoc.ent"> %xsldoc.ent; ]>
3 <!--#############################################################################
4 | $Id: table.mod.xsl,v 1.32 2004/01/28 02:08:41 j-devenish Exp $
5 |- #############################################################################
6 | $Author: j-devenish $
7 + ############################################################################## -->
8 <xsl:stylesheet
9 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
10 xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
11 exclude-result-prefixes="doc" version='1.0'>
13 <doc:reference id="table" xmlns="">
14 <referenceinfo>
15 <releaseinfo role="meta">
16 $Id: table.mod.xsl,v 1.32 2004/01/28 02:08:41 j-devenish Exp $
17 </releaseinfo>
18 <authorgroup>
19 &ramon;
20 &james;
21 </authorgroup>
22 <copyright>
23 <year>2000</year><year>2001</year><year>2002</year><year>2003</year><year>2004</year>
24 <holder>Ramon Casellas</holder>
25 </copyright>
26 <revhistory>
27 <doc:revision rcasver="1.24">&rev_2003_05;</doc:revision>
28 </revhistory>
29 </referenceinfo>
30 <title>Tables <filename>table.mod.xsl</filename></title>
31 <partintro>
32 <para>
36 </para>
37 </partintro>
38 </doc:reference>
40 <doc:template xmlns="">
41 <refpurpose>Process <doc:db>table</doc:db> elements</refpurpose>
42 <doc:description>
43 <para>
47 </para>
48 </doc:description>
49 <doc:variables>
50 <variablelist>
51 <varlistentry>
52 <term><xref linkend="param.latex.table.caption.style"/></term>
53 <listitem><simpara>
54 The &LaTeX; command for formatting captions.
55 </simpara></listitem>
56 </varlistentry>
57 </variablelist>
58 </doc:variables>
59 <doc:notes>
60 <para>
62 Unless <xref linkend="param.latex.use.ltxtable"/> is in use,
63 tables are typeset as <quote>floats</quote> using the <link
64 linkend="latex.mapping">mapping system</link>. This limits the
65 size of each table to one page. It is possible to use tables
66 without floats, but captions and cross-referencing will not
67 function as intended.
69 </para>
70 <para>
72 If a <sgmltag class="attribute">condition</sgmltag> attribute
73 exists and begins with <quote>db2latex:</quote>, or a <sgmltag
74 class="pi">latex-float-placement</sgmltag> processing
75 instruction is present, the remainder of its value will be used
76 as the &LaTeX; <quote>float</quote> placement. Otherwise, the
77 default placement is <quote>htb</quote>.
79 </para>
80 </doc:notes>
81 <doc:samples>
82 <simplelist type='inline'>
83 &test_book;
84 &test_ecos;
85 &test_pinkjuice;
86 &test_tables;
87 </simplelist>
88 </doc:samples>
89 <doc:seealso>
90 <itemizedlist>
91 <listitem><simpara>&mapping;</simpara></listitem>
92 <listitem><simpara><xref linkend="template.generate.formal.title.placement"/></simpara></listitem>
93 </itemizedlist>
94 </doc:seealso>
95 </doc:template>
96 <xsl:template match="table">
97 <xsl:choose>
98 <xsl:when test="caption">
99 <xsl:message>Cannot cope with new-style tables lacking tgroup -- skipped.</xsl:message>
100 </xsl:when>
101 <xsl:when test="$latex.use.ltxtable='1'">
102 <!--
103 <xsl:message>No captions for ltxtable, yet.</xsl:message>
105 <!--
106 Can use captions with longtable, but this is handled by
107 the thead and tfoot templates :-(
109 <xsl:call-template name="content-templates"/>
110 </xsl:when>
111 <xsl:otherwise>
112 <xsl:variable name="placement">
113 <xsl:call-template name="generate.formal.title.placement">
114 <xsl:with-param name="object" select="local-name(.)" />
115 </xsl:call-template>
116 </xsl:variable>
117 <xsl:variable name="position">
118 <xsl:call-template name="generate.latex.float.position">
119 <xsl:with-param name="default" select="'htb'"/>
120 </xsl:call-template>
121 </xsl:variable>
122 <xsl:variable name="caption">
123 <xsl:call-template name="generate.table.caption"/>
124 </xsl:variable>
125 <xsl:call-template name="map.begin">
126 <xsl:with-param name="string" select="$position"/>
127 </xsl:call-template>
128 <xsl:if test="$placement='before'">
129 <xsl:text>\captionswapskip{}</xsl:text>
130 <xsl:value-of select="$caption" />
131 <xsl:text>\captionswapskip{}</xsl:text>
132 </xsl:if>
133 <xsl:call-template name="content-templates"/>
134 <xsl:if test="$placement!='before'"><xsl:value-of select="$caption" /></xsl:if>
135 <xsl:call-template name="map.end">
136 <xsl:with-param name="string" select="$position"/>
137 </xsl:call-template>
138 </xsl:otherwise>
139 </xsl:choose>
140 </xsl:template>
142 <xsl:template name="generate.table.caption.longtable">
143 <xsl:for-each select="ancestor-or-self::table">
144 <xsl:text>\caption{</xsl:text>
145 <xsl:value-of select="$latex.table.caption.style"/>
146 <xsl:text>{</xsl:text>
147 <xsl:apply-templates select="title" mode="caption.mode"/>
148 <xsl:text>}</xsl:text>
149 <xsl:call-template name="label.id"/>
150 <xsl:text>}\hypertarget{</xsl:text>
151 <xsl:call-template name="generate.label.id"/>
152 <xsl:text>}{}&#10;</xsl:text>
153 </xsl:for-each>
154 </xsl:template>
156 <xsl:template name="generate.table.caption">
157 <xsl:for-each select="ancestor-or-self::table">
158 <xsl:text>{</xsl:text>
159 <xsl:value-of select="$latex.table.caption.style"/>
160 <xsl:text>{\caption{</xsl:text>
161 <xsl:apply-templates select="title" mode="caption.mode"/>
162 <xsl:text>}</xsl:text>
163 <xsl:call-template name="label.id"/>
164 <xsl:text>}}&#10;</xsl:text>
165 </xsl:for-each>
166 </xsl:template>
168 <doc:template xmlns="">
169 <refpurpose>Process <doc:db>informaltable</doc:db> elements</refpurpose>
170 <doc:description>
171 <para>
173 Applies templates within a &LaTeX; mapping.
175 </para>
176 </doc:description>
177 <doc:variables>
178 &no_var;
179 </doc:variables>
180 <doc:samples>
181 <simplelist type='inline'>
182 &test_bind;
183 &test_book;
184 &test_chemistry;
185 &test_tables;
186 </simplelist>
187 </doc:samples>
188 <doc:seealso>
189 <itemizedlist>
190 <listitem><simpara>&mapping;</simpara></listitem>
191 </itemizedlist>
192 </doc:seealso>
193 </doc:template>
194 <xsl:template match="informaltable">
195 <xsl:call-template name="map.begin"/>
196 <xsl:apply-templates/>
197 <xsl:call-template name="map.end"/>
198 </xsl:template>
200 <doc:template xmlns="">
201 <refpurpose>Process <doc:db basename="table">tables</doc:db> using <productname>tabularx</productname> </refpurpose>
202 <doc:description>
203 <para>
205 Similar to <xref linkend="template.table.format.tabularx"/> but
206 calculates <quote>relative</quote> column sizes.
208 </para>
209 </doc:description>
210 <doc:variables>
211 &no_var;
212 </doc:variables>
213 <doc:samples>
214 <simplelist type='inline'>
215 &test_tables;
216 </simplelist>
217 </doc:samples>
218 <doc:seealso>
219 <itemizedlist>
220 <listitem><simpara><xref linkend="template.table.format.tabular"/></simpara></listitem>
221 </itemizedlist>
222 </doc:seealso>
223 </doc:template>
224 <xsl:template name="table.format.tabularx">
225 <xsl:param name="cols" select="1"/>
226 <xsl:param name="i" select="1"/>
227 <xsl:param name="colsep" select="1"/>
228 <!-- sum of numeric portions in 1*-like colwidths -->
229 <xsl:param name="starfactor" select="0"/>
230 <xsl:choose>
231 <!-- Out of the recursive iteration -->
232 <xsl:when test="$i > $cols"></xsl:when>
233 <!-- There are still columns to count -->
234 <xsl:otherwise>
235 <xsl:variable name="userwidth">
236 <xsl:choose>
237 <xsl:when test="./colspec[@colnum=$i]">
238 <xsl:value-of select="./colspec[@colnum=$i]/@colwidth"/>
239 </xsl:when>
240 <xsl:otherwise>
241 <xsl:value-of select="./colspec[position()=$i]/@colwidth"/>
242 </xsl:otherwise>
243 </xsl:choose>
244 </xsl:variable>
245 <xsl:variable name="useralign">
246 <xsl:choose>
247 <xsl:when test="./colspec[@colnum=$i]/@align!=''">
248 <xsl:value-of select="./colspec[@colnum=$i]/@align"/>
249 </xsl:when>
250 <xsl:when test="./colspec[position()=$i]/@align!=''">
251 <xsl:value-of select="./colspec[position()=$i]/@align"/>
252 </xsl:when>
253 <xsl:otherwise>
254 <xsl:value-of select="./@align"/>
255 </xsl:otherwise>
256 </xsl:choose>
257 </xsl:variable>
258 <xsl:variable name="width">
259 <xsl:variable name="cells" select="thead/row/entry[$i]|tbody/row/entry[$i]"/>
260 <xsl:choose>
261 <xsl:when test="string-length($userwidth)=0 and count($cells//itemizedlist|$cells//orderedlist|$cells//variablelist)&gt;0">
262 <!-- In these specific circumstances, we MUST use a line-wrapped column
263 and yet the user hasn't specified one. -->
264 <xsl:value-of select="'1*'"/>
265 </xsl:when>
266 <xsl:otherwise>
267 <!-- In the general case, we just do what the user wants (may even
268 have no pre-specified width). -->
269 <xsl:value-of select="$userwidth"/>
270 </xsl:otherwise>
271 </xsl:choose>
272 </xsl:variable>
273 <!-- Try to take heed of colspecs -->
274 <xsl:choose>
275 <xsl:when test="$width!=''">
276 <xsl:text>&gt;{</xsl:text>
277 <xsl:if test="contains($width,'*')">
278 <!-- see tabularx documentation -->
279 <xsl:text>\hsize=</xsl:text>
280 <xsl:value-of select="substring-before($width,'*') * $starfactor" />
281 <xsl:text>\hsize</xsl:text>
282 </xsl:if>
283 <xsl:choose>
284 <xsl:when test="$useralign='left'"><xsl:text>\RaggedRight</xsl:text></xsl:when>
285 <xsl:when test="$useralign='right'"><xsl:text>\RaggedLeft</xsl:text></xsl:when>
286 <xsl:when test="$useralign='center'"><xsl:text>\Centering</xsl:text></xsl:when>
287 <xsl:when test="$useralign='char' and $latex.use.dcolumn='1'">
288 <xsl:variable name="char" select="(./colspec[@colnum=$i]/@char|./colspec[position()=$i]/@char)[1]"/>
289 <xsl:choose>
290 <xsl:when test="$char=''"><xsl:text>d</xsl:text></xsl:when>
291 <xsl:otherwise>D{<xsl:value-of select="$char"/>}{<xsl:value-of select="$char"/>}{-1}</xsl:otherwise>
292 </xsl:choose>
293 </xsl:when>
294 <xsl:when test="$useralign!=''"><xsl:message>Table column '<xsl:value-of select="$useralign"/>' alignment is not supported.</xsl:message></xsl:when>
295 </xsl:choose>
296 <xsl:text>}</xsl:text>
297 <xsl:choose>
298 <xsl:when test="contains($width,'*')">
299 <xsl:text>X</xsl:text>
300 </xsl:when>
301 <xsl:otherwise>
302 <xsl:text>p{</xsl:text><xsl:value-of select="$width" /><xsl:text>}</xsl:text>
303 </xsl:otherwise>
304 </xsl:choose>
305 <xsl:if test="$i&lt;$cols and $colsep='1'">
306 <xsl:text>|</xsl:text>
307 </xsl:if>
308 </xsl:when>
309 <xsl:otherwise>
310 <xsl:choose>
311 <xsl:when test="$useralign='left'"><xsl:text>l</xsl:text></xsl:when>
312 <xsl:when test="$useralign='right'"><xsl:text>r</xsl:text></xsl:when>
313 <xsl:when test="$useralign='center'"><xsl:text>c</xsl:text></xsl:when>
314 <xsl:when test="$useralign='justify'"><xsl:text>X</xsl:text></xsl:when>
315 <xsl:when test="$useralign='char' and $latex.use.dcolumn='1'">
316 <xsl:variable name="char" select="(./colspec[@colnum=$i]/@char|./colspec[position()=$i]/@char)[1]"/>
317 <xsl:choose>
318 <xsl:when test="$char=''"><xsl:text>d</xsl:text></xsl:when>
319 <xsl:otherwise>D{<xsl:value-of select="$char"/>}{<xsl:value-of select="$char"/>}{-1}</xsl:otherwise>
320 </xsl:choose>
321 </xsl:when>
322 <xsl:otherwise>
323 <xsl:text>c</xsl:text>
324 <xsl:if test="$useralign!=''">
325 <xsl:message>Table column '<xsl:value-of select="$useralign"/>' alignment is not supported.</xsl:message>
326 </xsl:if>
327 </xsl:otherwise>
328 </xsl:choose>
329 <xsl:if test="$i&lt;$cols and $colsep='1'">
330 <xsl:text>|</xsl:text>
331 </xsl:if>
332 </xsl:otherwise>
333 </xsl:choose>
334 <!-- Recursive for next column -->
335 <xsl:call-template name="table.format.tabularx">
336 <xsl:with-param name="i" select="$i+1"/>
337 <xsl:with-param name="cols" select="$cols"/>
338 <xsl:with-param name="colsep" select="$colsep"/>
339 <xsl:with-param name="starfactor" select="$starfactor"/>
340 </xsl:call-template>
341 </xsl:otherwise>
342 </xsl:choose>
343 </xsl:template>
345 <doc:template xmlns="">
346 <refpurpose>Process <doc:db basename="table">tables</doc:db> using <function condition="env">tabular</function> </refpurpose>
347 <doc:description>
348 <para>
352 </para>
353 </doc:description>
354 <doc:variables>
355 &no_var;
356 </doc:variables>
357 <doc:samples>
358 <simplelist type='inline'>
359 &test_tables;
360 </simplelist>
361 </doc:samples>
362 <doc:seealso>
363 <itemizedlist>
364 <listitem><simpara><xref linkend="template.table.format.tabularx"/></simpara></listitem>
365 </itemizedlist>
366 </doc:seealso>
367 </doc:template>
368 <xsl:template name="table.format.tabular">
369 <xsl:param name="cols" select="1"/>
370 <xsl:param name="i" select="1"/>
371 <xsl:param name="colsep" select="1"/>
372 <xsl:choose>
373 <!-- Out of the recursive iteration -->
374 <xsl:when test="$i > $cols"></xsl:when>
375 <!-- There are still columns to count -->
376 <xsl:otherwise>
377 <!-- Try to take heed of colspecs -->
378 <xsl:variable name="width">
379 <xsl:variable name="userwidth">
380 <xsl:choose>
381 <xsl:when test="./colspec[@colnum=$i]">
382 <xsl:value-of select="./colspec[@colnum=$i]/@colwidth"/>
383 </xsl:when>
384 <xsl:otherwise>
385 <xsl:value-of select="./colspec[position()=$i]/@colwidth"/>
386 </xsl:otherwise>
387 </xsl:choose>
388 </xsl:variable>
389 <xsl:variable name="cells" select="thead/row/entry[$i]|tbody/row/entry[$i]"/>
390 <xsl:choose>
391 <xsl:when test="string-length($userwidth)=0 and count($cells//itemizedlist|$cells//orderedlist|$cells//variablelist)&gt;0">
392 <!-- In these specific circumstances, we MUST use a line-wrapped column
393 and yet the user hasn't specified one. -->
394 <xsl:value-of select="concat(1 div $cols,'\linewidth')"/>
395 </xsl:when>
396 <xsl:otherwise>
397 <!-- In the general case, we just do what the user wants (may even
398 have no pre-specified width). -->
399 <xsl:value-of select="$userwidth"/>
400 </xsl:otherwise>
401 </xsl:choose>
402 </xsl:variable>
403 <xsl:variable name="useralign">
404 <xsl:choose>
405 <xsl:when test="./colspec[@colnum=$i]/@align!=''">
406 <xsl:value-of select="./colspec[@colnum=$i]/@align"/>
407 </xsl:when>
408 <xsl:when test="./colspec[position()=$i]/@align!=''">
409 <xsl:value-of select="./colspec[position()=$i]/@align"/>
410 </xsl:when>
411 <xsl:otherwise>
412 <xsl:value-of select="./@align"/>
413 </xsl:otherwise>
414 </xsl:choose>
415 </xsl:variable>
416 <xsl:choose>
417 <xsl:when test="$width!='' and not(contains($width,'*'))">
418 <xsl:choose>
419 <xsl:when test="$useralign='left'"><xsl:text>&gt;{\RaggedRight}</xsl:text></xsl:when>
420 <xsl:when test="$useralign='right'"><xsl:text>&gt;{\RaggedLeft}</xsl:text></xsl:when>
421 <xsl:when test="$useralign='center'"><xsl:text>&gt;{\Centering}</xsl:text></xsl:when>
422 <xsl:when test="$useralign='char'"><xsl:message>Table column 'char' alignment is not supported when width specified.</xsl:message></xsl:when>
423 <xsl:when test="$useralign!=''"><xsl:message>Table column '<xsl:value-of select="$useralign"/>' alignment is not supported.</xsl:message></xsl:when>
424 </xsl:choose>
425 <xsl:text>p{</xsl:text><xsl:value-of select="$width" /><xsl:text>}</xsl:text>
426 <xsl:if test="$i&lt;$cols and $colsep='1'">
427 <xsl:text>|</xsl:text>
428 </xsl:if>
429 </xsl:when>
430 <xsl:otherwise>
431 <xsl:choose>
432 <xsl:when test="$useralign='left'"><xsl:text>l</xsl:text></xsl:when>
433 <xsl:when test="$useralign='right'"><xsl:text>r</xsl:text></xsl:when>
434 <xsl:when test="$useralign='center'"><xsl:text>c</xsl:text></xsl:when>
435 <xsl:when test="$useralign='justify'"><xsl:text>l</xsl:text></xsl:when>
436 <xsl:when test="$useralign='char' and $latex.use.dcolumn='1'">
437 <xsl:variable name="char" select="(./colspec[@colnum=$i]/@char|./colspec[position()=$i]/@char)[1]"/>
438 <xsl:choose>
439 <xsl:when test="$char=''"><xsl:text>d</xsl:text></xsl:when>
440 <xsl:otherwise>D{<xsl:value-of select="$char"/>}{<xsl:value-of select="$char"/>}{-1}</xsl:otherwise>
441 </xsl:choose>
442 </xsl:when>
443 <xsl:otherwise>
444 <xsl:text>c</xsl:text>
445 <xsl:if test="$useralign!=''">
446 <xsl:message>Table column '<xsl:value-of select="$useralign"/>' alignment is not supported.</xsl:message>
447 </xsl:if>
448 </xsl:otherwise>
449 </xsl:choose>
450 <xsl:if test="$i&lt;$cols and $colsep='1'">
451 <xsl:text>|</xsl:text>
452 </xsl:if>
453 </xsl:otherwise>
454 </xsl:choose>
455 <!-- Recursive for next column -->
456 <xsl:call-template name="table.format.tabular">
457 <xsl:with-param name="i" select="$i+1"/>
458 <xsl:with-param name="cols" select="$cols"/>
459 <xsl:with-param name="colsep" select="$colsep"/>
460 </xsl:call-template>
461 </xsl:otherwise>
462 </xsl:choose>
463 </xsl:template>
465 <!-- See tabularx documentation. -->
466 <!-- For example, if we have a 1* column and a 3* column, then the
467 the hsizes for each column are (1/(1+3)*2) and (3/(1+3)*2).
468 The ratio of these to the star values (star values being 1 and 3)
469 is 2/(1+3).
470 BUT it is now very complicated because it takes into account columns
471 where the user has not specified a width but LaTeX requires a
472 fixed-width column (i.e. specialcols may vary).
473 Relies on there being (a) colspecs for every column or (b) no
474 colspecs.
476 <doc:template xmlns="">
477 <refpurpose>Calculate relative column sizes</refpurpose>
478 <doc:description>
479 <para>
481 Determines the width of each column in terms of <quote>relative
482 units</quote>.
484 </para>
485 </doc:description>
486 <doc:variables>
487 &no_var;
488 </doc:variables>
489 <doc:samples>
490 <simplelist type='inline'>
491 &test_tables;
492 </simplelist>
493 </doc:samples>
494 <doc:seealso>
495 <itemizedlist>
496 <listitem><simpara><xref linkend="template.table.format.tabular"/></simpara></listitem>
497 <listitem><simpara><xref linkend="template.table.format.tabularx"/></simpara></listitem>
498 </itemizedlist>
499 </doc:seealso>
500 </doc:template>
501 <xsl:template name="generate.starfactor">
502 <xsl:param name="i" select="1"/>
503 <xsl:param name="cols" select="count(colspec)"/>
504 <xsl:param name="sum" select="0"/>
505 <xsl:param name="specialcols" select="count(colspec[contains(@colwidth,'*')])"/>
506 <xsl:choose>
507 <xsl:when test="$i&lt;=$cols and colspec[position()=$i and contains(@colwidth,'*')]">
508 <!-- a * column -->
509 <xsl:call-template name="generate.starfactor">
510 <xsl:with-param name="i" select="$i+1"/>
511 <xsl:with-param name="cols" select="$cols"/>
512 <xsl:with-param name="sum" select="$sum+substring-before(colspec[$i]/@colwidth,'*')"/>
513 <xsl:with-param name="specialcols" select="$specialcols"/>
514 </xsl:call-template>
515 </xsl:when>
516 <xsl:when test="$i&lt;=$cols">
517 <!-- not a * column, but we are going to pretend that it is -->
518 <xsl:variable name="cells" select="thead/row/entry[$i]|tbody/row/entry[$i]"/>
519 <xsl:variable name="problems" select="count($cells//itemizedlist|$cells//orderedlist|$cells//variablelist)"/>
520 <xsl:choose>
521 <xsl:when test="$problems &gt; 0">
522 <xsl:call-template name="generate.starfactor">
523 <xsl:with-param name="i" select="$i+1"/>
524 <xsl:with-param name="cols" select="$cols"/>
525 <xsl:with-param name="sum" select="$sum+1"/>
526 <xsl:with-param name="specialcols" select="$specialcols+1"/>
527 </xsl:call-template>
528 </xsl:when>
529 <xsl:otherwise>
530 <xsl:call-template name="generate.starfactor">
531 <xsl:with-param name="i" select="$i+1"/>
532 <xsl:with-param name="cols" select="$cols"/>
533 <xsl:with-param name="sum" select="$sum"/>
534 <xsl:with-param name="specialcols" select="$specialcols"/>
535 </xsl:call-template>
536 </xsl:otherwise>
537 </xsl:choose>
538 </xsl:when>
539 <xsl:otherwise>
540 <xsl:value-of select="$specialcols div $sum"/>
541 </xsl:otherwise>
542 </xsl:choose>
543 </xsl:template>
545 <doc:template xmlns="">
546 <refpurpose>Process <doc:db>tgroup</doc:db> elements</refpurpose>
547 <doc:variables>
548 &no_var;
549 </doc:variables>
550 </doc:template>
551 <xsl:template match="tgroup">
552 <xsl:variable name="colsep">
553 <xsl:choose>
554 <xsl:when test="@colsep!=''">
555 <xsl:value-of select="number(@colsep)"/>
556 </xsl:when>
557 <xsl:when test="../@colsep!=''">
558 <xsl:value-of select="number(../@colsep)"/>
559 </xsl:when>
560 <xsl:otherwise>1</xsl:otherwise>
561 </xsl:choose>
562 </xsl:variable>
563 <xsl:variable name="frame">
564 <xsl:choose>
565 <xsl:when test="string-length(../@frame)&lt;1">all</xsl:when>
566 <xsl:otherwise>
567 <xsl:value-of select="../@frame"/>
568 </xsl:otherwise>
569 </xsl:choose>
570 </xsl:variable>
571 <xsl:variable name="colspecs" select="./colspec"/>
572 <xsl:variable name="usex">
573 <xsl:choose>
574 <xsl:when test="$latex.use.ltxtable='1'">
575 <xsl:text>0</xsl:text>
576 </xsl:when>
577 <!-- if there are lists within cells, we need tabularx -->
578 <xsl:when test="$latex.use.tabularx=1 and (descendant::itemizedlist|descendant::orderedlist|descendant::variablelist)">
579 <xsl:text>1</xsl:text>
580 </xsl:when>
581 <!-- if there are instances of 1*-style colwidths, we need tabularx -->
582 <xsl:when test="$latex.use.tabularx=1 and contains(colspec/@colwidth,'*')">
583 <xsl:text>1</xsl:text>
584 </xsl:when>
585 <!-- if there are colspecs with 'justify' alignment and no explicit width, we need tabularx -->
586 <xsl:when test="$latex.use.tabularx=1 and count(colspec[@align='justify'])&gt;0">
587 <xsl:text>1</xsl:text>
588 </xsl:when>
589 <xsl:otherwise>
590 <xsl:text>0</xsl:text>
591 </xsl:otherwise>
592 </xsl:choose>
593 </xsl:variable>
594 <xsl:variable name="useminipage">
595 <!-- Hack to get around LaTeX issue with tabular (not necessary with tabularx).
596 This is NOT a good solution, and has problems of its own, but at least the footnotes
597 do not actually disappear (which is what would otherwise happen). -->
598 <xsl:if test="count(.//footnote)!=0">1</xsl:if>
599 </xsl:variable>
600 <xsl:choose>
601 <xsl:when test="$usex='1'">
602 <xsl:text>\begin{tabularx}{\linewidth}{</xsl:text>
603 </xsl:when>
604 <xsl:when test="$latex.use.ltxtable='1'">
605 <xsl:if test="parent::informaltable">
606 <xsl:text>\addtocounter{table}{-1}</xsl:text>
607 </xsl:if>
608 <xsl:text>\begin{longtable}{</xsl:text>
609 </xsl:when>
610 <xsl:otherwise>
611 <xsl:if test="$useminipage='1'"><xsl:text>\begin{minipage}{\linewidth}&#10;</xsl:text></xsl:if>
612 <xsl:text>\begin{tabular}{</xsl:text>
613 </xsl:otherwise>
614 </xsl:choose>
615 <xsl:if test="$frame='all' or $frame='sides'">
616 <xsl:text>|</xsl:text>
617 </xsl:if>
618 <xsl:variable name="cols">
619 <xsl:choose>
620 <xsl:when test="@cols">
621 <xsl:value-of select="@cols"/>
622 </xsl:when>
623 <xsl:otherwise>
624 <xsl:value-of select="count(tbody/row[1]/entry)"/>
625 <xsl:message>Warning: table's tgroup lacks cols attribute. Assuming <xsl:value-of select="count(tbody/row[1]/entry)"/>.</xsl:message>
626 </xsl:otherwise>
627 </xsl:choose>
628 </xsl:variable>
629 <xsl:choose>
630 <xsl:when test="$usex=1">
631 <xsl:call-template name="table.format.tabularx">
632 <xsl:with-param name="cols" select="$cols"/>
633 <xsl:with-param name="colsep" select="$colsep"/>
634 <xsl:with-param name="starfactor">
635 <xsl:call-template name="generate.starfactor">
636 <xsl:with-param name="cols" select="$cols"/>
637 </xsl:call-template>
638 </xsl:with-param>
639 </xsl:call-template>
640 </xsl:when>
641 <xsl:otherwise>
642 <xsl:call-template name="table.format.tabular">
643 <xsl:with-param name="cols" select="$cols"/>
644 <xsl:with-param name="colsep" select="$colsep"/>
645 </xsl:call-template>
646 </xsl:otherwise>
647 </xsl:choose>
648 <xsl:if test="$frame='all' or $frame='sides'">
649 <xsl:text>|</xsl:text>
650 </xsl:if>
651 <xsl:text>}&#10;</xsl:text>
652 <xsl:variable name="thead.frame">
653 <xsl:choose>
654 <xsl:when test="$frame!='sides' and $frame!='none' and $frame!='bottom'">
655 <xsl:value-of select="1"/>
656 </xsl:when>
657 <xsl:otherwise>
658 <xsl:value-of select="0"/>
659 </xsl:otherwise>
660 </xsl:choose>
661 </xsl:variable>
662 <xsl:variable name="tfoot.frame">
663 <xsl:choose>
664 <xsl:when test="$frame!='sides' and $frame!='none' and $frame!='top'">
665 <xsl:value-of select="1"/>
666 </xsl:when>
667 <xsl:otherwise>
668 <xsl:value-of select="0"/>
669 </xsl:otherwise>
670 </xsl:choose>
671 </xsl:variable>
672 <!-- APPLY TEMPLATES -->
673 <xsl:choose>
674 <xsl:when test="$latex.use.ltxtable='1' and parent::table">
675 <!-- for tables only, not informaltables -->
676 <xsl:variable name="placement">
677 <xsl:call-template name="generate.formal.title.placement">
678 <xsl:with-param name="object" select="'table'" />
679 </xsl:call-template>
680 </xsl:variable>
681 <xsl:choose>
682 <xsl:when test="$placement='before'">
683 <xsl:choose>
684 <xsl:when test="thead">
685 <xsl:apply-templates select="thead" mode="longtable.caption">
686 <xsl:with-param name="frame" select="$thead.frame"/>
687 </xsl:apply-templates>
688 <xsl:apply-templates select="thead" mode="longtable.caption.continuation">
689 <xsl:with-param name="frame" select="$thead.frame"/>
690 </xsl:apply-templates>
691 </xsl:when>
692 <xsl:otherwise>
693 <xsl:call-template name="thead.longtable.caption">
694 <xsl:with-param name="frame" select="$thead.frame"/>
695 </xsl:call-template>
696 <xsl:call-template name="thead.longtable.caption.continuation">
697 <xsl:with-param name="frame" select="$thead.frame"/>
698 </xsl:call-template>
699 </xsl:otherwise>
700 </xsl:choose>
701 <xsl:apply-templates select="tfoot">
702 <xsl:with-param name="frame" select="$tfoot.frame"/>
703 </xsl:apply-templates>
704 <xsl:if test="$tfoot.frame=1 and not(tfoot)">
705 <xsl:text>\hline &#10;</xsl:text>
706 </xsl:if>
707 <xsl:apply-templates select="tbody"/>
708 </xsl:when>
709 <xsl:otherwise>
710 <xsl:if test="$thead.frame=1 and not(thead)">
711 <xsl:text>\hline &#10;</xsl:text>
712 </xsl:if>
713 <xsl:apply-templates select="thead">
714 <xsl:with-param name="frame" select="$thead.frame"/>
715 </xsl:apply-templates>
716 <xsl:choose>
717 <xsl:when test="tfoot">
718 <xsl:apply-templates select="tfoot" mode="longtable.caption.continued">
719 <xsl:with-param name="frame" select="$tfoot.frame"/>
720 </xsl:apply-templates>
721 <xsl:apply-templates select="tfoot" mode="longtable.caption">
722 <xsl:with-param name="frame" select="$tfoot.frame"/>
723 </xsl:apply-templates>
724 </xsl:when>
725 <xsl:otherwise>
726 <xsl:call-template name="tfoot.longtable.caption.continued">
727 <xsl:with-param name="frame" select="$tfoot.frame"/>
728 </xsl:call-template>
729 <xsl:call-template name="tfoot.longtable.caption">
730 <xsl:with-param name="frame" select="$tfoot.frame"/>
731 </xsl:call-template>
732 </xsl:otherwise>
733 </xsl:choose>
734 <xsl:apply-templates select="tbody"/>
735 </xsl:otherwise>
736 </xsl:choose>
737 </xsl:when>
738 <xsl:otherwise>
739 <xsl:if test="$thead.frame=1 and not(thead)">
740 <xsl:text>\hline &#10;</xsl:text>
741 </xsl:if>
742 <xsl:apply-templates select="thead">
743 <xsl:with-param name="frame" select="$thead.frame"/>
744 </xsl:apply-templates>
745 <xsl:apply-templates select="tbody"/>
746 <xsl:apply-templates select="tfoot">
747 <xsl:with-param name="frame" select="$tfoot.frame"/>
748 </xsl:apply-templates>
749 <xsl:if test="$tfoot.frame=1 and not(tfoot)">
750 <xsl:text>\hline &#10;</xsl:text>
751 </xsl:if>
752 </xsl:otherwise>
753 </xsl:choose>
754 <!-- -->
755 <xsl:choose>
756 <xsl:when test="$usex=1">
757 <xsl:text>\end{tabularx}&#10;</xsl:text>
758 </xsl:when>
759 <xsl:when test="$latex.use.ltxtable='1'">
760 <xsl:text>\end{longtable}&#10;</xsl:text>
761 <!-- catcode touchup ARGH -->
762 <xsl:call-template name="generate.latex.cell.separator">
763 <xsl:with-param name="which" select="'post'"/>
764 </xsl:call-template>
765 </xsl:when>
766 <xsl:otherwise>
767 <xsl:text>\end{tabular}&#10;</xsl:text>
768 <xsl:if test="$useminipage='1'"><xsl:text>\end{minipage}&#10;</xsl:text></xsl:if>
769 </xsl:otherwise>
770 </xsl:choose>
771 </xsl:template>
773 <doc:template xmlns="">
774 <refpurpose>Process <doc:db>colspec</doc:db> elements</refpurpose>
775 <doc:description>
776 <para>
778 Suppressed.
780 </para>
781 </doc:description>
782 <doc:variables>
783 &no_var;
784 </doc:variables>
785 <doc:notes>
786 <para>
788 <doc:db basename="colspec">Colspec</doc:db> are interpreted by
789 the <doc:db>tgroup</doc:db> template.
791 </para>
792 </doc:notes>
793 <doc:samples>
794 <simplelist type='inline'>
795 &test_book;
796 &test_tables;
797 </simplelist>
798 </doc:samples>
799 <doc:seealso>
800 <itemizedlist>
801 <listitem><simpara><xref linkend="template.tgroup"/></simpara></listitem>
802 </itemizedlist>
803 </doc:seealso>
804 </doc:template>
805 <xsl:template match="colspec"></xsl:template>
807 <doc:template xmlns="">
808 <refpurpose>Process <doc:db>spanspec</doc:db> elements</refpurpose>
809 <doc:description>
810 <para>
812 Suppressed.
814 </para>
815 </doc:description>
816 <doc:variables>
817 &no_var;
818 </doc:variables>
819 <doc:notes>
820 <para>
822 <doc:db basename="spanspec">Spanspecs</doc:db> are interpreted
823 by the <doc:db>tgroup</doc:db> template.
825 </para>
826 </doc:notes>
827 <doc:samples>
828 <simplelist type='inline'>
829 &test_book;
830 &test_tables;
831 </simplelist>
832 </doc:samples>
833 <doc:seealso>
834 <itemizedlist>
835 <listitem><simpara><xref linkend="template.tgroup"/></simpara></listitem>
836 </itemizedlist>
837 </doc:seealso>
838 </doc:template>
839 <xsl:template match="spanspec"></xsl:template>
841 <doc:template basename="thead" xmlns="">
842 <refpurpose>Process <doc:db>thead</doc:db> elements</refpurpose>
843 <doc:description>
844 <para>
845 Applies templates.
846 </para>
847 </doc:description>
848 <doc:variables>
849 &no_var;
850 </doc:variables>
851 </doc:template>
852 <xsl:template match="thead">
853 <xsl:param name="frame" select="0"/>
854 <xsl:if test="$frame=1">
855 <xsl:text>\hline &#10;</xsl:text>
856 </xsl:if>
857 <xsl:apply-templates/>
858 <xsl:if test="$latex.use.ltxtable='1'">
859 <xsl:text> \endhead&#10;</xsl:text>
860 </xsl:if>
861 </xsl:template>
863 <doc:template basename="thead" xmlns="">
864 <refpurpose>Process <doc:db>thead</doc:db> elements</refpurpose>
865 <doc:description>
866 <para>
867 Emits a caption and calls <function condition="latex">endfirsthead</function>.
868 </para>
869 </doc:description>
870 <doc:variables>
871 &no_var;
872 </doc:variables>
873 </doc:template>
874 <xsl:template match="thead" mode="longtable.caption" name="thead.longtable.caption">
875 <xsl:param name="frame" select="0"/>
876 <xsl:call-template name="generate.table.caption.longtable"/>
877 <xsl:text>\\&#10;</xsl:text><!-- or should this be \tabularnewline? -->
878 <xsl:if test="$frame=1">
879 <xsl:text>\hline &#10;</xsl:text>
880 </xsl:if>
881 <xsl:apply-templates select="row"/>
882 <xsl:text> \endfirsthead&#10;</xsl:text>
883 </xsl:template>
885 <doc:template basename="thead" xmlns="">
886 <refpurpose>Process <doc:db>thead</doc:db> elements</refpurpose>
887 <doc:description>
888 <para>
889 Emits a continuation caption and calls <function condition="latex">endhead</function>.
890 </para>
891 </doc:description>
892 <doc:variables>
893 &no_var;
894 </doc:variables>
895 </doc:template>
896 <xsl:template match="thead" mode="longtable.caption.continuation" name="thead.longtable.caption.continuation">
897 <xsl:param name="frame" select="0"/>
898 <xsl:text>\caption[]{</xsl:text>
899 <xsl:value-of select="$latex.table.caption.style"/>
900 <xsl:text>{</xsl:text>
901 <xsl:call-template name="gentext.template">
902 <xsl:with-param name="context" select="'table'"/>
903 <xsl:with-param name="name" select="'thead.continuation'"/>
904 </xsl:call-template>
905 <xsl:text>}}\\&#10;</xsl:text><!-- or should this be \tabularnewline? -->
906 <xsl:if test="$frame=1">
907 <xsl:text>\hline &#10;</xsl:text>
908 </xsl:if>
909 <xsl:apply-templates select="row"/>
910 <xsl:text> \endhead&#10;</xsl:text>
911 </xsl:template>
913 <doc:template basename="tfoot" xmlns="">
914 <refpurpose>Process <doc:db>tfoot</doc:db> elements</refpurpose>
915 <doc:variables>
916 &no_var;
917 </doc:variables>
918 </doc:template>
919 <xsl:template match="tfoot">
920 <xsl:param name="frame" select="0"/>
921 <xsl:apply-templates/>
922 <xsl:if test="$frame=1">
923 <xsl:text>\hline &#10;</xsl:text>
924 </xsl:if>
925 <xsl:if test="$latex.use.ltxtable='1'">
926 <xsl:text> \endfoot&#10;</xsl:text>
927 </xsl:if>
928 </xsl:template>
930 <doc:template basename="tfoot" xmlns="">
931 <refpurpose>Process <doc:db>tfoot</doc:db> elements</refpurpose>
932 <doc:description>
933 <para>
934 Emits a caption and calls <function condition="latex">endlastfoot</function>.
935 </para>
936 </doc:description>
937 <doc:variables>
938 &no_var;
939 </doc:variables>
940 </doc:template>
941 <xsl:template match="tfoot" mode="longtable.caption" name="tfoot.longtable.caption">
942 <xsl:param name="frame" select="0"/>
943 <xsl:apply-templates select="row"/>
944 <xsl:if test="$frame=1">
945 <xsl:text>\hline &#10;</xsl:text>
946 </xsl:if>
947 <xsl:call-template name="generate.table.caption.longtable"/>
948 <xsl:text>\\&#10;</xsl:text><!-- or should this be \tabularnewline? -->
949 <xsl:text> \endlastfoot&#10;</xsl:text>
950 </xsl:template>
952 <doc:template basename="tfoot" xmlns="">
953 <refpurpose>Process <doc:db>tfoot</doc:db> elements</refpurpose>
954 <doc:description>
955 <para>
956 Emits a continuation caption and calls <function condition="latex">endfoot</function>.
957 </para>
958 </doc:description>
959 <doc:variables>
960 &no_var;
961 </doc:variables>
962 </doc:template>
963 <xsl:template match="tfoot" mode="longtable.caption.continued" name="tfoot.longtable.caption.continued">
964 <xsl:param name="frame" select="0"/>
965 <xsl:apply-templates select="row"/>
966 <xsl:if test="$frame=1">
967 <xsl:text>\hline &#10;</xsl:text>
968 </xsl:if>
969 <xsl:text>\caption[]{</xsl:text>
970 <xsl:value-of select="$latex.table.caption.style"/>
971 <xsl:text>{</xsl:text>
972 <xsl:call-template name="gentext.template">
973 <xsl:with-param name="context" select="'table'"/>
974 <xsl:with-param name="name" select="'tfoot.continued'"/>
975 </xsl:call-template>
976 <xsl:text>}}\\&#10;</xsl:text><!-- or should this be \tabularnewline? -->
977 <xsl:text> \endfoot&#10;</xsl:text>
978 </xsl:template>
980 <doc:template basename="entry" xmlns="">
981 <refpurpose>Process a <doc:db>thead</doc:db>'s <doc:db>entry</doc:db> elements</refpurpose>
982 <doc:variables>
983 &no_var;
984 </doc:variables>
985 </doc:template>
986 <xsl:template match="thead/row/entry">
987 <xsl:call-template name="latex.entry.prealign"/>
988 <xsl:call-template name="latex.thead.row.entry"/>
989 <xsl:call-template name="latex.entry.postalign"/>
990 <xsl:if test="position()&lt;last()">
991 <xsl:call-template name="generate.latex.cell.separator">
992 <xsl:with-param name="which" select="'pre'"/>
993 </xsl:call-template>
994 </xsl:if>
995 </xsl:template>
997 <doc:template basename="entry" xmlns="">
998 <refpurpose>Process a <doc:db>tfoot</doc:db>'s <doc:db>entry</doc:db> elements</refpurpose>
999 <doc:variables>
1000 &no_var;
1001 </doc:variables>
1002 </doc:template>
1003 <xsl:template match="tfoot/row/entry">
1004 <xsl:call-template name="latex.entry.prealign"/>
1005 <xsl:call-template name="latex.tfoot.row.entry"/>
1006 <xsl:call-template name="latex.entry.postalign"/>
1007 <xsl:if test="position()&lt;last()">
1008 <xsl:call-template name="generate.latex.cell.separator">
1009 <xsl:with-param name="which" select="'pre'"/>
1010 </xsl:call-template>
1011 </xsl:if>
1012 </xsl:template>
1014 <doc:template xmlns="">
1015 <refpurpose>Process <doc:db>tbody</doc:db> elements</refpurpose>
1016 <doc:variables>
1017 &no_var;
1018 </doc:variables>
1019 </doc:template>
1020 <xsl:template match="tbody">
1021 <xsl:apply-templates/>
1022 </xsl:template>
1024 <doc:template basename="row" xmlns="">
1025 <refpurpose>Process a <doc:db>tbody</doc:db>'s <doc:db>row</doc:db> elements</refpurpose>
1026 <doc:variables>
1027 &no_var;
1028 </doc:variables>
1029 </doc:template>
1030 <xsl:template match="tbody/row">
1031 <xsl:apply-templates/>
1032 <xsl:text> \tabularnewline&#10;</xsl:text>
1033 <xsl:call-template name="generate.table.row.separator"/>
1034 </xsl:template>
1036 <doc:template basename="row" xmlns="">
1037 <refpurpose>Process a <doc:db>thead</doc:db>'s <doc:db>row</doc:db> elements</refpurpose>
1038 <doc:variables>
1039 &no_var;
1040 </doc:variables>
1041 </doc:template>
1042 <xsl:template match="thead/row">
1043 <xsl:apply-templates/>
1044 <xsl:text> \tabularnewline&#10;</xsl:text>
1045 <xsl:call-template name="generate.table.row.separator"/>
1046 </xsl:template>
1048 <doc:template basename="row" xmlns="">
1049 <refpurpose>Process a <doc:db>tfoot</doc:db>'s <doc:db>row</doc:db> elements</refpurpose>
1050 <doc:variables>
1051 &no_var;
1052 </doc:variables>
1053 </doc:template>
1054 <xsl:template match="tfoot/row">
1055 <xsl:call-template name="generate.table.row.separator"/>
1056 <xsl:apply-templates/>
1057 <xsl:text> \tabularnewline&#10;</xsl:text>
1058 </xsl:template>
1060 <!-- The rule below the last row in the table is controlled by the
1061 Frame attribute of the enclosing Table or InformalTable and the RowSep
1062 of the last row is ignored. If unspecified, this attribute is
1063 inherited from enclosing elements, rowsep=1 by default. -->
1064 <xsl:template name="generate.table.row.separator">
1065 <xsl:param name="rowsep">
1066 <xsl:choose>
1067 <xsl:when test="ancestor::tgroup/@rowsep!=''">
1068 <xsl:value-of select="number(ancestor::tgroup/@rowsep)"/>
1069 </xsl:when>
1070 <xsl:when test="ancestor::tgroup/../@rowsep!=''">
1071 <xsl:value-of select="number(ancestor::tgroup/../@rowsep)"/>
1072 </xsl:when>
1073 <xsl:otherwise>1</xsl:otherwise>
1074 </xsl:choose>
1075 </xsl:param>
1076 <xsl:variable name="parent_position" select="count(../preceding-sibling::node())+1"/>
1077 <xsl:variable name="grandparent_children" select="count(../../child::node())"/>
1078 <xsl:if test="$rowsep=1 and (position() != last() or $parent_position &lt; $grandparent_children)">
1079 <xsl:call-template name="table.row.separator"/>
1080 </xsl:if>
1081 </xsl:template>
1083 <xsl:template name="table.row.separator">
1084 <xsl:text> \hline &#10;</xsl:text>
1085 </xsl:template>
1087 <xsl:template match="tbody/row/entry">
1088 <xsl:call-template name="latex.entry.prealign"/>
1089 <xsl:apply-templates/>
1090 <xsl:call-template name="latex.entry.postalign"/>
1091 <xsl:if test="position()&lt;last()">
1092 <xsl:call-template name="generate.latex.cell.separator">
1093 <xsl:with-param name="which" select="'pre'"/>
1094 </xsl:call-template>
1095 </xsl:if>
1096 </xsl:template>
1098 <xsl:template name="latex.entry.prealign">
1099 <xsl:variable name="span">
1100 <xsl:choose>
1101 <xsl:when test="@spanname!=''">
1102 <xsl:call-template name="calculate.colspan">
1103 <xsl:with-param name="namest" select="../../../spanspec[@spanname=@spanname]/@namest"/>
1104 <xsl:with-param name="nameend" select="../../../spanspec[@spanname=@spanname]/@nameend"/>
1105 </xsl:call-template>
1106 </xsl:when>
1107 <xsl:when test="@namest!=''">
1108 <xsl:call-template name="calculate.colspan"/>
1109 </xsl:when>
1110 <xsl:otherwise>-1</xsl:otherwise>
1111 </xsl:choose>
1112 </xsl:variable>
1113 <!-- Remember: if multicolumn is present, generate.latex.cell.separator post needs to occur within multicolumn -->
1114 <xsl:if test="$span &gt; 1">
1115 <xsl:text>\multicolumn{</xsl:text>
1116 <xsl:value-of select="$span"/>
1117 <xsl:text>}{|</xsl:text><!-- TODO take heed of @colsep on BOTH sides!! -->
1118 <xsl:choose>
1119 <xsl:when test="@align='left'"><xsl:text>l</xsl:text></xsl:when>
1120 <xsl:when test="@align='right'"><xsl:text>r</xsl:text></xsl:when>
1121 <xsl:when test="@align='center'"><xsl:text>c</xsl:text></xsl:when>
1122 <xsl:when test="@align='char'">c<xsl:message>Table _entry_ 'char' alignment is not supported.</xsl:message></xsl:when>
1123 <xsl:otherwise>c</xsl:otherwise>
1124 </xsl:choose>
1125 <!-- use this as a hook for some general warnings -->
1126 <xsl:text>|}</xsl:text>
1127 </xsl:if>
1128 <!-- this is used when the entry's align spec wants to override the column default -->
1129 <xsl:if test="$span &lt; 1">
1130 <xsl:choose>
1131 <xsl:when test="@align='left'"><xsl:text>\docbooktolatexalignll </xsl:text></xsl:when>
1132 <xsl:when test="@align='right'"><xsl:text>\docbooktolatexalignrl </xsl:text></xsl:when>
1133 <xsl:when test="@align='center'"><xsl:text>\docbooktolatexaligncl </xsl:text></xsl:when>
1134 <xsl:when test="@align='char'"><xsl:message>Table _entry_ char alignment is not supported.</xsl:message></xsl:when>
1135 </xsl:choose>
1136 </xsl:if>
1137 <xsl:text>{</xsl:text>
1138 <xsl:call-template name="generate.latex.cell.separator">
1139 <xsl:with-param name="which" select="'post'"/>
1140 </xsl:call-template>
1141 <xsl:if test="@rotate='1'">
1142 <xsl:text>\rotatebox{90}</xsl:text>
1143 <xsl:if test="@align!=''"><xsl:message>entry[@rotate='1' and @align!=''] probably doesn't work.</xsl:message></xsl:if>
1144 </xsl:if>
1145 <xsl:text>{</xsl:text>
1146 <!-- use this as a hook for some general warnings -->
1147 <xsl:if test="@morerows!=''"><xsl:message>The morerows attribute is not supported.</xsl:message></xsl:if>
1148 </xsl:template>
1150 <xsl:template name="latex.entry.postalign">
1151 <xsl:text>}}</xsl:text>
1152 <!-- this is used when the entry's align spec wants to override the column default -->
1153 <xsl:if test="@namest='' and @spanspec=''"><!-- TODO improve -->
1154 <xsl:choose>
1155 <xsl:when test="@align='left'"><xsl:text>\docbooktolatexalignlr </xsl:text></xsl:when>
1156 <xsl:when test="@align='right'"><xsl:text>\docbooktolatexalignrr </xsl:text></xsl:when>
1157 <xsl:when test="@align='center'"><xsl:text>\docbooktolatexaligncr </xsl:text></xsl:when>
1158 </xsl:choose>
1159 </xsl:if>
1160 </xsl:template>
1162 <xsl:template name="process.cell">
1163 <xsl:param name="cellgi">td</xsl:param>
1164 <xsl:variable name="empty.cell" select="count(node()) = 0"/>
1166 <xsl:element name="{$cellgi}">
1167 <xsl:if test="@morerows">
1168 <xsl:attribute name="rowspan">
1169 <xsl:value-of select="@morerows+1"/>
1170 </xsl:attribute>
1171 </xsl:if>
1172 <xsl:if test="@namest">
1173 <xsl:attribute name="colspan">
1174 <xsl:call-template name="calculate.colspan"/>
1175 </xsl:attribute>
1176 </xsl:if>
1177 <xsl:if test="@align">
1178 <xsl:attribute name="align">
1179 <xsl:value-of select="@align"/>
1180 </xsl:attribute>
1181 </xsl:if>
1182 <xsl:if test="@char">
1183 <xsl:attribute name="char">
1184 <xsl:value-of select="@char"/>
1185 </xsl:attribute>
1186 </xsl:if>
1187 <xsl:if test="@charoff">
1188 <xsl:attribute name="charoff">
1189 <xsl:value-of select="@charoff"/>
1190 </xsl:attribute>
1191 </xsl:if>
1192 <xsl:if test="@valign">
1193 <xsl:attribute name="valign">
1194 <xsl:value-of select="@valign"/>
1195 </xsl:attribute>
1196 </xsl:if>
1198 <xsl:choose>
1199 <xsl:when test="$empty.cell">
1200 <xsl:text>&#160;</xsl:text>
1201 </xsl:when>
1202 <xsl:otherwise>
1203 <xsl:apply-templates/>
1204 </xsl:otherwise>
1205 </xsl:choose>
1206 </xsl:element>
1207 </xsl:template>
1209 <xsl:template name="generate.colgroup">
1210 <xsl:param name="cols" select="1"/>
1211 <xsl:param name="count" select="1"/>
1212 <xsl:choose>
1213 <xsl:when test="$count>$cols"></xsl:when>
1214 <xsl:otherwise>
1215 <xsl:call-template name="generate.col">
1216 <xsl:with-param name="countcol" select="$count"/>
1217 </xsl:call-template>
1218 <xsl:call-template name="generate.colgroup">
1219 <xsl:with-param name="cols" select="$cols"/>
1220 <xsl:with-param name="count" select="$count+1"/>
1221 </xsl:call-template>
1222 </xsl:otherwise>
1223 </xsl:choose>
1224 </xsl:template>
1226 <xsl:template name="generate.col">
1227 <xsl:param name="countcol">1</xsl:param>
1228 <xsl:param name="colspecs" select="./colspec"/>
1229 <xsl:param name="count">1</xsl:param>
1230 <xsl:param name="colnum">1</xsl:param>
1232 <xsl:choose>
1233 <xsl:when test="$count>count($colspecs)">
1234 <col/>
1235 </xsl:when>
1236 <xsl:otherwise>
1237 <xsl:variable name="colspec" select="$colspecs[$count=position()]"/>
1238 <xsl:variable name="colspec.colnum">
1239 <xsl:choose>
1240 <xsl:when test="$colspec/@colnum">
1241 <xsl:value-of select="$colspec/@colnum"/>
1242 </xsl:when>
1243 <xsl:otherwise>
1244 <xsl:value-of select="$colnum"/>
1245 </xsl:otherwise>
1246 </xsl:choose>
1247 </xsl:variable>
1249 <xsl:choose>
1250 <xsl:when test="$colspec.colnum=$countcol">
1251 <col>
1252 <xsl:if test="$colspec/@align">
1253 <xsl:attribute name="align">
1254 <xsl:value-of select="$colspec/@align"/>
1255 </xsl:attribute>
1256 </xsl:if>
1257 <xsl:if test="$colspec/@char">
1258 <xsl:attribute name="char">
1259 <xsl:value-of select="$colspec/@char"/>
1260 </xsl:attribute>
1261 </xsl:if>
1262 <xsl:if test="$colspec/@charoff">
1263 <xsl:attribute name="charoff">
1264 <xsl:value-of select="$colspec/@charoff"/>
1265 </xsl:attribute>
1266 </xsl:if>
1267 </col>
1268 </xsl:when>
1269 <xsl:otherwise>
1270 <xsl:call-template name="generate.col">
1271 <xsl:with-param name="countcol" select="$countcol"/>
1272 <xsl:with-param name="colspecs" select="$colspecs"/>
1273 <xsl:with-param name="count" select="$count+1"/>
1274 <xsl:with-param name="colnum">
1275 <xsl:choose>
1276 <xsl:when test="$colspec/@colnum">
1277 <xsl:value-of select="$colspec/@colnum + 1"/>
1278 </xsl:when>
1279 <xsl:otherwise>
1280 <xsl:value-of select="$colnum + 1"/>
1281 </xsl:otherwise>
1282 </xsl:choose>
1283 </xsl:with-param>
1284 </xsl:call-template>
1285 </xsl:otherwise>
1286 </xsl:choose>
1287 </xsl:otherwise>
1288 </xsl:choose>
1290 </xsl:template>
1292 <xsl:template name="colspec.colnum">
1293 <!-- when this macro is called, the current context must be an entry -->
1294 <xsl:param name="colname"></xsl:param>
1295 <!-- .. = row, ../.. = thead|tbody, ../../.. = tgroup -->
1296 <xsl:param name="colspecs" select="../../../../tgroup/colspec"/>
1297 <xsl:param name="count">1</xsl:param>
1298 <xsl:param name="colnum">1</xsl:param>
1299 <xsl:choose>
1300 <xsl:when test="$count>count($colspecs)"></xsl:when>
1301 <xsl:otherwise>
1302 <xsl:variable name="colspec" select="$colspecs[$count=position()]"/>
1303 <!--
1304 <xsl:value-of select="$count"/>:
1305 <xsl:value-of select="$colspec/@colname"/>=
1306 <xsl:value-of select="$colnum"/>
1308 <xsl:choose>
1309 <xsl:when test="$colspec/@colname=$colname">
1310 <xsl:choose>
1311 <xsl:when test="$colspec/@colnum">
1312 <xsl:value-of select="$colspec/@colnum"/>
1313 </xsl:when>
1314 <xsl:otherwise>
1315 <xsl:value-of select="$colnum"/>
1316 </xsl:otherwise>
1317 </xsl:choose>
1318 </xsl:when>
1319 <xsl:otherwise>
1320 <xsl:call-template name="colspec.colnum">
1321 <xsl:with-param name="colname" select="$colname"/>
1322 <xsl:with-param name="colspecs" select="$colspecs"/>
1323 <xsl:with-param name="count" select="$count+1"/>
1324 <xsl:with-param name="colnum">
1325 <xsl:choose>
1326 <xsl:when test="$colspec/@colnum">
1327 <xsl:value-of select="$colspec/@colnum + 1"/>
1328 </xsl:when>
1329 <xsl:otherwise>
1330 <xsl:value-of select="$colnum + 1"/>
1331 </xsl:otherwise>
1332 </xsl:choose>
1333 </xsl:with-param>
1334 </xsl:call-template>
1335 </xsl:otherwise>
1336 </xsl:choose>
1337 </xsl:otherwise>
1338 </xsl:choose>
1339 </xsl:template>
1341 <xsl:template name="colspec.colwidth">
1342 <!-- when this macro is called, the current context must be an entry -->
1343 <xsl:param name="colname"></xsl:param>
1344 <!-- .. = row, ../.. = thead|tbody, ../../.. = tgroup -->
1345 <xsl:param name="colspecs" select="../../../../tgroup/colspec"/>
1346 <xsl:param name="count">1</xsl:param>
1347 <xsl:choose>
1348 <xsl:when test="$count>count($colspecs)"></xsl:when>
1349 <xsl:otherwise>
1350 <xsl:variable name="colspec" select="$colspecs[$count=position()]"/>
1351 <xsl:choose>
1352 <xsl:when test="$colspec/@colname=$colname">
1353 <xsl:value-of select="$colspec/@colwidth"/>
1354 </xsl:when>
1355 <xsl:otherwise>
1356 <xsl:call-template name="colspec.colwidth">
1357 <xsl:with-param name="colname" select="$colname"/>
1358 <xsl:with-param name="colspecs" select="$colspecs"/>
1359 <xsl:with-param name="count" select="$count+1"/>
1360 </xsl:call-template>
1361 </xsl:otherwise>
1362 </xsl:choose>
1363 </xsl:otherwise>
1364 </xsl:choose>
1365 </xsl:template>
1367 <xsl:template name="calculate.colspan">
1368 <xsl:param name="namest" select="@namest"/>
1369 <xsl:param name="nameend" select="@nameend"/>
1370 <xsl:variable name="scol">
1371 <xsl:call-template name="colspec.colnum">
1372 <xsl:with-param name="colname" select="$namest"/>
1373 </xsl:call-template>
1374 </xsl:variable>
1375 <xsl:variable name="ecol">
1376 <xsl:call-template name="colspec.colnum">
1377 <xsl:with-param name="colname" select="$nameend"/>
1378 </xsl:call-template>
1379 </xsl:variable>
1380 <xsl:value-of select="$ecol - $scol + 1"/>
1381 </xsl:template>
1383 <!-- write docs:
1384 The pre/post mechanism is to deal with multicolumn, which
1385 needs to be the first command within a cell.
1387 <xsl:template name="generate.latex.cell.separator">
1388 <xsl:param name="which"/>
1389 <xsl:choose>
1390 <xsl:when test="$which='pre'">
1391 <xsl:if test="$latex.entities='catcode'">
1392 <xsl:text> \catcode`\&amp;=4</xsl:text>
1393 </xsl:if>
1394 <xsl:text> &amp; </xsl:text>
1395 </xsl:when>
1396 <xsl:when test="$which='post'">
1397 <xsl:if test="$latex.entities='catcode'">
1398 <xsl:text>\catcode`\&amp;=\active </xsl:text>
1399 </xsl:if>
1400 </xsl:when>
1401 <xsl:otherwise>
1402 <xsl:choose>
1403 <xsl:when test="$latex.entities='catcode'">
1404 <xsl:text> \catcode`\&amp;=4 &amp;\catcode`\&amp;=\active </xsl:text>
1405 </xsl:when>
1406 <xsl:otherwise>
1407 <xsl:text> &amp; </xsl:text>
1408 </xsl:otherwise>
1409 </xsl:choose>
1410 </xsl:otherwise>
1411 </xsl:choose>
1412 </xsl:template>
1414 </xsl:stylesheet>