2
<!DOCTYPE xsl:stylesheet [ <!ENTITY % xsldoc.ent SYSTEM "./xsldoc.ent"> %xsldoc.ent; ]>
3
<!--#############################################################################
4
| $Id: lists.mod.xsl,v 1.25 2004/01/31 11:53:50 j-devenish Exp $
5
|- #############################################################################
6
| $Author: j-devenish $
7
+ ############################################################################## -->
10
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
11
xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
12
exclude-result-prefixes="doc" version='1.0'>
14
<doc:reference id="lists" xmlns="">
16
<releaseinfo role="meta">
17
$Id: lists.mod.xsl,v 1.25 2004/01/31 11:53:50 j-devenish Exp $
24
<year>2000</year><year>2001</year><year>2002</year><year>2003</year><year>2004</year>
25
<holder>Ramon Casellas</holder>
28
<doc:revision rcasver="1.16">&rev_2003_05;</doc:revision>
31
<title>Lists <filename>lists.mod.xsl</filename></title>
41
<doc:template xmlns="">
42
<refpurpose>Process titles for <doc:db>variablelist</doc:db>, <doc:db>orderedlist</doc:db>, <doc:db>itemizedlist</doc:db> and <doc:db>simplelist</doc:db> elements</refpurpose>
53
<term><xref linkend="param.latex.list.title.style"/></term>
55
The &LaTeX; command for formatting titles.
64
<listitem><simpara>The &LaTeX; command to use. Defaults to
65
<xref linkend="param.latex.list.title.style"/>.</simpara></listitem>
71
Applies templates as a paragraph, formatted with the specified style.
75
<xsl:template match="variablelist/title|orderedlist/title|itemizedlist/title|simplelist/title">
76
<xsl:param name="style" select="$latex.list.title.style"/>
77
<xsl:text> {</xsl:text>
78
<xsl:value-of select="$style"/>
79
<xsl:text>{</xsl:text>
80
<xsl:apply-templates/>
81
<xsl:text>}} </xsl:text>
84
<doc:template basename="listitem" xmlns="">
85
<refpurpose>Process <doc:db>listitem</doc:db> elements</refpurpose>
96
Applies templates within a &LaTeX; <function condition="latex">item</function>
101
<xsl:template match="listitem">
102
<xsl:text> %--- Item </xsl:text>
103
<xsl:text>\item </xsl:text>
104
<xsl:apply-templates/>
105
<xsl:text> </xsl:text>
108
<doc:template xmlns="">
109
<refpurpose>Process <doc:db>itemizedlist</doc:db> elements</refpurpose>
112
Formats an itemised list.
117
<listitem><simpara><xref linkend="param.latex.use.noindent"/></simpara></listitem>
122
Applies templates. Uses a &LaTeX; <function condition="env">itemize</function>
126
The <sgmltag class="attribute">spacing</sgmltag>=<quote>compact</quote>
127
attribute is recognised.
131
<simplelist type='inline'>
138
<xsl:template match="itemizedlist">
139
<xsl:apply-templates select="node()[not(self::listitem)]"/>
140
<xsl:call-template name="compactlist.pre"/>
141
<xsl:text> \begin{itemize}</xsl:text>
142
<xsl:call-template name="compactlist.begin"/>
143
<xsl:apply-templates select="listitem"/>
144
<xsl:text>\end{itemize} </xsl:text>
145
<xsl:call-template name="compactlist.post"/>
148
<doc:template xmlns="">
149
<refpurpose>Process <doc:db>variablelist</doc:db> elements</refpurpose>
152
Formats a list in which each item is denoted by a textual label.
157
<listitem><simpara><xref linkend="param.latex.use.noindent"/></simpara></listitem>
162
Applies templates. Uses a &LaTeX; <function condition="env">description</function>
167
<simplelist type='inline'>
175
<xsl:template match="variablelist">
176
<xsl:apply-templates select="node()[not(self::varlistentry)]"/>
177
<xsl:text> \begin{description} </xsl:text>
178
<xsl:apply-templates select="varlistentry"/>
179
<xsl:text>\end{description} </xsl:text>
180
<xsl:if test="$latex.use.noindent=1">
181
<xsl:text>\noindent </xsl:text>
185
<doc:template xmlns="">
186
<refpurpose>Process <doc:db>orderedlist</doc:db> elements</refpurpose>
189
Formats a list in which each item is denoted by a numeric label.
194
<listitem><simpara><xref linkend="param.latex.use.noindent"/></simpara></listitem>
198
<para>The only &DocBook; attribute that is supported is <sgmltag class="attribute">numeration</sgmltag>.</para>
200
Applies templates. Uses a &LaTeX; <function condition="env">enumerate</function>
204
The <sgmltag class="attribute">spacing</sgmltag>=<quote>compact</quote>
205
attribute is recognised.
208
The <sgmltag class="attribute">numeration</sgmltag> attribute
213
<simplelist type='inline'>
219
<xsl:template match="orderedlist">
220
<xsl:variable name="numeration">
222
<xsl:when test="@numeration">
223
<xsl:value-of select="@numeration"/>
226
<xsl:value-of select="arabic"/>
230
<xsl:apply-templates select="node()[not(self::listitem)]"/>
231
<xsl:call-template name="compactlist.pre"/>
232
<xsl:text> \begin{enumerate}</xsl:text>
233
<xsl:if test="@numeration">
235
<xsl:when test="@numeration='arabic'"> <xsl:text>[1]</xsl:text> </xsl:when>
236
<xsl:when test="@numeration='upperalpha'"><xsl:text>[A]</xsl:text> </xsl:when>
237
<xsl:when test="@numeration='loweralpha'"><xsl:text>[a]</xsl:text> </xsl:when>
238
<xsl:when test="@numeration='upperroman'"><xsl:text>[I]</xsl:text> </xsl:when>
239
<xsl:when test="@numeration='lowerroman'"><xsl:text>[i]</xsl:text> </xsl:when>
242
<xsl:call-template name="compactlist.begin"/>
243
<xsl:apply-templates select="listitem"/>
244
<xsl:text>\end{enumerate} </xsl:text>
245
<xsl:call-template name="compactlist.post"/>
248
<doc:template xmlns="">
249
<refpurpose>Process <doc:db>varlistentry</doc:db> elements</refpurpose>
252
Formats a labeled list item.
260
Applies templates within a &LaTeX; <function condition="latex">item</function>
262
A comma is inserted between successive <doc:db basename="term">terms</doc:db>.
265
A &LaTeX; <function condition="latex">null{}</function> command is
266
inserted after the <function condition="latex">item</function> to
267
guard against empty <doc:db basename="listitem">listitems</doc:db>.
271
<xsl:template match="varlistentry">
272
<xsl:param name="object" select="listitem/*[1]"/>
273
<xsl:param name="next.is.list">
274
<xsl:value-of select="count($object[self::itemizedlist or self::orderedlist or self::variablelist])"/>
276
<xsl:variable name="id">
277
<xsl:call-template name="label.id"/>
279
<xsl:text>% \null and \mbox are tricks to induce different typesetting decisions </xsl:text>
280
<xsl:text>\item[{</xsl:text>
281
<xsl:for-each select="term">
282
<xsl:apply-templates/>
283
<xsl:if test="position()!=last()">
284
<xsl:text>, </xsl:text>
288
<xsl:when test="$next.is.list=1">
289
<xsl:text>}]\mbox{}</xsl:text>
292
<xsl:text>}]\null{}</xsl:text>
295
<xsl:apply-templates select="listitem"/>
298
<doc:template basename="term" xmlns="">
299
<refpurpose>Process <doc:db>varlistentry</doc:db>'s <doc:db>term</doc:db> elements</refpurpose>
309
<xsl:template match="varlistentry/term">
310
<xsl:apply-templates/><xsl:text>, </xsl:text>
313
<doc:template basename="listitem" xmlns="">
314
<refpurpose>Process <doc:db>listitem</doc:db> elements</refpurpose>
325
Unlike <xref linkend="template.listitem"/>, the \item
326
has been output by the enclosing element's template.
330
<xsl:template match="varlistentry/listitem">
331
<xsl:apply-templates/>
334
<doc:template xmlns="">
335
<refpurpose>Generate a <function condition="env">tabular</function> specification</refpurpose>
339
Produces a left-aligned tabular specification list.
350
<listitem><simpara>The number of repetitions</simpara></listitem>
355
<xsl:template name="generate.simplelist.tabular.string">
356
<xsl:param name="cols" select="1"/>
357
<xsl:param name="i" select="1"/>
359
<xsl:when test="$i > $cols"></xsl:when>
361
<xsl:text>l</xsl:text>
362
<xsl:call-template name="generate.simplelist.tabular.string">
363
<xsl:with-param name="i" select="$i+1"/>
364
<xsl:with-param name="cols" select="$cols"/>
370
<doc:template basename="simplelist" xmlns="">
371
<refpurpose>Process <doc:db>simplelist</doc:db> elements with inline <doc:db basename="member">members</doc:db></refpurpose>
374
Formats a simple, comma-separated list for a <doc:db>simplelist</doc:db>
375
that has a <sgmltag class="attribute">type</sgmltag> attribute equal to <quote>inline</quote>.
383
This is not made into a paragraph and is not temrinated by a full stop (<quote>period</quote>).
387
<xsl:template match="simplelist[@type='inline']" name="generate.simplelist.inline">
388
<xsl:for-each select="member">
389
<xsl:apply-templates/>
390
<xsl:if test="position()!=last()">
391
<xsl:text>, </xsl:text>
396
<doc:template basename="simplelist" xmlns="">
397
<refpurpose>Process <doc:db>simplelist</doc:db> elements with <quote>horiz</quote> <doc:db basename="member">members</doc:db></refpurpose>
400
Formats a simple, comma-separated list for a <doc:db>simplelist</doc:db>
401
that has a <sgmltag class="attribute">type</sgmltag> attribute equal to <quote>horiz</quote>.
410
<term>environment</term>
411
<listitem><simpara>The &LaTeX; tabular-like environment to use. Defaults to <quote>tabular</quote> unless <xref linkend="param.latex.use.ltxtable"/> or <xref linkend="param.latex.use.longtable"/> is enabled, in which case the default is <quote>longtable</quote>.</simpara></listitem>
415
<listitem><simpara>The number of members per line (defaults to the value of the <sgmltag class="attribute">columns</sgmltag> attribute).</simpara></listitem>
421
This is formatted as a border-less &LaTeX; table.
425
<xsl:template match="simplelist[@type='horiz']" name="generate.simplelist.horiz">
426
<xsl:param name="environment">
428
<xsl:when test="$latex.use.ltxtable='1' or $latex.use.longtable='1'">
429
<xsl:text>longtable</xsl:text>
432
<xsl:text>tabular</xsl:text>
436
<xsl:param name="cols">
438
<xsl:when test="@columns">
439
<xsl:value-of select="@columns"/>
441
<xsl:otherwise>1</xsl:otherwise>
444
<xsl:text> </xsl:text>
445
<xsl:text>\begin{</xsl:text>
446
<xsl:value-of select="$environment"/>
447
<xsl:text>}{</xsl:text>
448
<xsl:call-template name="generate.simplelist.tabular.string">
449
<xsl:with-param name="cols" select="$cols"/>
451
<xsl:text>} </xsl:text>
452
<xsl:call-template name="simplelist.horiz">
453
<xsl:with-param name="cols" select="$cols"/>
455
<xsl:text> \end{</xsl:text>
456
<xsl:value-of select="$environment"/>
457
<xsl:text>} </xsl:text>
460
<xsl:template name="simplelist.horiz">
461
<xsl:param name="cols">1</xsl:param>
462
<xsl:param name="cell">1</xsl:param>
463
<xsl:param name="members" select="./member"/>
464
<xsl:if test="$cell <= count($members)">
465
<xsl:text> </xsl:text>
466
<xsl:call-template name="simplelist.horiz.row">
467
<xsl:with-param name="cols" select="$cols"/>
468
<xsl:with-param name="cell" select="$cell"/>
469
<xsl:with-param name="members" select="$members"/>
471
<xsl:text> \\</xsl:text>
472
<xsl:call-template name="simplelist.horiz">
473
<xsl:with-param name="cols" select="$cols"/>
474
<xsl:with-param name="cell" select="$cell + $cols"/>
475
<xsl:with-param name="members" select="$members"/>
480
<xsl:template name="simplelist.horiz.row">
481
<xsl:param name="cols">1</xsl:param>
482
<xsl:param name="cell">1</xsl:param>
483
<xsl:param name="members" select="./member"/>
484
<xsl:param name="curcol">1</xsl:param>
485
<xsl:if test="$curcol <= $cols">
487
<xsl:when test="$members[position()=$cell]">
488
<xsl:apply-templates select="$members[position()=$cell]"/>
489
<xsl:text> </xsl:text>
490
<xsl:if test="$curcol < $cols">
491
<xsl:call-template name="generate.latex.cell.separator"/>
495
<xsl:call-template name="simplelist.horiz.row">
496
<xsl:with-param name="cols" select="$cols"/>
497
<xsl:with-param name="cell" select="$cell+1"/>
498
<xsl:with-param name="members" select="$members"/>
499
<xsl:with-param name="curcol" select="$curcol+1"/>
504
<doc:template basename="simplelist" xmlns="">
505
<refpurpose>Process <doc:db>simplelist</doc:db> elements with <quote>vert</quote> <doc:db basename="member">members</doc:db></refpurpose>
508
Formats a simple, comma-separated list for a <doc:db>simplelist</doc:db>
509
that has a <sgmltag class="attribute">type</sgmltag> attribute that is either
510
empty or equal to <quote>vert</quote>.
519
<term>environment</term>
520
<listitem><simpara>The &LaTeX; tabular-like environment to use. Defaults to <quote>tabular</quote> unless <xref linkend="param.latex.use.ltxtable"/> or <xref linkend="param.latex.use.longtable"/> is set, in which case the default is <quote>longtable</quote>.</simpara></listitem>
524
<listitem><simpara>The number of members per line (defaults to the value of the <sgmltag class="attribute">columns</sgmltag> attribute).</simpara></listitem>
530
This is formatted as a border-less &LaTeX; table.
534
<xsl:template match="simplelist|simplelist[@type='vert']" name="generate.simplelist.vert">
535
<xsl:param name="environment">
537
<xsl:when test="$latex.use.ltxtable='1' or $latex.use.longtable='1'">
538
<xsl:text>longtable</xsl:text>
541
<xsl:text>tabular</xsl:text>
545
<xsl:param name="cols">
547
<xsl:when test="@columns">
548
<xsl:value-of select="@columns"/>
550
<xsl:otherwise>1</xsl:otherwise>
553
<xsl:text> </xsl:text>
554
<xsl:text>\begin{</xsl:text>
555
<xsl:value-of select="$environment"/>
556
<xsl:text>}{</xsl:text>
557
<xsl:call-template name="generate.simplelist.tabular.string">
558
<xsl:with-param name="cols" select="$cols"/>
560
<xsl:text>} </xsl:text>
561
<xsl:call-template name="simplelist.vert">
562
<xsl:with-param name="cols" select="$cols"/>
564
<xsl:text> \end{</xsl:text>
565
<xsl:value-of select="$environment"/>
566
<xsl:text>} </xsl:text>
569
<xsl:template name="simplelist.vert">
570
<xsl:param name="cols">1</xsl:param>
571
<xsl:param name="cell">1</xsl:param>
572
<xsl:param name="members" select="./member"/>
573
<xsl:param name="rows" select="floor((count($members)+$cols - 1) div $cols)"/>
574
<xsl:if test="$cell <= $rows">
575
<xsl:text> </xsl:text>
576
<xsl:call-template name="simplelist.vert.row">
577
<xsl:with-param name="cols" select="$cols"/>
578
<xsl:with-param name="rows" select="$rows"/>
579
<xsl:with-param name="cell" select="$cell"/>
580
<xsl:with-param name="members" select="$members"/>
582
<xsl:text> \\</xsl:text>
583
<xsl:call-template name="simplelist.vert">
584
<xsl:with-param name="cols" select="$cols"/>
585
<xsl:with-param name="cell" select="$cell+1"/>
586
<xsl:with-param name="members" select="$members"/>
587
<xsl:with-param name="rows" select="$rows"/>
592
<xsl:template name="simplelist.vert.row">
593
<xsl:param name="cols">1</xsl:param>
594
<xsl:param name="rows">1</xsl:param>
595
<xsl:param name="cell">1</xsl:param>
596
<xsl:param name="members" select="./member"/>
597
<xsl:param name="curcol">1</xsl:param>
598
<xsl:if test="$curcol <= $cols">
600
<xsl:when test="$members[position()=$cell]">
601
<xsl:apply-templates select="$members[position()=$cell]"/>
602
<xsl:text> </xsl:text>
603
<xsl:if test="$curcol < $cols">
604
<xsl:call-template name="generate.latex.cell.separator"/>
610
<xsl:call-template name="simplelist.vert.row">
611
<xsl:with-param name="cols" select="$cols"/>
612
<xsl:with-param name="rows" select="$rows"/>
613
<xsl:with-param name="cell" select="$cell+$rows"/>
614
<xsl:with-param name="members" select="$members"/>
615
<xsl:with-param name="curcol" select="$curcol+1"/>
620
<doc:template xmlns="">
621
<refpurpose>Process <doc:db>member</doc:db> elements</refpurpose>
631
<xsl:template match="member">
632
<xsl:apply-templates/>
635
<doc:template xmlns="">
636
<refpurpose>Process <doc:db>segmentedlist</doc:db> elements</refpurpose>
646
<simplelist type='inline'>
651
<xsl:template match="segmentedlist">
652
<xsl:apply-templates select="title|titleabbrev"/>
653
<xsl:apply-templates select="seglistitem"/>
656
<doc:template xmlns="">
657
<refpurpose>Process titles for <doc:db>segmentedlist</doc:db> elements</refpurpose>
660
Formats a title as a paragraph.
670
<listitem><simpara>The &LaTeX; command to use.</simpara></listitem>
676
Applies templates as a paragraph, formatted with the specified style, and
677
terminated with a newline command.
681
<xsl:template match="segmentedlist/title">
682
<xsl:param name="style" select="$latex.list.title.style"/>
683
<xsl:text> {</xsl:text>
684
<xsl:value-of select="$style"/>
685
<xsl:text>{</xsl:text>
686
<xsl:apply-templates/>
687
<xsl:text>}}\\ </xsl:text>
690
<doc:template xmlns="">
691
<refpurpose>Process <doc:db>segtitle</doc:db> elements</refpurpose>
701
<xsl:template match="segtitle">
702
<xsl:apply-templates/>
705
<doc:template xmlns="">
706
<refpurpose>Process <doc:db>seglistitem</doc:db> elements</refpurpose>
709
Formats a segmented list item.
716
<para>Applies <doc:db>seg</doc:db> templates. Each item is separated by a &LaTeX;
717
<function condition="latex">\</function> command.</para>
720
<xsl:template match="seglistitem">
721
<xsl:apply-templates/>
723
<xsl:when test="position()=last()"><xsl:text> </xsl:text></xsl:when>
724
<xsl:otherwise><xsl:text> \\ </xsl:text></xsl:otherwise>
728
<doc:template xmlns="">
729
<refpurpose>Process <doc:db>seg</doc:db> elements</refpurpose>
732
Formats a <doc:db>seg</doc:db> with its <doc:db>segtitle</doc:db>.
737
<listitem><simpara><xref linkend="param.latex.segtitle.style"/></simpara></listitem>
741
<xsl:template match="seg">
742
<xsl:variable name="segnum" select="position()"/>
743
<xsl:variable name="seglist" select="ancestor::segmentedlist"/>
744
<xsl:variable name="segtitles" select="$seglist/segtitle"/>
747
Note: segtitle is only going to be the right thing in a well formed
748
SegmentedList. If there are too many Segs or too few SegTitles,
749
you'll get something odd...maybe an error
752
<xsl:text> {</xsl:text>
753
<xsl:value-of select="$latex.segtitle.style"/>
754
<xsl:text>{</xsl:text>
755
<xsl:apply-templates select="$segtitles[$segnum=position()]"/>
756
<xsl:text>:}} </xsl:text>
757
<xsl:apply-templates/>
760
<xsl:template name="compactlist.pre">
761
<xsl:if test="@spacing='compact'">
762
<xsl:if test="$latex.use.parskip=1">
763
<xsl:text> \docbooktolatexnoparskip</xsl:text>
768
<xsl:template name="compactlist.begin">
769
<xsl:if test="@spacing='compact' and $latex.use.parskip!=1">
770
<xsl:text>\setlength{\itemsep}{-0.25em} </xsl:text>
774
<xsl:template name="compactlist.post">
775
<xsl:if test="@spacing='compact' and $latex.use.parskip=1">
776
<xsl:text>\docbooktolatexrestoreparskip </xsl:text>
778
<xsl:if test="$latex.use.noindent=1">
779
<xsl:text>\noindent </xsl:text>