Debian Codegraph @

xsl/refentry.xsl

raw
1 <?xml version='1.0'?>
2 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version='1.0'>
3
4 <!--############################################################################
5 XSLT Stylesheet DocBook -> LaTeX
6 ############################################################################ -->
7 <xsl:param name="refentry.tocdepth">5</xsl:param>
8 <xsl:param name="refentry.numbered">1</xsl:param>
9 <xsl:param name="refentry.generate.name" select="0"/>
10 <xsl:param name="refclass.suppress" select="0"/>
11
12 <xsl:template name="refsect.level">
13 <xsl:param name="n" select="."/>
14 <xsl:variable name="level">
15 <xsl:call-template name="get.sect.level">
16 <xsl:with-param name="n" select="$n/ancestor::refentry"/>
17 </xsl:call-template>
18 </xsl:variable>
19
20 <xsl:variable name="offset">
21 <xsl:choose>
22 <xsl:when test="local-name($n)='refsynopsisdiv'">1</xsl:when>
23 <xsl:when test="local-name($n)='refsect1'">1</xsl:when>
24 <xsl:when test="local-name($n)='refsect2'">2</xsl:when>
25 <xsl:when test="local-name($n)='refsect3'">3</xsl:when>
26 <xsl:when test="local-name($n)='refsection'">
27 <xsl:value-of select="count($n/ancestor::refsection)+1"/>
28 </xsl:when>
29 <xsl:otherwise>1</xsl:otherwise>
30 </xsl:choose>
31 </xsl:variable>
32 <xsl:value-of select="$level + $offset"/>
33 </xsl:template>
34
35 <!-- #############
36 # reference #
37 ############# -->
38
39 <xsl:template match="reference">
40 <xsl:text>&#10;</xsl:text>
41 <xsl:text>% Reference &#10;</xsl:text>
42 <xsl:text>% ---------&#10;</xsl:text>
43 <xsl:call-template name="makeheading">
44 <!-- raise to the highest existing book section level (part or chapter) -->
45 <xsl:with-param name="level">
46 <xsl:choose>
47 <xsl:when test="preceding-sibling::part or
48 following-sibling::part">-1</xsl:when>
49 <xsl:otherwise>0</xsl:otherwise>
50 </xsl:choose>
51 </xsl:with-param>
52 </xsl:call-template>
53 <xsl:apply-templates select="partintro"/>
54 <xsl:apply-templates select="*[local-name(.) != 'partintro']"/>
55 </xsl:template>
56
57 <xsl:template match="reference/docinfo"/>
58 <xsl:template match="reference/title"/>
59 <xsl:template match="reference/subtitle"/>
60 <xsl:template match="refentryinfo|refentryinfo/*"/>
61
62 <!-- ############
63 # refentry #
64 ############ -->
65
66 <xsl:template match="refentry">
67 <xsl:variable name="refmeta" select=".//refmeta"/>
68 <xsl:variable name="refentrytitle" select="$refmeta//refentrytitle"/>
69 <xsl:variable name="refnamediv" select=".//refnamediv"/>
70 <xsl:variable name="refname" select="$refnamediv//refname"/>
71 <xsl:variable name="title">
72 <xsl:choose>
73 <xsl:when test="$refentrytitle">
74 <xsl:apply-templates select="$refentrytitle[1]"/>
75 </xsl:when>
76 <xsl:when test="$refname">
77 <xsl:apply-templates select="$refname[1]"/>
78 </xsl:when>
79 <xsl:otherwise></xsl:otherwise>
80 </xsl:choose>
81 </xsl:variable>
82 <xsl:text>&#10;</xsl:text>
83 <xsl:text>% Refentry &#10;</xsl:text>
84 <xsl:text>% ---------&#10;</xsl:text>
85
86 <xsl:variable name="level">
87 <xsl:call-template name="get.sect.level"/>
88 </xsl:variable>
89
90 <xsl:choose>
91 <xsl:when test="$refentry.numbered = '0'">
92 <!-- Unumbered refentry title (but in TOC) -->
93 <xsl:call-template name="section.unnumbered">
94 <xsl:with-param name="level" select="$level"/>
95 <xsl:with-param name="title" select="$title"/>
96 <xsl:with-param name="tocdepth" select="$refentry.tocdepth"/>
97 </xsl:call-template>
98 </xsl:when>
99 <xsl:otherwise>
100 <!-- Numbered refentry title -->
101 <xsl:call-template name="maketitle">
102 <xsl:with-param name="level" select="$level"/>
103 <xsl:with-param name="title" select="$title"/>
104 </xsl:call-template>
105 <xsl:apply-templates/>
106 </xsl:otherwise>
107 </xsl:choose>
108 </xsl:template>
109
110 <xsl:template match="refmeta">
111 <xsl:apply-templates select="indexterm"/>
112 </xsl:template>
113
114 <xsl:template match="refentrytitle">
115 <xsl:call-template name="inline.charseq"/>
116 </xsl:template>
117
118 <xsl:template match="manvolnum">
119 <xsl:if test="$refentry.xref.manvolnum != 0">
120 <xsl:text>(</xsl:text>
121 <xsl:apply-templates/>
122 <xsl:text>)</xsl:text>
123 </xsl:if>
124 </xsl:template>
125
126 <!-- ###############
127 # refsynopsis #
128 ############### -->
129
130 <!-- A refsynopsisdiv with a title is handled like a refsectx -->
131 <xsl:template match="refsynopsisdiv">
132 <!-- Without title, generate a localized "Synopsis" heading -->
133 <xsl:call-template name="maketitle">
134 <xsl:with-param name="num" select="'0'"/>
135 <xsl:with-param name="level">
136 <xsl:call-template name="refsect.level"/>
137 </xsl:with-param>
138 <xsl:with-param name="title">
139 <xsl:call-template name="gentext">
140 <xsl:with-param name="key" select="'RefSynopsisDiv'"/>
141 </xsl:call-template>
142 </xsl:with-param>
143 </xsl:call-template>
144
145 <xsl:apply-templates/>
146 </xsl:template>
147
148 <xsl:template match="refsynopsisdivinfo"/>
149 <xsl:template match="refsynopsisdiv/title"/>
150
151 <!-- ##############
152 # refnamediv #
153 ############## -->
154
155 <xsl:template match="refnamediv">
156 <!-- Generate a localized "Name" subheading if is non-zero -->
157 <xsl:if test="$refentry.generate.name != 0">
158 <xsl:call-template name="maketitle">
159 <xsl:with-param name="num" select="'0'"/>
160 <xsl:with-param name="level">
161 <xsl:call-template name="refsect.level"/>
162 </xsl:with-param>
163 <xsl:with-param name="title">
164 <xsl:call-template name="gentext">
165 <xsl:with-param name="key" select="'RefName'"/>
166 </xsl:call-template>
167 </xsl:with-param>
168 </xsl:call-template>
169 </xsl:if>
170
171 <!-- refdescriptor is used only if no refname -->
172 <xsl:choose>
173 <xsl:when test="refname">
174 <xsl:apply-templates select="refname"/>
175 </xsl:when>
176 <xsl:otherwise>
177 <xsl:apply-templates select="refdescriptor"/>
178 </xsl:otherwise>
179 </xsl:choose>
180 <xsl:apply-templates select="*[local-name(.)!='refname' and
181 local-name(.)!='refdescriptor']"/>
182 </xsl:template>
183
184 <xsl:template match="refname">
185 <xsl:apply-templates/>
186 <xsl:if test="following-sibling::refname">
187 <xsl:text>, </xsl:text>
188 </xsl:if>
189 </xsl:template>
190
191 <xsl:template match="refpurpose">
192 <xsl:text> --- </xsl:text>
193 <xsl:apply-templates/>
194 </xsl:template>
195
196 <xsl:template match="refdescriptor">
197 <xsl:apply-templates/>
198 </xsl:template>
199
200 <xsl:template match="refclass">
201 <xsl:if test="$refclass.suppress = 0">
202 <!-- Displayed as block -->
203 <xsl:text>&#10;&#10;</xsl:text>
204 <xsl:if test="@role">
205 <xsl:value-of select="@role"/>
206 <xsl:text>: </xsl:text>
207 </xsl:if>
208 <xsl:apply-templates/>
209 <xsl:text>&#10;</xsl:text>
210 </xsl:if>
211 </xsl:template>
212
213 <!-- ############
214 # refsectx #
215 ############ -->
216
217 <xsl:template match="refsect1/title"/>
218 <xsl:template match="refsect2/title"/>
219 <xsl:template match="refsect3/title"/>
220 <xsl:template match="refsection/title"/>
221 <xsl:template match="refsect1info"/>
222 <xsl:template match="refsect2info"/>
223 <xsl:template match="refsect3info"/>
224
225 <xsl:template match="refsection|refsect1|refsect2|refsect3">
226 <xsl:call-template name="makeheading">
227 <xsl:with-param name="level">
228 <xsl:call-template name="refsect.level"/>
229 </xsl:with-param>
230 <xsl:with-param name="num" select="0"/>
231 </xsl:call-template>
232 <xsl:apply-templates/>
233 </xsl:template>
234
235 <xsl:template match="refsynopsisdiv[title|
236 refsynopsisdivinfo/title|
237 info/title]">
238 <!-- Select the title node -->
239 <xsl:variable name="title"
240 select="(title|
241 refsynopsisdivinfo/title|
242 info/title)[1]"/>
243
244 <xsl:call-template name="makeheading">
245 <xsl:with-param name="level">
246 <xsl:call-template name="refsect.level"/>
247 </xsl:with-param>
248 <xsl:with-param name="num" select="0"/>
249 <xsl:with-param name="title" select="$title"/>
250 </xsl:call-template>
251 <xsl:apply-templates/>
252 </xsl:template>
253
254 </xsl:stylesheet>