root/docs/docbook-xsl/manpages/lists.xsl

Revision 23dea7e00df87480acb58bb3398283c2bb227949, 6.1 kB (checked in by Theo Schlossnagle <jesus@omniti.com>, 8 years ago)

pull docs into master

  • Property mode set to 100644
Line 
1 <?xml version='1.0'?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
3                 version='1.0'>
4
5 <!-- ********************************************************************
6      $Id: lists.xsl,v 1.21 2005/08/11 04:42:26 xmldoc Exp $
7      ********************************************************************
8
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.
12
13      ******************************************************************** -->
14
15 <xsl:template match="para[ancestor::listitem or ancestor::step or ancestor::glossdef]|
16                      simpara[ancestor::listitem or ancestor::step or ancestor::glossdef]|
17                      remark[ancestor::listitem or ancestor::step or ancestor::glossdef]">
18   <xsl:call-template name="mixed-block"/>
19   <xsl:text>&#10;</xsl:text>
20   <xsl:if test="following-sibling::*[1][
21                 self::para or
22                 self::simpara or
23                 self::remark
24                 ]">
25     <!-- * Make sure multiple paragraphs within a list item don't -->
26     <!-- * merge together.                                        -->
27     <xsl:text>.sp&#10;</xsl:text>
28   </xsl:if>
29 </xsl:template>
30
31 <xsl:template match="variablelist|glosslist">
32   <xsl:if test="title">
33     <xsl:text>.PP&#10;</xsl:text>
34     <xsl:apply-templates mode="bold" select="title"/>
35     <xsl:text>&#10;</xsl:text>
36   </xsl:if>
37   <xsl:apply-templates/>
38 </xsl:template>
39
40 <xsl:template match="varlistentry|glossentry">
41   <xsl:text>.TP&#10;</xsl:text>
42   <!-- * read in contents of all terms or glossterms so that we can run -->
43   <!-- * normalize-space on them as a set before rendering -->
44   <xsl:variable name="content">
45     <!-- * check each term/glossterm to see if it is the last one in the set; -->
46     <!-- * if not last, render a comma and space after it so that multiple -->
47     <!-- * terms/glossterms are displayed as a comma-separated list -->
48     <xsl:for-each select="term|glossterm">
49       <xsl:apply-templates/>
50       <xsl:choose>
51         <xsl:when test="position() = last()"/> <!-- do nothing -->
52         <xsl:otherwise>
53           <xsl:text>, </xsl:text>
54         </xsl:otherwise>
55       </xsl:choose>
56     </xsl:for-each>
57   </xsl:variable>
58   <xsl:value-of select="normalize-space($content)"/>
59   <xsl:text>&#10;</xsl:text>
60   <xsl:apply-templates/>
61 </xsl:template>
62
63 <xsl:template match="varlistentry/term"/>
64 <xsl:template match="glossentry/glossterm"/>
65
66 <xsl:template match="variablelist[ancestor::listitem or ancestor::step or ancestor::glossdef]|
67                      glosslist[ancestor::listitem or ancestor::step or ancestor::glossdef]">
68   <xsl:text>.RS&#10;</xsl:text>
69   <xsl:apply-templates/>
70   <xsl:text>.RE&#10;</xsl:text>
71   <xsl:if test="following-sibling::node() or
72                 parent::para[following-sibling::node()] or
73                 parent::simpara[following-sibling::node()] or
74                 parent::remark[following-sibling::node()]">
75     <xsl:text>.IP&#10;</xsl:text>
76   </xsl:if>
77 </xsl:template>
78
79 <xsl:template match="varlistentry/listitem|glossentry/glossdef">
80   <xsl:apply-templates/>
81 </xsl:template>
82
83 <xsl:template match="itemizedlist/listitem">
84   <!-- * We output a real bullet here (rather than, "\(bu", -->
85   <!-- * the roff bullet) because, when we do character-map -->
86   <!-- * processing before final output, the character-map will -->
87   <!-- * handle conversion of the &#x2022; to "\(bu" for us -->
88   <xsl:text>&#x2022;&#10;</xsl:text>
89   <xsl:apply-templates/>
90   <xsl:if test="following-sibling::listitem">
91     <xsl:text>.TP&#10;</xsl:text>
92   </xsl:if>
93 </xsl:template>
94
95 <xsl:template match="orderedlist/listitem|procedure/step">
96   <xsl:number format="1."/>
97   <xsl:text>&#10;</xsl:text>
98   <xsl:apply-templates/>
99   <xsl:if test="position()!=last()">
100     <xsl:text>.TP&#10;</xsl:text>
101   </xsl:if>
102 </xsl:template>
103
104 <xsl:template match="itemizedlist|orderedlist|procedure">
105   <xsl:text>.TP 3&#10;</xsl:text>
106   <xsl:apply-templates/>
107 </xsl:template>
108
109 <xsl:template match="itemizedlist[ancestor::listitem or ancestor::step  or ancestor::glossdef]|
110                      orderedlist[ancestor::listitem or ancestor::step or ancestor::glossdef]|
111                      procedure[ancestor::listitem or ancestor::step or ancestor::glossdef]">
112   <xsl:text>.RS&#10;</xsl:text>
113   <xsl:text>.TP 3&#10;</xsl:text>
114   <xsl:apply-templates/>
115   <xsl:text>.RE&#10;</xsl:text>
116   <xsl:if test="following-sibling::node() or
117                 parent::para[following-sibling::node()] or
118                 parent::simpara[following-sibling::node()] or
119                 parent::remark[following-sibling::node()]">
120     <xsl:text>.IP&#10;</xsl:text>
121   </xsl:if>
122 </xsl:template>
123
124 <!-- ================================================================== -->
125  
126 <!-- * for simplelist type="inline", render it as a comma-separated list -->
127 <xsl:template match="simplelist[@type='inline']">
128
129   <!-- * if dbchoice PI exists, use that to determine the choice separator -->
130   <!-- * (that is, equivalent of "and" or "or" in current locale), or literal -->
131   <!-- * value of "choice" otherwise -->
132   <xsl:variable name="localized-choice-separator">
133     <xsl:choose>
134       <xsl:when test="processing-instruction('dbchoice')">
135         <xsl:call-template name="select.choice.separator"/>
136       </xsl:when>
137       <xsl:otherwise>
138         <!-- * empty -->
139       </xsl:otherwise>
140     </xsl:choose>
141   </xsl:variable>
142
143   <xsl:for-each select="member">
144     <xsl:apply-templates/>
145     <xsl:choose>
146       <xsl:when test="position() = last()"/> <!-- do nothing -->
147       <xsl:otherwise>
148         <xsl:text>, </xsl:text>
149         <xsl:if test="position() = last() - 1">
150           <xsl:if test="$localized-choice-separator != ''">
151             <xsl:value-of select="$localized-choice-separator"/>
152             <xsl:text> </xsl:text>
153           </xsl:if>
154         </xsl:if>
155       </xsl:otherwise>
156     </xsl:choose>
157   </xsl:for-each>
158   <xsl:text>&#10;</xsl:text>
159 </xsl:template>
160
161 <!-- * if simplelist type is not inline, render it as a one-column vertical -->
162 <!-- * list (ignoring the values of the type and columns attributes) -->
163 <xsl:template match="simplelist">
164   <xsl:for-each select="member">
165     <xsl:text>.IP&#10;</xsl:text>
166     <xsl:apply-templates/>
167     <xsl:text>&#10;</xsl:text>
168   </xsl:for-each>
169 </xsl:template>
170
171 </xsl:stylesheet>
Note: See TracBrowser for help on using the browser.