1<?xml version='1.0'?>
2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
4                xmlns:fo="http://www.w3.org/1999/XSL/Format"
5                xmlns:stbl="http://nwalsh.com/xslt/ext/com.nwalsh.saxon.Table"
6                xmlns:xtbl="com.nwalsh.xalan.Table"
7                xmlns:lxslt="http://xml.apache.org/xslt"
8                exclude-result-prefixes="doc stbl xtbl lxslt"
9                version='1.0'>
10
11<!-- ********************************************************************
12     $Id$
13     ********************************************************************
14
15     This file is part of the XSL DocBook Stylesheet distribution.
16     See /README or http://nwalsh.com/docbook/xsl/ for copyright
17     and other information.
18
19     ******************************************************************** -->
20
21<doc:reference xmlns="">
22<referenceinfo>
23<releaseinfo role="meta">
24$Id$
25</releaseinfo>
26<author><surname>Walsh</surname>
27<firstname>Norman</firstname></author>
28<copyright><year>1999</year><year>2000</year>
29<holder>Norman Walsh</holder>
30</copyright>
31</referenceinfo>
32<title>Formatting Object Table Reference</title>
33
34<partintro>
35<section><title>Introduction</title>
36
37<para>This is technical reference documentation for the DocBook XSL
38Stylesheets; it documents (some of) the parameters, templates, and
39other elements of the stylesheets.</para>
40
41<para>This is not intended to be <quote>user</quote> documentation.
42It is provided for developers writing customization layers for the
43stylesheets, and for anyone who's interested in <quote>how it
44works</quote>.</para>
45
46<para>Although I am trying to be thorough, this documentation is known
47to be incomplete. Don't forget to read the source, too :-)</para>
48</section>
49</partintro>
50</doc:reference>
51
52<!-- ==================================================================== -->
53
54<lxslt:component prefix="xtbl"
55                 functions="adjustColumnWidths"/>
56
57<!-- ==================================================================== -->
58
59<xsl:param name="table-border-thickness" select="'0.5pt'"/>
60<xsl:param name="table-border-padding" select="'2pt'"/>
61<xsl:param name="table-border-style" select="'solid'"/>
62<xsl:param name="table-border-color" select="'black'"/>
63
64<!-- ==================================================================== -->
65
66<xsl:template name="border">
67  <xsl:param name="side" select="'left'"/>
68  <xsl:param name="padding" select="0"/>
69
70  <xsl:attribute name="border-{$side}">
71    <xsl:value-of select="$table-border-thickness"/>
72    <xsl:text> </xsl:text>
73    <xsl:value-of select="$table-border-style"/>
74    <xsl:text> </xsl:text>
75    <xsl:value-of select="$table-border-color"/>
76    <xsl:text> </xsl:text>
77  </xsl:attribute>
78  <xsl:if test="$padding != 0">
79    <xsl:attribute name="padding-{$side}">
80      <xsl:value-of select="$table-border-padding"/>
81    </xsl:attribute>
82  </xsl:if>
83</xsl:template>
84
85<!-- ==================================================================== -->
86
87<xsl:template match="tgroup">
88  <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
89
90  <xsl:variable name="explicit.table.width">
91    <xsl:call-template name="dbfo-attribute">
92      <xsl:with-param name="pis"
93                      select="/processing-instruction('dbfo')"/>
94      <xsl:with-param name="attribute" select="'table-width'"/>
95    </xsl:call-template>
96  </xsl:variable>
97
98  <xsl:variable name="table.width">
99    <xsl:choose>
100      <xsl:when test="$explicit.table.width != ''">
101        <xsl:value-of select="$explicit.table.width"/>
102      </xsl:when>
103      <xsl:when test="$default.table.width = ''">
104        <xsl:text>100%</xsl:text>
105      </xsl:when>
106      <xsl:otherwise>
107        <xsl:value-of select="$default.table.width"/>
108      </xsl:otherwise>
109    </xsl:choose>
110  </xsl:variable>
111
112  <xsl:variable name="colspecs">
113    <xsl:choose>
114      <xsl:when test="$use.extensions != 0
115                      and $tablecolumns.extension != 0">
116        <xsl:call-template name="generate.colgroup.raw">
117          <xsl:with-param name="cols" select="@cols"/>
118        </xsl:call-template>
119      </xsl:when>
120      <xsl:otherwise>
121        <xsl:call-template name="generate.colgroup">
122          <xsl:with-param name="cols" select="@cols"/>
123        </xsl:call-template>
124      </xsl:otherwise>
125    </xsl:choose>
126  </xsl:variable>
127
128  <xsl:choose>
129    <xsl:when test="$use.extensions != 0
130                    and $tablecolumns.extension != 0">
131      <xsl:choose>
132        <xsl:when test="contains($vendor, 'SAXON 6')">
133          <xsl:copy-of select="stbl:adjustColumnWidths($colspecs)"/>
134        </xsl:when>
135        <xsl:when test="contains($vendor, 'SAXON 5')">
136          <!-- the saxon5 extension doesn't support this (yet) -->
137          <xsl:call-template name="generate.colgroup">
138            <xsl:with-param name="cols" select="@cols"/>
139          </xsl:call-template>
140        </xsl:when>
141        <xsl:when test="contains($vendor, 'Apache Software Foundation')">
142          <xsl:copy-of select="xtbl:adjustColumnWidths($colspecs)"/>
143        </xsl:when>
144        <xsl:otherwise>
145          <xsl:message terminate="yes">
146            <xsl:text>Don't know how to do adjust column widths with </xsl:text>
147            <xsl:value-of select="$vendor"/>
148          </xsl:message>
149        </xsl:otherwise>
150      </xsl:choose>
151    </xsl:when>
152    <xsl:otherwise>
153      <xsl:copy-of select="$colspecs"/>
154    </xsl:otherwise>
155  </xsl:choose>
156
157  <xsl:apply-templates select="thead"/>
158  <xsl:apply-templates select="tbody"/>
159  <xsl:apply-templates select="tfoot"/>
160</xsl:template>
161
162<xsl:template match="colspec"></xsl:template>
163
164<xsl:template match="spanspec"></xsl:template>
165
166<xsl:template match="thead">
167  <xsl:variable name="tgroup" select="parent::*"/>
168  <xsl:variable name="frame" select="$tgroup/parent::*/@frame"/>
169
170  <fo:table-header>
171    <xsl:choose>
172      <xsl:when test="$frame='topbot' or $frame='top'">
173        <xsl:call-template name="border">
174          <xsl:with-param name="side" select="'top'"/>
175        </xsl:call-template>
176      </xsl:when>
177      <xsl:when test="$frame='sides'">
178        <xsl:call-template name="border">
179          <xsl:with-param name="side" select="'left'"/>
180        </xsl:call-template>
181        <xsl:call-template name="border">
182          <xsl:with-param name="side" select="'right'"/>
183        </xsl:call-template>
184      </xsl:when>
185    </xsl:choose>
186    <xsl:apply-templates/>
187  </fo:table-header>
188</xsl:template>
189
190<xsl:template match="tbody">
191  <xsl:variable name="tgroup" select="parent::*"/>
192  <xsl:variable name="frame" select="$tgroup/parent::*/@frame"/>
193  <fo:table-body>
194    <xsl:choose>
195      <xsl:when test="$frame='top'">
196        <xsl:choose>
197          <xsl:when test="preceding-sibling::thead">
198          </xsl:when>
199          <xsl:otherwise>
200            <xsl:call-template name="border">
201              <xsl:with-param name="side" select="'top'"/>
202            </xsl:call-template>
203          </xsl:otherwise>
204        </xsl:choose>
205      </xsl:when>
206      <xsl:when test="$frame='bottom'">
207        <xsl:choose>
208          <xsl:when test="preceding-sibling::tfoot">
209          </xsl:when>
210          <xsl:otherwise>
211            <xsl:call-template name="border">
212              <xsl:with-param name="side" select="'bottom'"/>
213            </xsl:call-template>
214          </xsl:otherwise>
215        </xsl:choose>
216      </xsl:when>
217      <xsl:when test="$frame='topbot'">
218        <xsl:choose>
219          <xsl:when test="preceding-sibling::thead">
220          </xsl:when>
221          <xsl:otherwise>
222            <xsl:call-template name="border">
223              <xsl:with-param name="side" select="'top'"/>
224            </xsl:call-template>
225          </xsl:otherwise>
226        </xsl:choose>
227        <xsl:choose>
228          <xsl:when test="preceding-sibling::tfoot">
229          </xsl:when>
230          <xsl:otherwise>
231            <xsl:call-template name="border">
232              <xsl:with-param name="side" select="'bottom'"/>
233            </xsl:call-template>
234          </xsl:otherwise>
235        </xsl:choose>
236      </xsl:when>
237      <xsl:when test="$frame='sides'">
238        <xsl:call-template name="border">
239          <xsl:with-param name="side" select="'left'"/>
240        </xsl:call-template>
241        <xsl:call-template name="border">
242          <xsl:with-param name="side" select="'right'"/>
243        </xsl:call-template>
244      </xsl:when>
245    </xsl:choose>
246    <xsl:apply-templates/>
247  </fo:table-body>
248</xsl:template>
249
250<xsl:template match="row">
251  <fo:table-row>
252    <xsl:if test="@rowsep='1'">
253      <xsl:call-template name="border">
254        <xsl:with-param name="side" select="'bottom'"/>
255      </xsl:call-template>
256    </xsl:if>
257    <xsl:apply-templates/>
258  </fo:table-row>
259</xsl:template>
260
261<xsl:template match="thead/row/entry">
262  <xsl:call-template name="process.cell"/>
263</xsl:template>
264
265<xsl:template match="tbody/row/entry">
266  <xsl:call-template name="process.cell"/>
267</xsl:template>
268
269<xsl:template match="tfoot/row/entry">
270  <xsl:call-template name="process.cell"/>
271</xsl:template>
272
273<xsl:template name="process.cell">
274  <xsl:variable name="row" select="parent::row"/>
275  <xsl:variable name="group" select="$row/parent::*[1]"/>
276  <xsl:variable name="frame" select="ancestor::tgroup/parent::*/@frame"/>
277
278  <xsl:variable name="content">
279    <xsl:apply-templates/>
280  </xsl:variable>
281
282  <fo:table-cell>
283    <xsl:choose>
284      <xsl:when test="$frame='all'">
285        <xsl:call-template name="border">
286          <xsl:with-param name="side" select="'left'"/>
287          <xsl:with-param name="padding" select="1"/>
288        </xsl:call-template>
289        <xsl:call-template name="border">
290          <xsl:with-param name="side" select="'right'"/>
291          <xsl:with-param name="padding" select="1"/>
292        </xsl:call-template>
293        <xsl:call-template name="border">
294          <xsl:with-param name="side" select="'top'"/>
295          <xsl:with-param name="padding" select="1"/>
296        </xsl:call-template>
297        <xsl:call-template name="border">
298          <xsl:with-param name="side" select="'bottom'"/>
299          <xsl:with-param name="padding" select="1"/>
300        </xsl:call-template>
301      </xsl:when>
302      <xsl:otherwise>
303        <xsl:if test="@colsep='1'">
304          <xsl:call-template name="border">
305            <xsl:with-param name="side" select="'right'"/>
306            <xsl:with-param name="padding" select="1"/>
307          </xsl:call-template>
308        </xsl:if>
309        <xsl:if test="@rowsep='1'">
310          <xsl:call-template name="border">
311            <xsl:with-param name="side" select="'bottom'"/>
312            <xsl:with-param name="padding" select="1"/>
313          </xsl:call-template>
314        </xsl:if>
315      </xsl:otherwise>
316    </xsl:choose>
317
318    <xsl:if test="@morerows">
319      <xsl:attribute name="number-rows-spanned">
320        <xsl:value-of select="@morerows+1"/>
321      </xsl:attribute>
322    </xsl:if>
323    <xsl:if test="@namest">
324      <xsl:attribute name="number-columns-spanned">
325        <xsl:call-template name="calculate.colspan"/>
326      </xsl:attribute>
327    </xsl:if>
328
329    <fo:block>
330      <xsl:copy-of select="$content"/>
331    </fo:block>
332  </fo:table-cell>
333</xsl:template>
334
335<xsl:template name="generate.colgroup.raw">
336  <xsl:param name="cols" select="1"/>
337  <xsl:param name="count" select="1"/>
338
339  <xsl:choose>
340    <xsl:when test="$count>$cols"></xsl:when>
341    <xsl:otherwise>
342      <xsl:call-template name="generate.col.raw">
343        <xsl:with-param name="countcol" select="$count"/>
344      </xsl:call-template>
345      <xsl:call-template name="generate.colgroup.raw">
346        <xsl:with-param name="cols" select="$cols"/>
347        <xsl:with-param name="count" select="$count+1"/>
348      </xsl:call-template>
349    </xsl:otherwise>
350  </xsl:choose>
351</xsl:template>
352
353<xsl:template name="generate.colgroup">
354  <xsl:param name="cols" select="1"/>
355  <xsl:param name="count" select="1"/>
356
357  <xsl:choose>
358    <xsl:when test="$count>$cols"></xsl:when>
359    <xsl:otherwise>
360      <xsl:call-template name="generate.col">
361        <xsl:with-param name="countcol" select="$count"/>
362      </xsl:call-template>
363      <xsl:call-template name="generate.colgroup">
364        <xsl:with-param name="cols" select="$cols"/>
365        <xsl:with-param name="count" select="$count+1"/>
366      </xsl:call-template>
367    </xsl:otherwise>
368  </xsl:choose>
369</xsl:template>
370
371<xsl:template name="generate.col.raw">
372  <!-- generate the table-column for column countcol -->
373  <xsl:param name="countcol">1</xsl:param>
374  <xsl:param name="colspecs" select="/colspec"/>
375  <xsl:param name="count">1</xsl:param>
376  <xsl:param name="colnum">1</xsl:param>
377
378  <xsl:choose>
379    <xsl:when test="$count>count($colspecs)">
380      <fo:table-column column-number="{$countcol}"/>
381    </xsl:when>
382    <xsl:otherwise>
383      <xsl:variable name="colspec" select="$colspecs[$count=position()]"/>
384
385      <xsl:variable name="colspec.colnum">
386        <xsl:choose>
387          <xsl:when test="$colspec/@colnum">
388            <xsl:value-of select="$colspec/@colnum"/>
389          </xsl:when>
390          <xsl:otherwise>
391            <xsl:value-of select="$colnum"/>
392          </xsl:otherwise>
393        </xsl:choose>
394      </xsl:variable>
395
396      <xsl:variable name="colspec.colwidth">
397        <xsl:choose>
398          <xsl:when test="$colspec/@colwidth">
399            <xsl:value-of select="$colspec/@colwidth"/>
400          </xsl:when>
401          <xsl:otherwise>1*</xsl:otherwise>
402        </xsl:choose>
403      </xsl:variable>
404
405      <xsl:choose>
406        <xsl:when test="$colspec.colnum=$countcol">
407          <fo:table-column column-number="{$countcol}">
408            <xsl:attribute name="column-width">
409              <xsl:value-of select="$colspec.colwidth"/>
410            </xsl:attribute>
411          </fo:table-column>
412        </xsl:when>
413        <xsl:otherwise>
414          <xsl:call-template name="generate.col.raw">
415            <xsl:with-param name="countcol" select="$countcol"/>
416            <xsl:with-param name="colspecs" select="$colspecs"/>
417            <xsl:with-param name="count" select="$count+1"/>
418            <xsl:with-param name="colnum">
419              <xsl:choose>
420                <xsl:when test="$colspec/@colnum">
421                  <xsl:value-of select="$colspec/@colnum + 1"/>
422                </xsl:when>
423                <xsl:otherwise>
424                  <xsl:value-of select="$colnum + 1"/>
425                </xsl:otherwise>
426              </xsl:choose>
427            </xsl:with-param>
428           </xsl:call-template>
429        </xsl:otherwise>
430      </xsl:choose>
431    </xsl:otherwise>
432  </xsl:choose>
433</xsl:template>
434
435<xsl:template name="generate.col">
436  <!-- generate the table-column for column countcol -->
437  <xsl:param name="countcol">1</xsl:param>
438  <xsl:param name="colspecs" select="/colspec"/>
439  <xsl:param name="count">1</xsl:param>
440  <xsl:param name="colnum">1</xsl:param>
441
442  <xsl:choose>
443    <xsl:when test="$count>count($colspecs)">
444      <fo:table-column column-number="{$countcol}">
445	<xsl:variable name="colwidth">
446	  <xsl:call-template name="calc.column.width"/>
447	</xsl:variable>
448	<xsl:if test="$colwidth != 'proportional-column-width(1)'">
449	  <xsl:attribute name="column-width">
450	    <xsl:value-of select="$colwidth"/>
451	  </xsl:attribute>
452	</xsl:if>
453      </fo:table-column>
454    </xsl:when>
455    <xsl:otherwise>
456      <xsl:variable name="colspec" select="$colspecs[$count=position()]"/>
457
458      <xsl:variable name="colspec.colnum">
459        <xsl:choose>
460          <xsl:when test="$colspec/@colnum">
461            <xsl:value-of select="$colspec/@colnum"/>
462          </xsl:when>
463          <xsl:otherwise>
464            <xsl:value-of select="$colnum"/>
465          </xsl:otherwise>
466        </xsl:choose>
467      </xsl:variable>
468
469      <xsl:variable name="colspec.colwidth">
470        <xsl:choose>
471          <xsl:when test="$colspec/@colwidth">
472            <xsl:value-of select="$colspec/@colwidth"/>
473          </xsl:when>
474          <xsl:otherwise>1*</xsl:otherwise>
475        </xsl:choose>
476      </xsl:variable>
477
478      <xsl:choose>
479        <xsl:when test="$colspec.colnum=$countcol">
480          <fo:table-column column-number="{$countcol}">
481	    <xsl:variable name="colwidth">
482              <xsl:call-template name="calc.column.width">
483                <xsl:with-param name="colwidth">
484                  <xsl:value-of select="$colspec.colwidth"/>
485                </xsl:with-param>
486	      </xsl:call-template>
487	    </xsl:variable>
488	    <xsl:if test="$colwidth != 'proportional-column-width(1)'">
489	      <xsl:attribute name="column-width">
490		<xsl:value-of select="$colwidth"/>
491	      </xsl:attribute>
492	    </xsl:if>
493	  </fo:table-column>
494        </xsl:when>
495        <xsl:otherwise>
496          <xsl:call-template name="generate.col">
497            <xsl:with-param name="countcol" select="$countcol"/>
498            <xsl:with-param name="colspecs" select="$colspecs"/>
499            <xsl:with-param name="count" select="$count+1"/>
500            <xsl:with-param name="colnum">
501              <xsl:choose>
502                <xsl:when test="$colspec/@colnum">
503                  <xsl:value-of select="$colspec/@colnum + 1"/>
504                </xsl:when>
505                <xsl:otherwise>
506                  <xsl:value-of select="$colnum + 1"/>
507                </xsl:otherwise>
508              </xsl:choose>
509            </xsl:with-param>
510           </xsl:call-template>
511        </xsl:otherwise>
512      </xsl:choose>
513    </xsl:otherwise>
514  </xsl:choose>
515</xsl:template>
516
517<doc:template name="calc.column.width" xmlns="">
518<refpurpose>Calculate an XSL FO table column width specification from a
519CALS table column width specification.</refpurpose>
520
521<refdescription>
522<para>CALS expresses table column widths in the following basic
523forms:</para>
524
525<itemizedlist>
526<listitem>
527<para><emphasis>99.99units</emphasis>, a fixed length specifier.</para>
528</listitem>
529<listitem>
530<para><emphasis>99.99</emphasis>, a fixed length specifier without any units.</para>
531</listitem>
532<listitem>
533<para><emphasis>99.99*</emphasis>, a relative length specifier.</para>
534</listitem>
535<listitem>
536<para><emphasis>99.99*+99.99units</emphasis>, a combination of both.</para>
537</listitem>
538</itemizedlist>
539
540<para>The CALS units are points (pt), picas (pi), centimeters (cm),
541millimeters (mm), and inches (in). These are the same units as XSL,
542except that XSL abbreviates picas "pc" instead of "pi". If a length
543specifier has no units, the CALS default unit (pt) is assumed.</para>
544
545<para>Relative length specifiers are represented in XSL with the
546proportional-column-width() function.</para>
547
548<para>Here are some examples:</para>
549
550<itemizedlist>
551<listitem>
552<para>"36pt" becomes "36pt"</para>
553</listitem>
554<listitem>
555<para>"3pi" becomes "3pc"</para>
556</listitem>
557<listitem>
558<para>"36" becomes "36pt"</para>
559</listitem>
560<listitem>
561<para>"3*" becomes "proportional-column-width(3)"</para>
562</listitem>
563<listitem>
564<para>"3*+2pi" becomes "proportional-column-width(3)+2pc"</para>
565</listitem>
566<listitem>
567<para>"1*+2" becomes "proportional-column-width(1)+2pt"</para>
568</listitem>
569</itemizedlist>
570</refdescription>
571
572<refparameter>
573<variablelist>
574<varlistentry><term>colwidth</term>
575<listitem>
576<para>The CALS column width specification.</para>
577</listitem>
578</varlistentry>
579</variablelist>
580</refparameter>
581
582<refreturn>
583<para>The XSL column width specification.</para>
584</refreturn>
585</doc:template>
586
587<xsl:template name="calc.column.width">
588  <xsl:param name="colwidth">1*</xsl:param>
589
590  <!-- Ok, the colwidth could have any one of the following forms: -->
591  <!--        1*       = proportional width -->
592  <!--     1unit       = 1.0 units wide -->
593  <!--         1       = 1pt wide -->
594  <!--  1*+1unit       = proportional width + some fixed width -->
595  <!--      1*+1       = proportional width + some fixed width -->
596
597  <!-- If it has a proportional width, translate it to XSL -->
598  <xsl:if test="contains($colwidth, '*')">
599    <xsl:text>proportional-column-width(</xsl:text>
600    <xsl:value-of select="substring-before($colwidth, '*')"/>
601    <xsl:text>)</xsl:text>
602  </xsl:if>
603
604  <!-- Now grab the non-proportional part of the specification -->
605  <xsl:variable name="width-units">
606    <xsl:choose>
607      <xsl:when test="contains($colwidth, '*')">
608        <xsl:value-of
609             select="normalize-space(substring-after($colwidth, '*'))"/>
610      </xsl:when>
611      <xsl:otherwise>
612        <xsl:value-of select="normalize-space($colwidth)"/>
613      </xsl:otherwise>
614    </xsl:choose>
615  </xsl:variable>
616
617  <!-- Ok, now the width-units could have any one of the following forms: -->
618  <!--                 = <empty string> -->
619  <!--     1unit       = 1.0 units wide -->
620  <!--         1       = 1pt wide -->
621  <!-- with an optional leading sign -->
622
623  <!-- Grab the width part by blanking out the units part and discarding -->
624  <!-- whitespace. It's not pretty, but it works. -->
625  <xsl:variable name="width"
626       select="normalize-space(translate($width-units,
627                                         '+-0123456789.abcdefghijklmnopqrstuvwxyz',
628                                         '+-0123456789.'))"/>
629
630  <!-- Grab the units part by blanking out the width part and discarding -->
631  <!-- whitespace. It's not pretty, but it works. -->
632  <xsl:variable name="units"
633       select="normalize-space(translate($width-units,
634                                         'abcdefghijklmnopqrstuvwxyz+-0123456789.',
635                                         'abcdefghijklmnopqrstuvwxyz'))"/>
636
637  <!-- Output the width -->
638  <xsl:value-of select="$width"/>
639
640  <!-- Output the units, translated appropriately -->
641  <xsl:choose>
642    <xsl:when test="$units = 'pi'">pc</xsl:when>
643    <xsl:when test="$units = '' and $width != ''">pt</xsl:when>
644    <xsl:otherwise><xsl:value-of select="$units"/></xsl:otherwise>
645  </xsl:choose>
646</xsl:template>
647
648<xsl:template name="colspec.colnum">
649  <!-- when this macro is called, the current context must be an entry -->
650  <xsl:param name="colname"></xsl:param>
651  <!-- .. = row, ../.. = thead|tbody, ../../.. = tgroup -->
652  <xsl:param name="colspecs" select="/tgroup/colspec"/>
653  <xsl:param name="count">1</xsl:param>
654  <xsl:param name="colnum">1</xsl:param>
655  <xsl:choose>
656    <xsl:when test="$count>count($colspecs)"></xsl:when>
657    <xsl:otherwise>
658      <xsl:variable name="colspec" select="$colspecs[$count=position()]"/>
659<!--
660      <xsl:value-of select="$count"/>:
661      <xsl:value-of select="$colspec/@colname"/>=
662      <xsl:value-of select="$colnum"/>
663-->
664      <xsl:choose>
665        <xsl:when test="$colspec/@colname=$colname">
666          <xsl:choose>
667            <xsl:when test="$colspec/@colnum">
668              <xsl:value-of select="$colspec/@colnum"/>
669            </xsl:when>
670            <xsl:otherwise>
671              <xsl:value-of select="$colnum"/>
672            </xsl:otherwise>
673          </xsl:choose>
674        </xsl:when>
675        <xsl:otherwise>
676          <xsl:call-template name="colspec.colnum">
677            <xsl:with-param name="colname" select="$colname"/>
678            <xsl:with-param name="colspecs" select="$colspecs"/>
679            <xsl:with-param name="count" select="$count+1"/>
680            <xsl:with-param name="colnum">
681              <xsl:choose>
682                <xsl:when test="$colspec/@colnum">
683                  <xsl:value-of select="$colspec/@colnum + 1"/>
684                </xsl:when>
685                <xsl:otherwise>
686                  <xsl:value-of select="$colnum + 1"/>
687                </xsl:otherwise>
688              </xsl:choose>
689            </xsl:with-param>
690           </xsl:call-template>
691        </xsl:otherwise>
692      </xsl:choose>
693    </xsl:otherwise>
694  </xsl:choose>
695</xsl:template>
696
697<xsl:template name="calculate.colspan">
698  <xsl:variable name="scol">
699    <xsl:call-template name="colspec.colnum">
700      <xsl:with-param name="colname" select="@namest"/>
701    </xsl:call-template>
702  </xsl:variable>
703  <xsl:variable name="ecol">
704    <xsl:call-template name="colspec.colnum">
705      <xsl:with-param name="colname" select="@nameend"/>
706    </xsl:call-template>
707  </xsl:variable>
708  <xsl:value-of select="$ecol - $scol + 1"/>
709</xsl:template>
710
711<!-- ==================================================================== -->
712
713</xsl:stylesheet>
714