2 <!DOCTYPE xsl:stylesheet [
3 <!ENTITY % common.entities SYSTEM "../common/entities.ent">
6 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
7 xmlns:xlink='http://www.w3.org/1999/xlink'
8 exclude-result-prefixes="xlink"
11 <!-- ********************************************************************
12 $Id: glossary.xsl 8421 2009-05-04 07:49:49Z bobstayton $
13 ********************************************************************
15 This file is part of the XSL DocBook Stylesheet distribution.
16 See ../README or http://docbook.sf.net/release/xsl/current/ for
17 copyright and other information.
19 ******************************************************************** -->
21 <!-- ==================================================================== -->
23 <xsl:template match="glossary">
24 &setup-language-variable;
25 <xsl:call-template name="id.warning"/>
28 <xsl:apply-templates select="." mode="common.html.attributes"/>
29 <xsl:if test="$generate.id.attributes != 0">
30 <xsl:attribute name="id">
31 <xsl:call-template name="object.id"/>
35 <xsl:call-template name="glossary.titlepage"/>
38 <xsl:when test="glossdiv">
39 <xsl:apply-templates select="(glossdiv[1]/preceding-sibling::*)"/>
41 <xsl:when test="glossentry">
42 <xsl:apply-templates select="(glossentry[1]/preceding-sibling::*)"/>
45 <xsl:apply-templates/>
50 <xsl:when test="glossdiv">
51 <xsl:apply-templates select="glossdiv"/>
53 <xsl:when test="glossentry">
56 <xsl:when test="$glossary.sort != 0">
57 <xsl:apply-templates select="glossentry">
58 <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
59 </xsl:apply-templates>
62 <xsl:apply-templates select="glossentry"/>
68 <!-- empty glossary -->
72 <xsl:if test="not(parent::article)">
73 <xsl:call-template name="process.footnotes"/>
78 <xsl:template match="glossary/glossaryinfo"></xsl:template>
79 <xsl:template match="glossary/info"></xsl:template>
80 <xsl:template match="glossary/title"></xsl:template>
81 <xsl:template match="glossary/subtitle"></xsl:template>
82 <xsl:template match="glossary/titleabbrev"></xsl:template>
84 <!-- ==================================================================== -->
86 <xsl:template match="glosslist">
87 &setup-language-variable;
89 <xsl:apply-templates select="." mode="common.html.attributes"/>
90 <xsl:call-template name="anchor"/>
91 <xsl:if test="blockinfo/title|info/title|title">
92 <xsl:call-template name="formal.object.heading"/>
96 <xsl:when test="$glossary.sort != 0">
97 <xsl:apply-templates select="glossentry">
98 <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
99 </xsl:apply-templates>
102 <xsl:apply-templates select="glossentry"/>
109 <!-- ==================================================================== -->
111 <xsl:template match="glossdiv">
112 &setup-language-variable;
113 <xsl:call-template name="id.warning"/>
116 <xsl:apply-templates select="." mode="common.html.attributes"/>
117 <xsl:apply-templates select="(glossentry[1]/preceding-sibling::*)"/>
121 <xsl:when test="$glossary.sort != 0">
122 <xsl:apply-templates select="glossentry">
123 <xsl:sort lang="{$language}"
124 select="translate(glossterm, $lowercase,
126 </xsl:apply-templates>
129 <xsl:apply-templates select="glossentry"/>
136 <xsl:template match="glossdiv/title">
138 <xsl:apply-templates select="." mode="common.html.attributes"/>
139 <xsl:apply-templates/>
143 <!-- ==================================================================== -->
147 GlossTerm, Acronym?, Abbrev?,
150 (GlossSee | GlossDef+)
153 <xsl:template match="glossentry">
155 <xsl:when test="$glossentry.show.acronym = 'primary'">
157 <xsl:call-template name="anchor">
158 <xsl:with-param name="conditional">
160 <xsl:when test="$glossterm.auto.link != 0">0</xsl:when>
161 <xsl:otherwise>1</xsl:otherwise>
167 <xsl:when test="acronym|abbrev">
168 <xsl:apply-templates select="acronym|abbrev"/>
169 <xsl:text> (</xsl:text>
170 <xsl:apply-templates select="glossterm"/>
171 <xsl:text>)</xsl:text>
174 <xsl:apply-templates select="glossterm"/>
179 <xsl:when test="$glossentry.show.acronym = 'yes'">
181 <xsl:call-template name="anchor">
182 <xsl:with-param name="conditional">
184 <xsl:when test="$glossterm.auto.link != 0">0</xsl:when>
185 <xsl:otherwise>1</xsl:otherwise>
190 <xsl:apply-templates select="glossterm"/>
192 <xsl:if test="acronym|abbrev">
193 <xsl:text> (</xsl:text>
194 <xsl:apply-templates select="acronym|abbrev"/>
195 <xsl:text>)</xsl:text>
201 <xsl:call-template name="anchor">
202 <xsl:with-param name="conditional">
204 <xsl:when test="$glossterm.auto.link != 0">0</xsl:when>
205 <xsl:otherwise>1</xsl:otherwise>
210 <xsl:apply-templates select="glossterm"/>
215 <xsl:apply-templates select="indexterm|revhistory|glosssee|glossdef"/>
218 <xsl:template match="glossentry/glossterm">
219 <xsl:apply-templates/>
220 <xsl:if test="following-sibling::glossterm">, </xsl:if>
223 <xsl:template match="glossentry/acronym">
224 <xsl:apply-templates/>
225 <xsl:if test="following-sibling::acronym|following-sibling::abbrev">, </xsl:if>
228 <xsl:template match="glossentry/abbrev">
229 <xsl:apply-templates/>
230 <xsl:if test="following-sibling::acronym|following-sibling::abbrev">, </xsl:if>
233 <xsl:template match="glossentry/revhistory">
236 <xsl:template match="glossentry/glosssee">
237 <xsl:variable name="otherterm" select="@otherterm"/>
238 <xsl:variable name="targets" select="key('id', $otherterm)"/>
239 <xsl:variable name="target" select="$targets[1]"/>
240 <xsl:variable name="xlink" select="@xlink:href"/>
244 <xsl:variable name="template">
245 <xsl:call-template name="gentext.template">
246 <xsl:with-param name="context" select="'glossary'"/>
247 <xsl:with-param name="name" select="'see'"/>
251 <xsl:variable name="title">
253 <xsl:when test="$target">
255 <xsl:apply-templates select="." mode="common.html.attributes"/>
256 <xsl:attribute name="href">
257 <xsl:call-template name="href.target">
258 <xsl:with-param name="object" select="$target"/>
261 <xsl:apply-templates select="$target" mode="xref-to"/>
264 <xsl:when test="$xlink">
265 <xsl:call-template name="simple.xlink">
266 <xsl:with-param name="content">
267 <xsl:apply-templates/>
271 <xsl:when test="$otherterm != '' and not($target)">
273 <xsl:text>Warning: glosssee @otherterm reference not found: </xsl:text>
274 <xsl:value-of select="$otherterm"/>
276 <xsl:apply-templates/>
279 <xsl:apply-templates/>
284 <xsl:call-template name="substitute-markup">
285 <xsl:with-param name="template" select="$template"/>
286 <xsl:with-param name="title" select="$title"/>
292 <xsl:template match="glossentry/glossdef">
294 <xsl:apply-templates select="*[local-name(.) != 'glossseealso']"/>
295 <xsl:if test="glossseealso">
297 <xsl:variable name="template">
298 <xsl:call-template name="gentext.template">
299 <xsl:with-param name="context" select="'glossary'"/>
300 <xsl:with-param name="name" select="'seealso'"/>
303 <xsl:variable name="title">
304 <xsl:apply-templates select="glossseealso"/>
306 <xsl:call-template name="substitute-markup">
307 <xsl:with-param name="template" select="$template"/>
308 <xsl:with-param name="title" select="$title"/>
315 <xsl:template match="glossseealso">
316 <xsl:variable name="otherterm" select="@otherterm"/>
317 <xsl:variable name="targets" select="key('id', $otherterm)"/>
318 <xsl:variable name="target" select="$targets[1]"/>
319 <xsl:variable name="xlink" select="@xlink:href"/>
322 <xsl:when test="$target">
324 <xsl:apply-templates select="." mode="common.html.attributes"/>
325 <xsl:attribute name="href">
326 <xsl:call-template name="href.target">
327 <xsl:with-param name="object" select="$target"/>
330 <xsl:apply-templates select="$target" mode="xref-to"/>
333 <xsl:when test="$xlink">
334 <xsl:call-template name="simple.xlink">
335 <xsl:with-param name="content">
336 <xsl:apply-templates/>
340 <xsl:when test="$otherterm != '' and not($target)">
342 <xsl:text>Warning: glossseealso @otherterm reference not found: </xsl:text>
343 <xsl:value-of select="$otherterm"/>
345 <xsl:apply-templates/>
348 <xsl:apply-templates/>
353 <xsl:when test="position() = last()"/>
355 <xsl:call-template name="gentext.template">
356 <xsl:with-param name="context" select="'glossary'"/>
357 <xsl:with-param name="name" select="'seealso-separator'"/>
363 <!-- ==================================================================== -->
365 <!-- Glossary collection -->
367 <xsl:template match="glossary[@role='auto']" priority="2">
368 &setup-language-variable;
369 <xsl:variable name="terms"
370 select="//glossterm[not(parent::glossdef)]|//firstterm"/>
371 <xsl:variable name="collection" select="document($glossary.collection, .)"/>
373 <xsl:call-template name="id.warning"/>
375 <xsl:if test="$glossary.collection = ''">
377 <xsl:text>Warning: processing automatic glossary </xsl:text>
378 <xsl:text>without a glossary.collection file.</xsl:text>
382 <xsl:if test="not($collection) and $glossary.collection != ''">
384 <xsl:text>Warning: processing automatic glossary but unable to </xsl:text>
385 <xsl:text>open glossary.collection file '</xsl:text>
386 <xsl:value-of select="$glossary.collection"/>
387 <xsl:text>'</xsl:text>
392 <xsl:apply-templates select="." mode="common.html.attributes"/>
393 <xsl:if test="$generate.id.attributes != 0">
394 <xsl:attribute name="id">
395 <xsl:call-template name="object.id"/>
399 <xsl:call-template name="glossary.titlepage"/>
402 <xsl:when test="glossdiv and $collection//glossdiv">
403 <xsl:for-each select="$collection//glossdiv">
404 <!-- first see if there are any in this div -->
405 <xsl:variable name="exist.test">
406 <xsl:for-each select="glossentry">
407 <xsl:variable name="cterm" select="glossterm"/>
408 <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
409 <xsl:value-of select="glossterm"/>
414 <xsl:if test="$exist.test != ''">
415 <xsl:apply-templates select="." mode="auto-glossary">
416 <xsl:with-param name="terms" select="$terms"/>
417 </xsl:apply-templates>
424 <xsl:when test="$glossary.sort != 0">
425 <xsl:for-each select="$collection//glossentry">
426 <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>
427 <xsl:variable name="cterm" select="glossterm"/>
428 <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
429 <xsl:apply-templates select="." mode="auto-glossary"/>
434 <xsl:for-each select="$collection//glossentry">
435 <xsl:variable name="cterm" select="glossterm"/>
436 <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
437 <xsl:apply-templates select="." mode="auto-glossary"/>
446 <xsl:if test="not(parent::article)">
447 <xsl:call-template name="process.footnotes"/>
452 <xsl:template match="*" mode="auto-glossary">
453 <!-- pop back out to the default mode for most elements -->
454 <xsl:apply-templates select="."/>
457 <xsl:template match="glossdiv" mode="auto-glossary">
458 <xsl:param name="terms" select="."/>
460 &setup-language-variable;
463 <xsl:apply-templates select="." mode="common.html.attributes"/>
464 <xsl:apply-templates select="(glossentry[1]/preceding-sibling::*)"/>
468 <xsl:when test="$glossary.sort != 0">
469 <xsl:for-each select="glossentry">
470 <xsl:sort lang="{$language}" select="normalize-space(translate(concat(@sortas, glossterm[not(parent::glossentry/@sortas) or parent::glossentry/@sortas = '']), &lowercase;, &uppercase;))"/>!
471 <xsl:variable name="cterm" select="glossterm"/>
472 <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
473 <xsl:apply-templates select="." mode="auto-glossary"/>
478 <xsl:for-each select="glossentry">
479 <xsl:variable name="cterm" select="glossterm"/>
480 <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
481 <xsl:apply-templates select="." mode="auto-glossary"/>
490 <!-- ==================================================================== -->