2 <!--#############################################################################
3 | $Id: lists.mod.xsl,v 1.1 2003/04/30 21:39:49 ab Exp $
4 |- #############################################################################
8 + ############################################################################## -->
11 xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
12 xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
13 exclude-result-prefixes="doc" version='1.0'>
17 <!--############################################################################# -->
18 <!-- DOCUMENTATION -->
19 <doc:reference id="lists" xmlns="">
21 <releaseinfo role="meta">
22 $Id: lists.mod.xsl,v 1.1 2003/04/30 21:39:49 ab Exp $
25 <author> <firstname>Ramon</firstname> <surname>Casellas</surname> </author>
26 <author> <firstname>James</firstname> <surname>Devenish</surname> </author>
29 <year>2000</year> <year>2001</year> <year>2002</year> <year>2003</year>
30 <holder>Ramon Casellas</holder>
34 <title>Lists <filename>lists.mod.xsl</filename></title>
36 <section><title>Introduction</title>
44 <xsl:template match="variablelist/title| orderedlist/title | itemizedlist/title | simplelist/title">
45 <xsl:text> {\sc </xsl:text>
46 <xsl:apply-templates/>
47 <xsl:text>} </xsl:text>
51 <xsl:template match="itemizedlist">
52 <xsl:if test="title"> <xsl:apply-templates select="title"/></xsl:if>
53 <xsl:text> \begin{itemize} </xsl:text>
54 <xsl:apply-templates select="listitem"/>
55 <xsl:text> \end{itemize} </xsl:text>
59 <xsl:template match="orderedlist">
60 <xsl:variable name="numeration">
62 <xsl:when test="@numeration">
63 <xsl:value-of select="@numeration"/>
66 <xsl:value-of select="arabic"/>
70 <xsl:if test="title"> <xsl:apply-templates select="title"/></xsl:if>
71 <xsl:text> \begin{enumerate}</xsl:text>
72 <xsl:if test="@numeration">
74 <xsl:when test="@numeration='arabic'"> <xsl:text>[1]</xsl:text> </xsl:when>
75 <xsl:when test="@numeration='upperalpha'"><xsl:text>[A]</xsl:text> </xsl:when>
76 <xsl:when test="@numeration='loweralpha'"><xsl:text>[a]</xsl:text> </xsl:when>
77 <xsl:when test="@numeration='upperroman'"><xsl:text>[I]</xsl:text> </xsl:when>
78 <xsl:when test="@numeration='lowerroman'"><xsl:text>[i]</xsl:text> </xsl:when>
81 <xsl:apply-templates select="listitem"/>
87 <xsl:template match="variablelist">
89 <xsl:apply-templates select="title"/>
91 <xsl:text> \noindent </xsl:text>
92 <xsl:text> \begin{description} </xsl:text>
93 <xsl:apply-templates select="varlistentry"/>
94 <xsl:text> \end{description} </xsl:text>
98 <xsl:template match="listitem">
99 <xsl:text> %--- Item </xsl:text>
100 <xsl:text>\item </xsl:text>
101 <xsl:apply-templates/>
102 <xsl:text> </xsl:text>
106 <xsl:template match="varlistentry">
107 <xsl:variable name="id">
108 <xsl:call-template name="label.id"/>
110 <xsl:text>\item[</xsl:text><xsl:apply-templates select="term"/><xsl:text>]\mbox{} % mbox is a trick to induce different typesetting decisions</xsl:text>
111 <xsl:apply-templates select="listitem"/>
115 <xsl:template match="varlistentry/term">
116 <xsl:apply-templates/><xsl:text>, </xsl:text>
119 <xsl:template match="varlistentry/term[position()=last()]">
120 <xsl:apply-templates/>
123 <xsl:template match="varlistentry/listitem">
124 <xsl:apply-templates/>
128 <xsl:template name="tabular.string">
129 <xsl:param name="cols" select="1"/>
130 <xsl:param name="i" select="1"/>
132 <xsl:when test="$i > $cols"></xsl:when>
134 <xsl:text>l</xsl:text>
135 <xsl:call-template name="tabular.string">
136 <xsl:with-param name="i" select="$i+1"/>
137 <xsl:with-param name="cols" select="$cols"/>
144 <!--==========================================================================
145 | Inline simplelist. It is rendered as a list of comma separated values.
146 | We make the difference between the last member and the rest. XSL easily
148 +============================================================================-->
150 <xsl:template match="simplelist[@type='inline']">
151 <xsl:apply-templates/>
153 <xsl:template match="simplelist[@type='inline']/member">
154 <xsl:apply-templates/>
155 <xsl:text>, </xsl:text>
157 <xsl:template match="simplelist[@type='inline']/member[position()=last()]">
158 <xsl:apply-templates/>
161 <xsl:template match="simplelist[@type='horiz']">
162 <xsl:variable name="cols">
164 <xsl:when test="@columns">
165 <xsl:value-of select="@columns"/>
167 <xsl:otherwise>1</xsl:otherwise>
170 <xsl:text> </xsl:text>
171 <xsl:text>\begin{tabular*}{\linewidth}{</xsl:text>
172 <xsl:call-template name="tabular.string">
173 <xsl:with-param name="cols" select="$cols"/>
175 <xsl:text>} </xsl:text>
176 <xsl:call-template name="simplelist.horiz">
177 <xsl:with-param name="cols" select="$cols"/>
179 <xsl:text> \end{tabular*} </xsl:text>
185 <xsl:template name="simplelist.horiz">
186 <xsl:param name="cols">1</xsl:param>
187 <xsl:param name="cell">1</xsl:param>
188 <xsl:param name="members" select="./member"/>
189 <xsl:if test="$cell <= count($members)">
190 <xsl:text> </xsl:text>
191 <xsl:call-template name="simplelist.horiz.row">
192 <xsl:with-param name="cols" select="$cols"/>
193 <xsl:with-param name="cell" select="$cell"/>
194 <xsl:with-param name="members" select="$members"/>
196 <xsl:text> \\</xsl:text>
197 <xsl:call-template name="simplelist.horiz">
198 <xsl:with-param name="cols" select="$cols"/>
199 <xsl:with-param name="cell" select="$cell + $cols"/>
200 <xsl:with-param name="members" select="$members"/>
205 <xsl:template name="simplelist.horiz.row">
206 <xsl:param name="cols">1</xsl:param>
207 <xsl:param name="cell">1</xsl:param>
208 <xsl:param name="members" select="./member"/>
209 <xsl:param name="curcol">1</xsl:param>
210 <xsl:if test="$curcol <= $cols">
212 <xsl:when test="$members[position()=$cell]">
213 <xsl:apply-templates select="$members[position()=$cell]"/>
214 <xsl:text> </xsl:text>
215 <xsl:if test="$curcol < $cols">
216 <xsl:call-template name="generate.latex.cell.separator"/>
220 <xsl:call-template name="simplelist.horiz.row">
221 <xsl:with-param name="cols" select="$cols"/>
222 <xsl:with-param name="cell" select="$cell+1"/>
223 <xsl:with-param name="members" select="$members"/>
224 <xsl:with-param name="curcol" select="$curcol+1"/>
239 <xsl:template match="simplelist|simplelist[@type='vert']">
240 <xsl:variable name="cols">
242 <xsl:when test="@columns">
243 <xsl:value-of select="@columns"/>
245 <xsl:otherwise>1</xsl:otherwise>
248 <xsl:text> </xsl:text>
249 <!--<xsl:text>\vspace{1cm} </xsl:text>-->
250 <xsl:text>\begin{tabular*}{\linewidth}{</xsl:text>
251 <xsl:call-template name="tabular.string">
252 <xsl:with-param name="i" select="1"/>
253 <xsl:with-param name="cols" select="$cols"/>
255 <xsl:text>}</xsl:text>
256 <xsl:call-template name="simplelist.vert">
257 <xsl:with-param name="cols" select="$cols"/>
259 <xsl:text> \end{tabular*} </xsl:text>
260 <!--<xsl:text>\vspace{1cm} </xsl:text>-->
265 <xsl:template name="simplelist.vert">
266 <xsl:param name="cols">1</xsl:param>
267 <xsl:param name="cell">1</xsl:param>
268 <xsl:param name="members" select="./member"/>
269 <xsl:param name="rows" select="floor((count($members)+$cols - 1) div $cols)"/>
270 <xsl:if test="$cell <= $rows">
271 <xsl:text> </xsl:text>
272 <xsl:call-template name="simplelist.vert.row">
273 <xsl:with-param name="cols" select="$cols"/>
274 <xsl:with-param name="rows" select="$rows"/>
275 <xsl:with-param name="cell" select="$cell"/>
276 <xsl:with-param name="members" select="$members"/>
278 <xsl:text> \\</xsl:text>
279 <xsl:call-template name="simplelist.vert">
280 <xsl:with-param name="cols" select="$cols"/>
281 <xsl:with-param name="cell" select="$cell+1"/>
282 <xsl:with-param name="members" select="$members"/>
283 <xsl:with-param name="rows" select="$rows"/>
290 <xsl:template name="simplelist.vert.row">
291 <xsl:param name="cols">1</xsl:param>
292 <xsl:param name="rows">1</xsl:param>
293 <xsl:param name="cell">1</xsl:param>
294 <xsl:param name="members" select="./member"/>
295 <xsl:param name="curcol">1</xsl:param>
296 <xsl:if test="$curcol <= $cols">
298 <xsl:when test="$members[position()=$cell]">
299 <xsl:apply-templates select="$members[position()=$cell]"/>
300 <xsl:text> </xsl:text>
301 <xsl:if test="$curcol < $cols">
302 <xsl:call-template name="generate.latex.cell.separator"/>
308 <xsl:call-template name="simplelist.vert.row">
309 <xsl:with-param name="cols" select="$cols"/>
310 <xsl:with-param name="rows" select="$rows"/>
311 <xsl:with-param name="cell" select="$cell+$rows"/>
312 <xsl:with-param name="members" select="$members"/>
313 <xsl:with-param name="curcol" select="$curcol+1"/>
319 <xsl:template match="member">
320 <xsl:apply-templates/>
326 <xsl:template match="segmentedlist">
327 <xsl:apply-templates/>
330 <xsl:template match="segmentedlist/title">
331 <xsl:text> {\sc </xsl:text>
332 <xsl:apply-templates/>
333 <xsl:text>} \\ </xsl:text>
336 <xsl:template match="segtitle">
339 <xsl:template match="segtitle" mode="segtitle-in-seg">
340 <xsl:apply-templates/>
343 <xsl:template match="seglistitem">
344 <xsl:apply-templates/>
346 <xsl:when test="position()=last()"><xsl:text> </xsl:text></xsl:when>
347 <xsl:otherwise><xsl:text> \\ </xsl:text></xsl:otherwise>
354 <xsl:template match="seg">
355 <xsl:variable name="segnum" select="position()"/>
356 <xsl:variable name="seglist" select="ancestor::segmentedlist"/>
357 <xsl:variable name="segtitles" select="$seglist/segtitle"/>
360 Note: segtitle is only going to be the right thing in a well formed
361 SegmentedList. If there are too many Segs or too few SegTitles,
362 you'll get something odd...maybe an error
365 <xsl:text>{ \em </xsl:text>
366 <xsl:apply-templates select="$segtitles[$segnum=position()]" mode="segtitle-in-seg"/>
367 <xsl:text>:} </xsl:text>
368 <xsl:apply-templates/>
380 <!-- ==================================================================== -->
382 <xsl:template match="calloutlist">
383 <xsl:if test="./title">
384 <xsl:apply-templates select="./title" mode="calloutlist.title.mode"/>
386 <xsl:apply-templates/>
389 <xsl:template match="calloutlist/title">
392 <xsl:template match="calloutlist/title" mode="calloutlist.title.mode">
393 <xsl:apply-templates/>
396 <xsl:template match="callout">
398 <xsl:call-template name="callout.arearefs">
399 <xsl:with-param name="arearefs" select="@arearefs"/>
402 <dl><xsl:apply-templates/></dl>
405 <xsl:template name="callout.arearefs">
406 <xsl:param name="arearefs"></xsl:param>
407 <xsl:if test="$arearefs!=''">
409 <xsl:when test="substring-before($arearefs,' ')=''">
410 <xsl:call-template name="callout.arearef">
411 <xsl:with-param name="arearef" select="$arearefs"/>
415 <xsl:call-template name="callout.arearef">
416 <xsl:with-param name="arearef"
417 select="substring-before($arearefs,' ')"/>
421 <xsl:call-template name="callout.arearefs">
422 <xsl:with-param name="arearefs"
423 select="substring-after($arearefs,' ')"/>
432 <xsl:template name="callout.arearef">
433 <xsl:param name="arearef"></xsl:param>
434 <xsl:variable name="targets" select="//node()[@id=$arearef]"/>
435 <xsl:variable name="target" select="$targets[1]"/>
437 <xsl:when test="count($target)=0">
438 <xsl:value-of select="$arearef"/>
439 <xsl:text>callout ???</xsl:text>
441 <xsl:when test="local-name($target)='co'">
443 <xsl:text>\href{ </xsl:text>
444 <xsl:value-of select="$target/@id"/>
445 <xsl:text>}{</xsl:text>
446 <xsl:value-of select="$target/@id"/><xsl:text>} </xsl:text>
449 <xsl:text>callout ???</xsl:text>