2 <xsl:stylesheet xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
5 <!-- ********************************************************************
6 $Id: lists.xsl,v 1.1 2007/03/10 05:15:34 scott Exp $
7 ********************************************************************
9 This file is part of the XSL DocBook Stylesheet distribution.
10 See ../README or http://docbook.sf.net/release/xsl/current/ for
11 copyright and other information.
13 ******************************************************************** -->
15 <xsl:variable name=
"list-indent">
17 <xsl:when test=
"not($man.indent.lists = 0)">
18 <xsl:value-of select=
"$man.indent.width"/>
20 <xsl:when test=
"not($man.indent.refsect = 0)">
21 <!-- * "zq" is the name of a register we set for -->
22 <!-- * preserving the original default indent value -->
23 <!-- * when $man.indent.refsect is non-zero; -->
24 <!-- * "u" is a roff unit specifier -->
25 <xsl:text>\n(zqu
</xsl:text>
27 <xsl:otherwise/> <!-- * otherwise, just leave it empty -->
31 <!-- ================================================================== -->
33 <xsl:template match=
"para[ancestor::listitem or ancestor::step or ancestor::glossdef]|
34 simpara[ancestor::listitem or ancestor::step or ancestor::glossdef]|
35 remark[ancestor::listitem or ancestor::step or ancestor::glossdef]">
36 <xsl:call-template name=
"mixed-block"/>
37 <xsl:text> </xsl:text>
38 <xsl:if test=
"following-sibling::*[1][
43 <!-- * Make sure multiple paragraphs within a list item don't -->
44 <!-- * merge together. -->
45 <xsl:text>.sp
</xsl:text>
49 <xsl:template match=
"variablelist|glosslist">
51 <xsl:text>.PP
</xsl:text>
52 <xsl:apply-templates mode=
"bold" select=
"title"/>
53 <xsl:text> </xsl:text>
55 <xsl:apply-templates/>
58 <xsl:template match=
"varlistentry|glossentry">
59 <xsl:text>.PP
</xsl:text>
60 <xsl:for-each select=
"term|glossterm">
61 <xsl:variable name=
"content">
62 <xsl:apply-templates/>
64 <xsl:value-of select=
"normalize-space($content)"/>
66 <xsl:when test=
"position() = last()"/> <!-- do nothing -->
68 <!-- * if we have multiple terms in the same varlistentry, generate -->
69 <!-- * a separator (", " by default) and/or an additional line -->
70 <!-- * break after each one except the last -->
72 <!-- * note that it is not valid to have multiple glossterms -->
73 <!-- * within a glossentry, so this logic never gets exercised -->
74 <!-- * for glossterms (every glossterm is always the last in -->
75 <!-- * its parent glossentry) -->
76 <xsl:value-of select=
"$variablelist.term.separator"/>
77 <xsl:if test=
"not($variablelist.term.break.after = '0')">
78 <xsl:text> </xsl:text>
79 <xsl:text>.br
</xsl:text>
84 <xsl:text> </xsl:text>
85 <xsl:text>.RS
</xsl:text>
86 <xsl:if test=
"not($list-indent = '')">
87 <xsl:text> </xsl:text>
88 <xsl:value-of select=
"$list-indent"/>
90 <xsl:text> </xsl:text>
91 <xsl:apply-templates/>
92 <xsl:text>.RE
</xsl:text>
95 <xsl:template match=
"varlistentry/term"/>
96 <xsl:template match=
"glossentry/glossterm"/>
98 <xsl:template match=
"variablelist[ancestor::listitem or ancestor::step or ancestor::glossdef]|
99 glosslist[ancestor::listitem or ancestor::step or ancestor::glossdef]">
100 <xsl:apply-templates/>
101 <xsl:if test=
"following-sibling::node() or
102 parent::para[following-sibling::node()] or
103 parent::simpara[following-sibling::node()] or
104 parent::remark[following-sibling::node()]">
105 <xsl:text>.sp
</xsl:text>
106 <xsl:text> </xsl:text>
110 <xsl:template match=
"varlistentry/listitem|glossentry/glossdef">
111 <xsl:apply-templates/>
114 <xsl:template match=
"itemizedlist/listitem">
115 <!-- * We output a real bullet here (rather than, "\(bu", -->
116 <!-- * the roff bullet) because, when we do character-map -->
117 <!-- * processing before final output, the character-map will -->
118 <!-- * handle conversion of the • to "\(bu" for us -->
119 <xsl:text> </xsl:text>
120 <xsl:text>.sp
</xsl:text>
121 <xsl:text> </xsl:text>
122 <xsl:text>.RS
</xsl:text>
123 <xsl:if test=
"not($list-indent = '')">
124 <xsl:text> </xsl:text>
125 <xsl:value-of select=
"$list-indent"/>
127 <xsl:text> </xsl:text>
128 <xsl:text>\h'-
</xsl:text>
129 <xsl:if test=
"not($list-indent = '')">
130 <xsl:text>0</xsl:text>
131 <xsl:value-of select=
"$list-indent"/>
133 <xsl:text>'
</xsl:text>
134 <xsl:text>•</xsl:text>
135 <xsl:text>\h'+
</xsl:text>
136 <xsl:if test=
"not($list-indent = '')">
137 <xsl:text>0</xsl:text>
138 <xsl:value-of select=
"$list-indent - 1"/>
139 <xsl:text>'
</xsl:text>
141 <xsl:apply-templates/>
142 <xsl:text>.RE
</xsl:text>
145 <xsl:template match=
"orderedlist/listitem|procedure/step">
146 <xsl:text> </xsl:text>
147 <xsl:text>.sp
</xsl:text>
148 <xsl:text> </xsl:text>
149 <xsl:text>.RS
</xsl:text>
150 <xsl:if test=
"not($list-indent = '')">
151 <xsl:text> </xsl:text>
152 <xsl:value-of select=
"$list-indent"/>
154 <xsl:text> </xsl:text>
155 <xsl:text>\h'-
</xsl:text>
156 <xsl:if test=
"not($list-indent = '')">
157 <xsl:text>0</xsl:text>
158 <xsl:value-of select=
"$list-indent"/>
160 <xsl:text>'
</xsl:text>
161 <xsl:if test=
"count(preceding-sibling::listitem) < 9">
162 <xsl:text> </xsl:text>
164 <xsl:number format=
"1."/>
165 <xsl:text>\h'+
</xsl:text>
166 <xsl:if test=
"not($list-indent = '')">
167 <xsl:text>0</xsl:text>
168 <xsl:value-of select=
"$list-indent - 2"/>
169 <xsl:text>'
</xsl:text>
171 <xsl:apply-templates/>
172 <xsl:text>.RE
</xsl:text>
173 <xsl:text> </xsl:text>
176 <xsl:template match=
"itemizedlist|orderedlist|procedure">
177 <xsl:if test=
"title">
178 <xsl:text>.PP
</xsl:text>
179 <xsl:apply-templates mode=
"bold" select=
"title"/>
180 <xsl:text> </xsl:text>
182 <!-- * DocBook allows just about any block content to appear in -->
183 <!-- * lists before the actual list items, so we need to get that -->
184 <!-- * content (if any) before getting the list items -->
186 select=
"*[not(self::listitem) and not(self::title)]"/>
187 <xsl:apply-templates select=
"listitem"/>
188 <!-- * If this list is a child of para and has content following -->
189 <!-- * it, within the same para, then add a blank line and move -->
190 <!-- * the left margin back to where it was -->
191 <xsl:if test=
"parent::para and following-sibling::node()">
192 <xsl:text>.sp
</xsl:text>
193 <xsl:text>.RE
</xsl:text>
197 <xsl:template match=
"itemizedlist[ancestor::listitem or ancestor::step or ancestor::glossdef]|
198 orderedlist[ancestor::listitem or ancestor::step or ancestor::glossdef]|
199 procedure[ancestor::listitem or ancestor::step or ancestor::glossdef]">
200 <xsl:if test=
"title">
201 <xsl:text>.PP
</xsl:text>
202 <xsl:apply-templates mode=
"bold" select=
"title"/>
203 <xsl:text> </xsl:text>
205 <xsl:apply-templates/>
206 <xsl:if test=
"following-sibling::node() or
207 parent::para[following-sibling::node()] or
208 parent::simpara[following-sibling::node()] or
209 parent::remark[following-sibling::node()]">
210 <xsl:text>.IP
""</xsl:text>
211 <xsl:if test=
"not($list-indent = '')">
212 <xsl:text> </xsl:text>
213 <xsl:value-of select=
"$list-indent"/>
215 <xsl:text> </xsl:text>
219 <!-- ================================================================== -->
221 <!-- * for simplelist type="inline", render it as a comma-separated list -->
222 <xsl:template match=
"simplelist[@type='inline']">
224 <!-- * if dbchoice PI exists, use that to determine the choice separator -->
225 <!-- * (that is, equivalent of "and" or "or" in current locale), or literal -->
226 <!-- * value of "choice" otherwise -->
227 <xsl:variable name=
"localized-choice-separator">
229 <xsl:when test=
"processing-instruction('dbchoice')">
230 <xsl:call-template name=
"select.choice.separator"/>
238 <xsl:for-each select=
"member">
239 <xsl:apply-templates/>
241 <xsl:when test=
"position() = last()"/> <!-- do nothing -->
243 <xsl:text>,
</xsl:text>
244 <xsl:if test=
"position() = last() - 1">
245 <xsl:if test=
"$localized-choice-separator != ''">
246 <xsl:value-of select=
"$localized-choice-separator"/>
247 <xsl:text> </xsl:text>
253 <xsl:text> </xsl:text>
256 <!-- * if simplelist type is not inline, render it as a one-column vertical -->
257 <!-- * list (ignoring the values of the type and columns attributes) -->
258 <xsl:template match=
"simplelist">
259 <xsl:for-each select=
"member">
260 <xsl:text>.IP
""</xsl:text>
261 <xsl:if test=
"not($list-indent = '')">
262 <xsl:text> </xsl:text>
263 <xsl:value-of select=
"$list-indent"/>
265 <xsl:text> </xsl:text>
266 <xsl:apply-templates/>
267 <xsl:text> </xsl:text>
271 <!-- ================================================================== -->
273 <!-- * We output Segmentedlist as a table, using tbl(1) markup. There -->
274 <!-- * is no option for outputting it in manpages in "list" form. -->
275 <xsl:template match=
"segmentedlist">
276 <xsl:if test=
"title">
277 <xsl:text>.PP
</xsl:text>
278 <xsl:apply-templates mode=
"bold" select=
"title"/>
279 <xsl:text> </xsl:text>
281 <xsl:text>.\
" line length increase to cope w/ tbl weirdness </xsl:text>
282 <xsl:text>.ll +(\n(LLu * 62u / 100u) </xsl:text>
283 <!-- * .TS = "Table Start
" -->
284 <xsl:text>.TS </xsl:text>
285 <!-- * first output the table "format
" spec, which tells tbl(1) how -->
286 <!-- * how to format each row and column. -->
287 <xsl:for-each select=".//segtitle
">
288 <!-- * l = "left
", which hard-codes left-alignment for tabular -->
289 <!-- * output of all segmentedlist content -->
290 <xsl:text>l</xsl:text>
292 <!-- * last line of table format section must end with a dot -->
293 <xsl:text>. </xsl:text>
294 <!-- * optionally suppress output of segtitle -->
296 <xsl:when test="$man.segtitle.suppress !=
0">
297 <!-- * non-zero = "suppress
", so do nothing -->
300 <!-- * "0" = "do not suppress
", so output the segtitle(s) -->
301 <xsl:apply-templates select=".//segtitle
" mode="table-title
"/>
302 <xsl:text> </xsl:text>
305 <xsl:apply-templates/>
306 <!-- * .TE = "Table End
" -->
307 <xsl:text>.TE </xsl:text>
308 <xsl:text>.\" line length decrease back to previous value
</xsl:text>
309 <xsl:text>.ll -(\n(LLu *
62u /
100u)
</xsl:text>
310 <!-- * put a blank line of space below the table -->
311 <xsl:text>.sp
</xsl:text>
314 <xsl:template match=
"segmentedlist/segtitle" mode=
"table-title">
315 <!-- * italic makes titles stand out more reliably than bold (because -->
316 <!-- * some consoles do not actually support rendering of bold -->
317 <xsl:apply-templates mode=
"italic" select=
"."/>
319 <xsl:when test=
"position() = last()"/> <!-- do nothing -->
321 <!-- * tbl(1) treats tab characters as delimiters between -->
322 <!-- * cells; so we need to output a tab after each except -->
323 <!-- * segtitle except the last one -->
324 <xsl:text>	</xsl:text>
329 <xsl:template match=
"segmentedlist/seglistitem">
330 <xsl:apply-templates/>
331 <xsl:text> </xsl:text>
334 <xsl:template match=
"segmentedlist/seglistitem/seg">
335 <!-- * the “T{" and “T}” stuff are delimiters to tell tbl(1) that -->
336 <!-- * the delimited contents are "text blocks" that groff(1) -->
337 <!-- * needs to process -->
338 <xsl:text>T{
</xsl:text>
339 <xsl:variable name=
"contents">
340 <xsl:apply-templates/>
342 <xsl:value-of select=
"normalize-space($contents)"/>
343 <xsl:text> T}
</xsl:text>
345 <xsl:when test=
"position() = last()"/> <!-- do nothing -->
347 <!-- * tbl(1) treats tab characters as delimiters between -->
348 <!-- * cells; so we need to output a tab after each except -->
349 <!-- * segtitle except the last one -->
350 <xsl:text>	</xsl:text>