2 <!DOCTYPE xsl:stylesheet [
3 <!ENTITY % common.entities SYSTEM
"../common/entities.ent">
6 <xsl:stylesheet xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
9 <!-- ********************************************************************
10 $Id: glossary.xsl,v 1.1 2007/03/10 05:15:13 scott Exp $
11 ********************************************************************
13 This file is part of the XSL DocBook Stylesheet distribution.
14 See ../README or http://nwalsh.com/docbook/xsl/ for copyright
15 and other information.
17 ******************************************************************** -->
19 <!-- ==================================================================== -->
21 <xsl:variable name=
"language">
22 <xsl:call-template name=
"l10n.language"/>
25 <xsl:template match=
"glossary">
26 <xsl:call-template name=
"id.warning"/>
29 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
30 <xsl:if test=
"$generate.id.attributes != 0">
31 <xsl:attribute name=
"id">
32 <xsl:call-template name=
"object.id"/>
36 <xsl:call-template name=
"glossary.titlepage"/>
39 <xsl:when test=
"glossdiv">
40 <xsl:apply-templates select=
"(glossdiv[1]/preceding-sibling::*)"/>
43 <xsl:apply-templates select=
"(glossentry[1]/preceding-sibling::*)"/>
48 <xsl:when test=
"glossdiv">
49 <xsl:apply-templates select=
"glossdiv"/>
54 <xsl:when test=
"$glossary.sort != 0">
55 <xsl:apply-templates select=
"glossentry">
56 <xsl:sort lang=
"{$language}"
57 select=
"translate(glossterm, &lowercase;,
59 </xsl:apply-templates>
62 <xsl:apply-templates select=
"glossentry"/>
69 <xsl:if test=
"not(parent::article)">
70 <xsl:call-template name=
"process.footnotes"/>
75 <xsl:template match=
"glossary/glossaryinfo"></xsl:template>
76 <xsl:template match=
"glossary/info"></xsl:template>
77 <xsl:template match=
"glossary/title"></xsl:template>
78 <xsl:template match=
"glossary/subtitle"></xsl:template>
79 <xsl:template match=
"glossary/titleabbrev"></xsl:template>
81 <!-- ==================================================================== -->
83 <xsl:template match=
"glosslist">
85 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
86 <xsl:call-template name=
"anchor"/>
87 <xsl:if test=
"blockinfo/title|info/title|title">
88 <xsl:call-template name=
"formal.object.heading"/>
92 <xsl:when test=
"$glossary.sort != 0">
93 <xsl:apply-templates select=
"glossentry">
94 <xsl:sort lang=
"{$language}"
95 select=
"translate(glossterm, &lowercase;,
97 </xsl:apply-templates>
100 <xsl:apply-templates select=
"glossentry"/>
107 <!-- ==================================================================== -->
109 <xsl:template match=
"glossdiv">
110 <xsl:call-template name=
"id.warning"/>
113 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
114 <xsl:apply-templates select=
"(glossentry[1]/preceding-sibling::*)"/>
118 <xsl:when test=
"$glossary.sort != 0">
119 <xsl:apply-templates select=
"glossentry">
120 <xsl:sort lang=
"{$language}"
121 select=
"translate(glossterm, &lowercase;,
123 </xsl:apply-templates>
126 <xsl:apply-templates select=
"glossentry"/>
133 <xsl:template match=
"glossdiv/title">
135 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
136 <xsl:apply-templates/>
140 <!-- ==================================================================== -->
144 GlossTerm, Acronym?, Abbrev?,
147 (GlossSee | GlossDef+)
150 <xsl:template match=
"glossentry">
152 <xsl:when test=
"$glossentry.show.acronym = 'primary'">
154 <xsl:call-template name=
"anchor">
155 <xsl:with-param name=
"conditional">
157 <xsl:when test=
"$glossterm.auto.link != 0">0</xsl:when>
158 <xsl:otherwise>1</xsl:otherwise>
164 <xsl:when test=
"acronym|abbrev">
165 <xsl:apply-templates select=
"acronym|abbrev"/>
166 <xsl:text> (
</xsl:text>
167 <xsl:apply-templates select=
"glossterm"/>
168 <xsl:text>)
</xsl:text>
171 <xsl:apply-templates select=
"glossterm"/>
176 <xsl:when test=
"$glossentry.show.acronym = 'yes'">
178 <xsl:call-template name=
"anchor">
179 <xsl:with-param name=
"conditional">
181 <xsl:when test=
"$glossterm.auto.link != 0">0</xsl:when>
182 <xsl:otherwise>1</xsl:otherwise>
187 <xsl:apply-templates select=
"glossterm"/>
189 <xsl:if test=
"acronym|abbrev">
190 <xsl:text> (
</xsl:text>
191 <xsl:apply-templates select=
"acronym|abbrev"/>
192 <xsl:text>)
</xsl:text>
198 <xsl:call-template name=
"anchor">
199 <xsl:with-param name=
"conditional">
201 <xsl:when test=
"$glossterm.auto.link != 0">0</xsl:when>
202 <xsl:otherwise>1</xsl:otherwise>
207 <xsl:apply-templates select=
"glossterm"/>
212 <xsl:apply-templates select=
"indexterm|revhistory|glosssee|glossdef"/>
215 <xsl:template match=
"glossentry/glossterm">
216 <xsl:apply-templates/>
217 <xsl:if test=
"following-sibling::glossterm">,
</xsl:if>
220 <xsl:template match=
"glossentry/acronym">
221 <xsl:apply-templates/>
222 <xsl:if test=
"following-sibling::acronym|following-sibling::abbrev">,
</xsl:if>
225 <xsl:template match=
"glossentry/abbrev">
226 <xsl:apply-templates/>
227 <xsl:if test=
"following-sibling::acronym|following-sibling::abbrev">,
</xsl:if>
230 <xsl:template match=
"glossentry/revhistory">
233 <xsl:template match=
"glossentry/glosssee">
234 <xsl:variable name=
"otherterm" select=
"@otherterm"/>
235 <xsl:variable name=
"targets" select=
"key('id', $otherterm)"/>
236 <xsl:variable name=
"target" select=
"$targets[1]"/>
240 <xsl:variable name=
"template">
241 <xsl:call-template name=
"gentext.template">
242 <xsl:with-param name=
"context" select=
"'glossary'"/>
243 <xsl:with-param name=
"name" select=
"'see'"/>
247 <xsl:variable name=
"title">
249 <xsl:when test=
"$target">
251 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
252 <xsl:attribute name=
"href">
253 <xsl:call-template name=
"href.target">
254 <xsl:with-param name=
"object" select=
"$target"/>
257 <xsl:apply-templates select=
"$target" mode=
"xref-to"/>
260 <xsl:when test=
"$otherterm != '' and not($target)">
262 <xsl:text>Warning: glosssee @otherterm reference not found:
</xsl:text>
263 <xsl:value-of select=
"$otherterm"/>
265 <xsl:apply-templates/>
268 <xsl:apply-templates/>
273 <xsl:call-template name=
"substitute-markup">
274 <xsl:with-param name=
"template" select=
"$template"/>
275 <xsl:with-param name=
"title" select=
"$title"/>
277 <xsl:text>.
</xsl:text>
282 <xsl:template match=
"glossentry/glossdef">
284 <xsl:apply-templates select=
"*[local-name(.) != 'glossseealso']"/>
285 <xsl:if test=
"glossseealso">
287 <xsl:variable name=
"template">
288 <xsl:call-template name=
"gentext.template">
289 <xsl:with-param name=
"context" select=
"'glossary'"/>
290 <xsl:with-param name=
"name" select=
"'seealso'"/>
293 <xsl:variable name=
"title">
294 <xsl:apply-templates select=
"glossseealso"/>
296 <xsl:call-template name=
"substitute-markup">
297 <xsl:with-param name=
"template" select=
"$template"/>
298 <xsl:with-param name=
"title" select=
"$title"/>
305 <xsl:template match=
"glossseealso">
306 <xsl:variable name=
"otherterm" select=
"@otherterm"/>
307 <xsl:variable name=
"targets" select=
"key('id', $otherterm)"/>
308 <xsl:variable name=
"target" select=
"$targets[1]"/>
311 <xsl:when test=
"$target">
313 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
314 <xsl:attribute name=
"href">
315 <xsl:call-template name=
"href.target">
316 <xsl:with-param name=
"object" select=
"$target"/>
319 <xsl:apply-templates select=
"$target" mode=
"xref-to"/>
322 <xsl:when test=
"$otherterm != '' and not($target)">
324 <xsl:text>Warning: glossseealso @otherterm reference not found:
</xsl:text>
325 <xsl:value-of select=
"$otherterm"/>
327 <xsl:apply-templates/>
330 <xsl:apply-templates/>
335 <xsl:when test=
"position() = last()">
336 <xsl:text>.
</xsl:text>
339 <xsl:text>,
</xsl:text>
344 <!-- ==================================================================== -->
346 <!-- Glossary collection -->
348 <xsl:template match=
"glossary[@role='auto']" priority=
"2">
349 <xsl:variable name=
"terms"
350 select=
"//glossterm[not(parent::glossdef)]|//firstterm"/>
351 <xsl:variable name=
"collection" select=
"document($glossary.collection, .)"/>
353 <xsl:call-template name=
"id.warning"/>
355 <xsl:if test=
"$glossary.collection = ''">
357 <xsl:text>Warning: processing automatic glossary
</xsl:text>
358 <xsl:text>without a glossary.collection file.
</xsl:text>
362 <xsl:if test=
"not($collection) and $glossary.collection != ''">
364 <xsl:text>Warning: processing automatic glossary but unable to
</xsl:text>
365 <xsl:text>open glossary.collection file '
</xsl:text>
366 <xsl:value-of select=
"$glossary.collection"/>
367 <xsl:text>'
</xsl:text>
372 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
373 <xsl:if test=
"$generate.id.attributes != 0">
374 <xsl:attribute name=
"id">
375 <xsl:call-template name=
"object.id"/>
379 <xsl:call-template name=
"glossary.titlepage"/>
382 <xsl:when test=
"glossdiv and $collection//glossdiv">
383 <xsl:for-each select=
"$collection//glossdiv">
384 <!-- first see if there are any in this div -->
385 <xsl:variable name=
"exist.test">
386 <xsl:for-each select=
"glossentry">
387 <xsl:variable name=
"cterm" select=
"glossterm"/>
388 <xsl:if test=
"$terms[@baseform = $cterm or . = $cterm]">
389 <xsl:value-of select=
"glossterm"/>
394 <xsl:if test=
"$exist.test != ''">
395 <xsl:apply-templates select=
"." mode=
"auto-glossary">
396 <xsl:with-param name=
"terms" select=
"$terms"/>
397 </xsl:apply-templates>
404 <xsl:when test=
"$glossary.sort != 0">
405 <xsl:for-each select=
"$collection//glossentry">
406 <xsl:sort lang=
"{$language}"
407 select=
"translate(glossterm, &lowercase;,
409 <xsl:variable name=
"cterm" select=
"glossterm"/>
410 <xsl:if test=
"$terms[@baseform = $cterm or . = $cterm]">
411 <xsl:apply-templates select=
"." mode=
"auto-glossary"/>
416 <xsl:for-each select=
"$collection//glossentry">
417 <xsl:variable name=
"cterm" select=
"glossterm"/>
418 <xsl:if test=
"$terms[@baseform = $cterm or . = $cterm]">
419 <xsl:apply-templates select=
"." mode=
"auto-glossary"/>
428 <xsl:if test=
"not(parent::article)">
429 <xsl:call-template name=
"process.footnotes"/>
434 <xsl:template match=
"*" mode=
"auto-glossary">
435 <!-- pop back out to the default mode for most elements -->
436 <xsl:apply-templates select=
"."/>
439 <xsl:template match=
"glossdiv" mode=
"auto-glossary">
440 <xsl:param name=
"terms" select=
"."/>
443 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
444 <xsl:apply-templates select=
"(glossentry[1]/preceding-sibling::*)"/>
448 <xsl:when test=
"$glossary.sort != 0">
449 <xsl:for-each select=
"glossentry">
450 <xsl:sort lang=
"{$language}"
451 select=
"translate(glossterm, &lowercase;,
453 <xsl:variable name=
"cterm" select=
"glossterm"/>
454 <xsl:if test=
"$terms[@baseform = $cterm or . = $cterm]">
455 <xsl:apply-templates select=
"." mode=
"auto-glossary"/>
460 <xsl:for-each select=
"glossentry">
461 <xsl:variable name=
"cterm" select=
"glossterm"/>
462 <xsl:if test=
"$terms[@baseform = $cterm or . = $cterm]">
463 <xsl:apply-templates select=
"." mode=
"auto-glossary"/>
472 <!-- ==================================================================== -->