Debian Codegraph @

xsl/glossary.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="glossary.tocdepth">5</xsl:param>
8 <xsl:param name="glossary.numbered">1</xsl:param>
9
10 <!-- ############
11 # glossary #
12 ############ -->
13
14 <xsl:template match="glossary">
15 <xsl:text>% -------- &#10;</xsl:text>
16 <xsl:text>% GLOSSARY &#10;</xsl:text>
17 <xsl:text>% -------- &#10;</xsl:text>
18
19 <xsl:variable name="level">
20 <xsl:call-template name="get.sect.level"/>
21 </xsl:variable>
22
23 <xsl:variable name="title.text">
24 <xsl:call-template name="gentext">
25 <xsl:with-param name="key" select="'Glossary'"/>
26 </xsl:call-template>
27 </xsl:variable>
28
29 <xsl:choose>
30 <xsl:when test="$glossary.numbered = '0'">
31 <!-- Unumbered section (but in TOC) -->
32 <xsl:call-template name="section.unnumbered">
33 <xsl:with-param name="tocdepth" select="number($glossary.tocdepth)"/>
34 <xsl:with-param name="level" select="$level"/>
35 <xsl:with-param name="title" select="$title.text"/>
36 </xsl:call-template>
37 </xsl:when>
38 <xsl:when test="title">
39 <!-- Numbered section from a <title> node -->
40 <xsl:call-template name="makeheading">
41 <xsl:with-param name="level" select="$level"/>
42 <xsl:with-param name="allnum" select="'1'"/>
43 </xsl:call-template>
44 <xsl:apply-templates select="." mode="section.body"/>
45 </xsl:when>
46 <xsl:otherwise>
47 <!-- Numbered section from a generated title -->
48 <xsl:call-template name="maketitle">
49 <xsl:with-param name="level" select="$level"/>
50 <xsl:with-param name="title" select="$title.text"/>
51 </xsl:call-template>
52 <xsl:apply-templates select="." mode="section.body"/>
53 </xsl:otherwise>
54 </xsl:choose>
55 </xsl:template>
56
57 <xsl:template match="glossary" mode="section.body">
58 <xsl:variable name="divs" select="glossdiv"/>
59 <xsl:variable name="entries" select="glossentry"/>
60 <xsl:variable name="preamble" select="*[not(self::title
61 or self::subtitle
62 or self::glossdiv
63 or self::glossentry)]"/>
64 <xsl:if test="$preamble">
65 <xsl:apply-templates select="$preamble"/>
66 </xsl:if>
67
68 <xsl:if test="$entries">
69 <xsl:text>&#10;\noindent&#10;</xsl:text>
70 <xsl:text>\begin{description}&#10;</xsl:text>
71 <xsl:apply-templates select="$entries"/>
72 <xsl:text>&#10;\end{description}&#10;</xsl:text>
73 </xsl:if>
74
75 <xsl:if test="$divs">
76 <xsl:apply-templates select="$divs"/>
77 </xsl:if>
78 </xsl:template>
79
80 <xsl:template match="glossary/glossaryinfo"/>
81 <xsl:template match="glossary/title"/>
82 <xsl:template match="glossary/subtitle"/>
83 <xsl:template match="glossary/titleabbrev"/>
84
85
86 <!-- ############
87 # glossdiv #
88 ############ -->
89
90 <xsl:template match="glossdiv">
91 <!-- find the appropriate section level -->
92 <xsl:variable name="l">
93 <xsl:call-template name="get.sect.level">
94 <xsl:with-param name="n" select="parent::glossary"/>
95 </xsl:call-template>
96 </xsl:variable>
97 <xsl:call-template name="map.sect.level">
98 <xsl:with-param name="level" select="$l+1"/>
99 </xsl:call-template>
100 <xsl:text>{</xsl:text>
101 <xsl:call-template name="normalize-scape">
102 <xsl:with-param name="string" select="title"/>
103 </xsl:call-template>
104 <xsl:text>}&#10;</xsl:text>
105 <xsl:call-template name="label.id"/>
106
107 <!-- display the stuff before the entries -->
108 <xsl:apply-templates select="*[not(self::glossentry)]"/>
109
110 <!-- now, display the description list -->
111 <xsl:text>&#10;\noindent&#10;</xsl:text>
112 <xsl:text>\begin{description}&#10;</xsl:text>
113 <xsl:apply-templates select="glossentry"/>
114 <xsl:text>&#10;\end{description}&#10;</xsl:text>
115 </xsl:template>
116
117
118 <!-- #############
119 # glosslist #
120 ############# -->
121
122 <xsl:template match="glossdiv/title" />
123
124 <xsl:template match="glosslist">
125 <xsl:text>&#10;\noindent&#10;</xsl:text>
126 <xsl:text>\begin{description}&#10;</xsl:text>
127 <xsl:apply-templates/>
128 <xsl:text>&#10;\end{description}&#10;</xsl:text>
129 </xsl:template>
130
131 <xsl:template match="glosslist/title" />
132 <xsl:template match="glosslist/blockinfo" />
133
134
135 <!-- ##############
136 # glossentry #
137 ############## -->
138
139 <xsl:template match="glossentry">
140 <xsl:apply-templates select="*[not(self::glosssee or self::glossdef)]"/>
141 <xsl:apply-templates select="glosssee|glossdef"/>
142 <xsl:text>&#10;&#10;</xsl:text>
143 </xsl:template>
144
145 <xsl:template match="glossentry/glossterm">
146 <xsl:text>\item[</xsl:text>
147 <xsl:if test="../@id or ../@xml:id">
148 <xsl:text>\hypertarget{</xsl:text>
149 <xsl:apply-templates select=".." mode="id-encode"/>
150 <xsl:text>}</xsl:text>
151 </xsl:if>
152 <xsl:text>{</xsl:text>
153 <xsl:variable name="term">
154 <xsl:apply-templates/>
155 </xsl:variable>
156 <xsl:value-of select="normalize-space($term)"/>
157 <xsl:text>}]~ </xsl:text>
158 </xsl:template>
159
160 <xsl:template match="glossentry/acronym">
161 <xsl:text> (\texttt{</xsl:text><xsl:apply-templates/><xsl:text>}) </xsl:text>
162 </xsl:template>
163
164 <xsl:template match="glossentry/abbrev">
165 <xsl:text> [ </xsl:text><xsl:apply-templates/><xsl:text> ] </xsl:text>
166 </xsl:template>
167
168 <!-- not printed -->
169 <xsl:template match="glossentry/revhistory"/>
170
171 <xsl:template match="glossentry/glossdef">
172 <xsl:text>&#10;</xsl:text>
173 <xsl:apply-templates select="*[not(self::glossseealso)]"/>
174 <xsl:apply-templates select="glossseealso"/>
175 </xsl:template>
176
177 <xsl:template match="glossseealso|glosssee">
178 <xsl:variable name="oterm" select="@otherterm"/>
179 <xsl:variable name="targets" select="//node()[@id=$oterm or @xml:id=$oterm]"/>
180 <xsl:variable name="target" select="$targets[1]"/>
181 <xsl:variable name="text">
182 <xsl:apply-templates/>
183 </xsl:variable>
184 <xsl:text> </xsl:text>
185 <xsl:if test="position()=1">
186 <xsl:if test="self::glosssee">
187 <xsl:text>&#10;&#10;</xsl:text>
188 </xsl:if>
189 <xsl:call-template name="gentext.element.name"/>
190 <xsl:call-template name="gentext.space"/>
191 </xsl:if>
192 <xsl:call-template name="gentext.startquote"/>
193 <xsl:choose>
194 <xsl:when test="@otherterm">
195 <xsl:call-template name="hyperlink.markup">
196 <xsl:with-param name="linkend" select="@otherterm"/>
197 <xsl:with-param name="text">
198 <xsl:choose>
199 <xsl:when test="$text!=''">
200 <xsl:value-of select="$text"/>
201 </xsl:when>
202 <xsl:otherwise>
203 <xsl:apply-templates select="$target" mode="xref"/>
204 </xsl:otherwise>
205 </xsl:choose>
206 </xsl:with-param>
207 </xsl:call-template>
208 </xsl:when>
209 <xsl:otherwise>
210 <xsl:value-of select="$text"/>
211 </xsl:otherwise>
212 </xsl:choose>
213 <xsl:call-template name="gentext.endquote"/>
214
215 <xsl:choose>
216 <xsl:when test="position()=last()">
217 <xsl:text>.</xsl:text>
218 </xsl:when>
219 <xsl:otherwise>
220 <xsl:text>, </xsl:text>
221 </xsl:otherwise>
222 </xsl:choose>
223 </xsl:template>
224
225 <xsl:template match="glossentry" mode="xref">
226 <xsl:apply-templates select="./glossterm" mode="xref"/>
227 </xsl:template>
228
229 <xsl:template match="glossterm" mode="xref">
230 <xsl:apply-templates/>
231 </xsl:template>
232
233 </xsl:stylesheet>
234