2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
5 <!-- ********************************************************************
6 $Id: lists.xsl 8530 2009-11-02 02:38:47Z dleidert $
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="bibliolist">
50 <xsl:apply-templates/>
51 <xsl:text> </xsl:text>
54 <xsl:template match="variablelist|glosslist">
56 <xsl:text>.PP </xsl:text>
57 <xsl:call-template name="bold">
58 <xsl:with-param name="node" select="title"/>
59 <xsl:with-param name="context" select="."/>
61 <xsl:text> </xsl:text>
63 <xsl:apply-templates/>
66 <xsl:template match="varlistentry|glossentry">
67 <xsl:text>.PP </xsl:text>
68 <xsl:for-each select="term|glossterm">
69 <xsl:variable name="content">
70 <xsl:apply-templates/>
72 <xsl:value-of select="normalize-space($content)"/>
74 <xsl:when test="position() = last()"/> <!-- do nothing -->
76 <!-- * if we have multiple terms in the same varlistentry, generate -->
77 <!-- * a separator (", " by default) and/or an additional line -->
78 <!-- * break after each one except the last -->
80 <!-- * note that it is not valid to have multiple glossterms -->
81 <!-- * within a glossentry, so this logic never gets exercised -->
82 <!-- * for glossterms (every glossterm is always the last in -->
83 <!-- * its parent glossentry) -->
84 <xsl:value-of select="$variablelist.term.separator"/>
85 <xsl:if test="not($variablelist.term.break.after = '0')">
86 <xsl:text> </xsl:text>
87 <xsl:text>.br </xsl:text>
92 <xsl:text> </xsl:text>
93 <xsl:text>.RS</xsl:text>
94 <xsl:if test="not($list-indent = '')">
95 <xsl:text> </xsl:text>
96 <xsl:value-of select="$list-indent"/>
98 <xsl:text> </xsl:text>
99 <xsl:apply-templates/>
100 <xsl:text>.RE </xsl:text>
103 <xsl:template match="varlistentry/term"/>
104 <xsl:template match="glossentry/glossterm"/>
106 <xsl:template match="variablelist[ancestor::listitem or ancestor::step or ancestor::glossdef]|
107 glosslist[ancestor::listitem or ancestor::step or ancestor::glossdef]">
108 <xsl:apply-templates/>
109 <xsl:if test="following-sibling::node() or
110 parent::para[following-sibling::node()] or
111 parent::simpara[following-sibling::node()] or
112 parent::remark[following-sibling::node()]">
113 <xsl:text>.sp</xsl:text>
114 <xsl:text> </xsl:text>
118 <xsl:template match="varlistentry/listitem|glossentry/glossdef">
119 <xsl:apply-templates/>
122 <xsl:template match="itemizedlist/listitem">
123 <!-- * We output a real bullet here (rather than, "\(bu", -->
124 <!-- * the roff bullet) because, when we do character-map -->
125 <!-- * processing before final output, the character-map will -->
126 <!-- * handle conversion of the • to "\(bu" for us -->
127 <xsl:text> </xsl:text>
128 <xsl:text>.sp</xsl:text>
129 <xsl:text> </xsl:text>
130 <xsl:text>.RS</xsl:text>
131 <xsl:if test="not($list-indent = '')">
132 <xsl:text> </xsl:text>
133 <xsl:value-of select="$list-indent"/>
135 <xsl:text> </xsl:text>
136 <!-- * if "n" then we are using "nroff", which means the output is for -->
137 <!-- * TTY; so we do some fixed-width-font hackery with \h to make a -->
138 <!-- * hanging indent (instead of using .IP, which has some -->
139 <!-- * undesirable side effects under certain circumstances) -->
140 <xsl:call-template name="roff-if-else-start"/>
141 <xsl:text>\h'-</xsl:text>
143 <xsl:when test="not($list-indent = '')">
144 <xsl:text>0</xsl:text>
145 <xsl:value-of select="$list-indent"/>
148 <xsl:text>\n(INu</xsl:text>
151 <xsl:text>'</xsl:text>
152 <xsl:text>•</xsl:text>
153 <xsl:text>\h'+</xsl:text>
155 <xsl:when test="not($list-indent = '')">
156 <xsl:text>0</xsl:text>
157 <xsl:value-of select="$list-indent - 1"/>
160 <xsl:text>\n(INu-1</xsl:text>
163 <xsl:text>'\c </xsl:text>
164 <!-- * else, we are not using for "nroff", but instead "troff" - which -->
165 <!-- * means not for TTY, but for PS or whatever; so we’re not using a -->
166 <!-- * fixed-width font, so use a real .IP instead -->
167 <xsl:call-template name="roff-else"/>
168 <!-- * .IP generates a blank like of space, so let’s go backwards one -->
169 <!-- * line up to compensate for that -->
170 <xsl:text>.sp -1 </xsl:text>
171 <xsl:text>.IP \(bu 2.3 </xsl:text>
172 <!-- * The value 2.3 is the amount of indentation; we use 2.3 instead -->
173 <!-- * of 2 because when the font family is New Century Schoolbook it -->
174 <!-- * seems to require the extra space. -->
175 <xsl:call-template name="roff-if-end"/>
176 <xsl:apply-templates/>
177 <xsl:text>.RE </xsl:text>
180 <xsl:template match="orderedlist/listitem|procedure/step">
181 <xsl:text> </xsl:text>
182 <xsl:text>.sp</xsl:text>
183 <xsl:text> </xsl:text>
184 <xsl:text>.RS</xsl:text>
185 <xsl:if test="not($list-indent = '')">
186 <xsl:text> </xsl:text>
187 <xsl:value-of select="$list-indent"/>
189 <xsl:text> </xsl:text>
190 <!-- * if "n" then we are using "nroff", which means the output is for -->
191 <!-- * TTY; so we do some fixed-width-font hackery with \h to make a -->
192 <!-- * hanging indents (instead of using .IP, which has some -->
193 <!-- * undesirable side effects under certain circumstances) -->
194 <xsl:call-template name="roff-if-else-start"/>
195 <xsl:text>\h'-</xsl:text>
197 <xsl:when test="not($list-indent = '')">
198 <xsl:text>0</xsl:text>
199 <xsl:value-of select="$list-indent"/>
202 <xsl:text>\n(INu+3n</xsl:text>
205 <xsl:text>'</xsl:text>
206 <xsl:if test="count(preceding-sibling::listitem) < 9">
207 <xsl:text> </xsl:text>
209 <xsl:number format="1."/>
210 <xsl:text>\h'+</xsl:text>
212 <xsl:when test="not($list-indent = '')">
213 <xsl:text>0</xsl:text>
214 <xsl:value-of select="$list-indent - 3"/>
217 <xsl:text>1n</xsl:text>
220 <xsl:text>'\c </xsl:text>
221 <!-- * else, we are not using for "nroff", but instead "troff" - which -->
222 <!-- * means not for TTY, but for PS or whatever; so we’re not using a -->
223 <!-- * fixed-width font, so use a real .IP instead -->
224 <xsl:call-template name="roff-else"/>
225 <!-- * .IP generates a blank line of space, so let’s go backwards one -->
226 <!-- * line up to compensate for that -->
227 <xsl:text>.sp -1 </xsl:text>
228 <xsl:text>.IP "</xsl:text>
229 <xsl:if test="count(preceding-sibling::listitem) < 9">
230 <xsl:text> </xsl:text>
232 <xsl:number format="1."/>
233 <xsl:text>" 4.2 </xsl:text>
234 <!-- * The value 4.2 is the amount of indentation; we use 4.2 instead -->
235 <!-- * of 4 because when the font family is Bookman it seems to require -->
236 <!-- * the extra space. -->
237 <xsl:call-template name="roff-if-end"/>
238 <xsl:apply-templates/>
239 <xsl:text>.RE </xsl:text>
240 <xsl:text> </xsl:text>
243 <xsl:template match="itemizedlist|orderedlist|procedure">
244 <xsl:if test="title">
245 <xsl:text>.PP </xsl:text>
246 <xsl:call-template name="bold">
247 <xsl:with-param name="node" select="title"/>
248 <xsl:with-param name="context" select="."/>
250 <xsl:text> </xsl:text>
252 <!-- * DocBook allows just about any block content to appear in -->
253 <!-- * lists before the actual list items, so we need to get that -->
254 <!-- * content (if any) before getting the list items -->
256 select="*[not(self::listitem) and not(self::title)]"/>
257 <xsl:apply-templates select="listitem"/>
258 <!-- * If this list is a child of para and has content following -->
259 <!-- * it, within the same para, then add a blank line and move -->
260 <!-- * the left margin back to where it was -->
261 <xsl:if test="parent::para and following-sibling::node()">
262 <xsl:text>.sp</xsl:text>
263 <xsl:text> </xsl:text>
267 <xsl:template match="itemizedlist[ancestor::listitem or ancestor::step or ancestor::glossdef]|
268 orderedlist[ancestor::listitem or ancestor::step or ancestor::glossdef]|
269 procedure[ancestor::listitem or ancestor::step or ancestor::glossdef]">
270 <xsl:if test="title">
271 <xsl:text>.PP </xsl:text>
272 <xsl:call-template name="bold">
273 <xsl:with-param name="node" select="title"/>
274 <xsl:with-param name="context" select="."/>
276 <xsl:text> </xsl:text>
278 <xsl:apply-templates/>
279 <xsl:if test="following-sibling::node() or
280 parent::para[following-sibling::node()] or
281 parent::simpara[following-sibling::node()] or
282 parent::remark[following-sibling::node()]">
283 <xsl:text>.sp</xsl:text>
284 <xsl:text> </xsl:text>
288 <!-- ================================================================== -->
290 <!-- * for simplelist type="inline", render it as a comma-separated list -->
291 <xsl:template match="simplelist[@type='inline']">
292 <!-- * if dbchoice PI exists, use that to determine the choice separator -->
293 <!-- * (that is, equivalent of "and" or "or" in current locale), or literal -->
294 <!-- * value of "choice" otherwise -->
295 <xsl:variable name="localized-choice-separator">
297 <xsl:when test="processing-instruction('dbchoice')">
298 <xsl:call-template name="select.choice.separator"/>
306 <xsl:for-each select="member">
307 <xsl:apply-templates/>
309 <xsl:when test="position() = last()"/> <!-- do nothing -->
311 <xsl:text>, </xsl:text>
312 <xsl:if test="position() = last() - 1">
313 <xsl:if test="$localized-choice-separator != ''">
314 <xsl:value-of select="$localized-choice-separator"/>
315 <xsl:text> </xsl:text>
321 <xsl:text> </xsl:text>
324 <!-- * if simplelist type is not inline, render it as a one-column vertical -->
325 <!-- * list (ignoring the values of the type and columns attributes) -->
326 <xsl:template match="simplelist">
327 <xsl:for-each select="member">
328 <xsl:text>.RS</xsl:text>
329 <xsl:if test="not($list-indent = '')">
330 <xsl:text> </xsl:text>
331 <xsl:value-of select="$list-indent"/>
333 <xsl:text> </xsl:text>
334 <xsl:apply-templates/>
335 <xsl:text> </xsl:text>
336 <xsl:text>.RE </xsl:text>
340 <!-- ================================================================== -->
342 <!-- * We output Segmentedlist as a table, using tbl(1) markup. There -->
343 <!-- * is no option for outputting it in manpages in "list" form. -->
344 <xsl:template match="segmentedlist">
345 <xsl:if test="title">
346 <xsl:text>.PP </xsl:text>
347 <xsl:call-template name="bold">
348 <xsl:with-param name="node" select="title"/>
349 <xsl:with-param name="context" select="."/>
351 <xsl:text> </xsl:text>
353 <xsl:text>.\" line length increase to cope w/ tbl weirdness </xsl:text>
354 <xsl:text>.ll +(\n(LLu * 62u / 100u) </xsl:text>
355 <!-- * .TS = "Table Start" -->
356 <xsl:text>.TS </xsl:text>
357 <!-- * first output the table "format" spec, which tells tbl(1) how -->
358 <!-- * how to format each row and column. -->
359 <xsl:for-each select=".//segtitle">
360 <!-- * l = "left", which hard-codes left-alignment for tabular -->
361 <!-- * output of all segmentedlist content -->
362 <xsl:text>l</xsl:text>
364 <!-- * last line of table format section must end with a dot -->
365 <xsl:text>. </xsl:text>
366 <!-- * optionally suppress output of segtitle -->
368 <xsl:when test="$man.segtitle.suppress != 0">
369 <!-- * non-zero = "suppress", so do nothing -->
372 <!-- * "0" = "do not suppress", so output the segtitle(s) -->
373 <xsl:apply-templates select=".//segtitle" mode="table-title"/>
374 <xsl:text> </xsl:text>
377 <xsl:apply-templates/>
378 <!-- * .TE = "Table End" -->
379 <xsl:text>.TE </xsl:text>
380 <xsl:text>.\" line length decrease back to previous value </xsl:text>
381 <xsl:text>.ll -(\n(LLu * 62u / 100u) </xsl:text>
382 <!-- * put a blank line of space below the table -->
383 <xsl:text>.sp </xsl:text>
386 <xsl:template match="segmentedlist/segtitle" mode="table-title">
387 <xsl:call-template name="italic">
388 <xsl:with-param name="node" select="."/>
389 <xsl:with-param name="context" select="."/>
392 <xsl:when test="position() = last()"/> <!-- do nothing -->
394 <!-- * tbl(1) treats tab characters as delimiters between -->
395 <!-- * cells; so we need to output a tab after each -->
396 <!-- * segtitle except the last one -->
397 <xsl:text>	</xsl:text>
402 <xsl:template match="segmentedlist/seglistitem">
403 <xsl:apply-templates/>
404 <xsl:text> </xsl:text>
407 <xsl:template match="segmentedlist/seglistitem/seg">
408 <!-- * the T{ and T} stuff are delimiters to tell tbl(1) that -->
409 <!-- * the delimited contents are "text blocks" that groff(1) -->
410 <!-- * needs to process -->
411 <xsl:text>T{ </xsl:text>
412 <xsl:variable name="contents">
413 <xsl:apply-templates/>
415 <xsl:value-of select="normalize-space($contents)"/>
416 <xsl:text> T}</xsl:text>
418 <xsl:when test="position() = last()"/> <!-- do nothing -->
420 <!-- * tbl(1) treats tab characters as delimiters between -->
421 <!-- * cells; so we need to output a tab after each -->
422 <!-- * segtitle except the last one -->
423 <xsl:text>	</xsl:text>
428 <!-- ==================================================================== -->
430 <xsl:template match="calloutlist">
431 <xsl:if test="title|info/title">
432 <xsl:call-template name="formal.object.heading"/>
434 <!-- * This template was originally copied over from the HTML -->
435 <!-- * calloutlist template, which precedes the following -->
436 <!-- * apply-templates with the comment "Preserve order of PIs and -->
437 <!-- * comments"; I'm not certain that it will actually have that -->
438 <!-- * effect for all cases, and it seems like there is probably a -->
439 <!-- * better way to do it, but anyway, I’m preserving it here for -->
440 <!-- * consistency. -->
442 select="*[not(self::callout or self::title or self::titleabbrev)]
443 |comment()[not(preceding-sibling::callout)]
444 |processing-instruction()[not(preceding-sibling::callout)]"/>
445 <!-- * put callout list into a table -->
446 <xsl:text>.TS </xsl:text>
447 <xsl:text>tab(:); </xsl:text>
448 <!-- * the following defines the row layout for the table: two columns, -->
449 <!-- * with the first cell in each row right-aligned, and the second -->
450 <!-- * cell left aligned with a width of 75% of the line length -->
451 <xsl:text>r lw(\n(.lu*75u/100u). </xsl:text>
452 <xsl:apply-templates select="callout
453 |comment()[preceding-sibling::callout]
454 |processing-instruction()[preceding-sibling::callout]"/>
455 <xsl:text>.TE </xsl:text>
458 <xsl:template match="calloutlist/title"/>
460 <xsl:template match="callout">
461 <!-- * first cell of each row is the set of callout numbers for this -->
462 <!-- * particular callout -->
463 <xsl:call-template name="callout.arearefs">
464 <xsl:with-param name="arearefs" select="@arearefs"/>
466 <!-- * end of the first cell in the row; the \h hackery is to correct -->
467 <!-- * for the excessive horizontal whitespace that tbl(1) adds between -->
468 <!-- * cells in the same row -->
469 <xsl:text>\h'-2n':</xsl:text>
470 <!-- * start the next cell in the row, which has the prose contents -->
471 <!-- * (description/explanation) for the callout -->
472 <xsl:text>T{ </xsl:text>
473 <xsl:apply-templates/>
474 <xsl:text>T} </xsl:text>
475 <!-- * end of the last cell and end of the row -->
478 <xsl:template name="callout.arearefs">
479 <xsl:param name="arearefs"></xsl:param>
480 <!-- * callout can have multiple values in its arearefs attribute, so -->
481 <!-- * we use the position param to track the postion of each value -->
482 <xsl:param name="position">1</xsl:param>
483 <xsl:if test="$arearefs!=''">
485 <xsl:when test="substring-before($arearefs,' ')=''">
486 <xsl:call-template name="callout.arearef">
487 <xsl:with-param name="arearef" select="$arearefs"/>
488 <xsl:with-param name="position" select="$position"/>
492 <xsl:call-template name="callout.arearef">
493 <xsl:with-param name="arearef"
494 select="substring-before($arearefs,' ')"/>
495 <xsl:with-param name="position" select="$position"/>
499 <xsl:call-template name="callout.arearefs">
500 <xsl:with-param name="arearefs"
501 select="substring-after($arearefs,' ')"/>
502 <xsl:with-param name="position" select="$position + 1"/>
507 <xsl:template name="callout.arearef">
508 <xsl:param name="arearef"></xsl:param>
509 <!-- * callout can have multiple values in its arearefs attribute, so -->
510 <!-- * we use the position param to track the postion of each value -->
511 <xsl:param name="position"></xsl:param>
512 <xsl:variable name="targets" select="key('id',$arearef)"/>
513 <xsl:variable name="target" select="$targets[1]"/>
515 <xsl:call-template name="check.id.unique">
516 <xsl:with-param name="linkend" select="$arearef"/>
520 <xsl:when test="count($target)=0">
521 <xsl:text>???</xsl:text>
523 <xsl:when test="local-name($target)='co'">
524 <!-- * if this is not the first value in the set of values in the -->
525 <!-- * arearef attribute for this callout, then we prepend a groff -->
526 <!-- * non-breaking space to it, to prevent groff from injecting -->
527 <!-- * linebreaks into the output. For callout instances with -->
528 <!-- * multiple values in their arearefs attributes, that results -->
529 <!-- * in all of callout numbers beings listed on the same line. -->
530 <xsl:if test="not($position = 1)">
531 <xsl:text>\ </xsl:text>
533 <xsl:apply-templates select="$target"
534 mode="calloutlist-callout-number"/>
536 <!-- * the manpages stylesheet does not really support areaset and -->
537 <!-- * area (because we can't/don't actually render the callout bugs -->
538 <!-- * at the specified coordinates); however, the following (for -->
539 <!-- * what it's worth) might cause the callout numbers in the -->
540 <!-- * calloutlist to be render at least (then again, maybe it won't; -->
541 <!-- * it's not actually been tested... -->
542 <xsl:when test="local-name($target)='areaset'">
543 <xsl:call-template name="callout-bug">
544 <xsl:with-param name="conum">
545 <xsl:apply-templates select="$target" mode="conumber"/>
549 <xsl:when test="local-name($target)='area'">
551 <xsl:when test="$target/parent::areaset">
552 <xsl:call-template name="callout-bug">
553 <xsl:with-param name="conum">
555 select="$target/parent::areaset" mode="conumber"/>
560 <xsl:call-template name="callout-bug">
561 <xsl:with-param name="conum">
562 <xsl:apply-templates select="$target"
570 <xsl:text>???</xsl:text>
575 <!-- * we bold the actual callout bugs and put -->
576 <!-- * parenthesis around them -->
577 <xsl:template name="callout-bug">
578 <xsl:param name="conum" select='1'/>
579 <xsl:text>\fB(</xsl:text>
580 <xsl:value-of select="$conum"/>
581 <xsl:text>)\fR</xsl:text>
584 <!-- * we bold the callout numbers and follow each -->
585 <!-- * with a period -->
586 <xsl:template name="calloutlist-callout-number">
587 <xsl:param name="conum" select='1'/>
588 <xsl:text>\fB</xsl:text>
589 <xsl:value-of select="$conum"/>
590 <xsl:text>.\fR</xsl:text>
593 <xsl:template match="co" mode="calloutlist-callout-number">
594 <xsl:call-template name="calloutlist-callout-number">
595 <xsl:with-param name="conum">
596 <xsl:number count="co"
598 from="programlisting|screen|literallayout|synopsis"