source: clfs-sysroot/BOOK/stylesheets/lfs-xsl/docbook-xsl-snapshot/xhtml/glossary.xsl@ b07cfb1

Last change on this file since b07cfb1 was a18aefd, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Added lfs-xsl stylesheets.

  • Property mode set to 100644
File size: 17.1 KB
Line 
1<?xml version="1.0" encoding="ASCII"?>
2<!--This file was created automatically by html2xhtml-->
3<!--from the HTML stylesheets.-->
4<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version="1.0">
5
6<!-- ********************************************************************
7 $Id$
8 ********************************************************************
9
10 This file is part of the XSL DocBook Stylesheet distribution.
11 See ../README or http://docbook.sf.net/release/xsl/current/ for
12 copyright and other information.
13
14 ******************************************************************** -->
15
16<!-- ==================================================================== -->
17
18<xsl:template match="glossary">
19
20<xsl:variable name="language">
21 <xsl:call-template name="l10n.language"/>
22</xsl:variable>
23
24<xsl:variable name="lowercase">
25 <xsl:call-template name="gentext">
26 <xsl:with-param name="key">normalize.sort.input</xsl:with-param>
27 </xsl:call-template>
28</xsl:variable>
29
30<xsl:variable name="uppercase">
31 <xsl:call-template name="gentext">
32 <xsl:with-param name="key">normalize.sort.output</xsl:with-param>
33 </xsl:call-template>
34</xsl:variable>
35
36 <xsl:call-template name="id.warning"/>
37
38 <div>
39 <xsl:apply-templates select="." mode="class.attribute"/>
40 <xsl:if test="$generate.id.attributes != 0">
41 <xsl:attribute name="id">
42 <xsl:call-template name="object.id"/>
43 </xsl:attribute>
44 </xsl:if>
45
46 <xsl:call-template name="glossary.titlepage"/>
47
48 <xsl:choose>
49 <xsl:when test="glossdiv">
50 <xsl:apply-templates select="(glossdiv[1]/preceding-sibling::*)"/>
51 </xsl:when>
52 <xsl:otherwise>
53 <xsl:apply-templates select="(glossentry[1]/preceding-sibling::*)"/>
54 </xsl:otherwise>
55 </xsl:choose>
56
57 <xsl:choose>
58 <xsl:when test="glossdiv">
59 <xsl:apply-templates select="glossdiv"/>
60 </xsl:when>
61 <xsl:otherwise>
62 <dl>
63 <xsl:choose>
64 <xsl:when test="$glossary.sort != 0">
65 <xsl:apply-templates select="glossentry">
66 <xsl:sort lang="{$language}" select="translate(glossterm, $lowercase, $uppercase)"/>
67 </xsl:apply-templates>
68 </xsl:when>
69 <xsl:otherwise>
70 <xsl:apply-templates select="glossentry"/>
71 </xsl:otherwise>
72 </xsl:choose>
73 </dl>
74 </xsl:otherwise>
75 </xsl:choose>
76
77 <xsl:if test="not(parent::article)">
78 <xsl:call-template name="process.footnotes"/>
79 </xsl:if>
80 </div>
81</xsl:template>
82
83<xsl:template match="glossary/glossaryinfo"/>
84<xsl:template match="glossary/info"/>
85<xsl:template match="glossary/title"/>
86<xsl:template match="glossary/subtitle"/>
87<xsl:template match="glossary/titleabbrev"/>
88
89<!-- ==================================================================== -->
90
91<xsl:template match="glosslist">
92
93<xsl:variable name="language">
94 <xsl:call-template name="l10n.language"/>
95</xsl:variable>
96
97<xsl:variable name="lowercase">
98 <xsl:call-template name="gentext">
99 <xsl:with-param name="key">normalize.sort.input</xsl:with-param>
100 </xsl:call-template>
101</xsl:variable>
102
103<xsl:variable name="uppercase">
104 <xsl:call-template name="gentext">
105 <xsl:with-param name="key">normalize.sort.output</xsl:with-param>
106 </xsl:call-template>
107</xsl:variable>
108
109 <div>
110 <xsl:apply-templates select="." mode="class.attribute"/>
111 <xsl:call-template name="anchor"/>
112 <xsl:if test="blockinfo/title|info/title|title">
113 <xsl:call-template name="formal.object.heading"/>
114 </xsl:if>
115 <dl>
116 <xsl:choose>
117 <xsl:when test="$glossary.sort != 0">
118 <xsl:apply-templates select="glossentry">
119 <xsl:sort lang="{$language}" select="translate(glossterm, $lowercase, $uppercase)"/>
120 </xsl:apply-templates>
121 </xsl:when>
122 <xsl:otherwise>
123 <xsl:apply-templates select="glossentry"/>
124 </xsl:otherwise>
125 </xsl:choose>
126 </dl>
127 </div>
128</xsl:template>
129
130<!-- ==================================================================== -->
131
132<xsl:template match="glossdiv">
133
134<xsl:variable name="language">
135 <xsl:call-template name="l10n.language"/>
136</xsl:variable>
137
138<xsl:variable name="lowercase">
139 <xsl:call-template name="gentext">
140 <xsl:with-param name="key">normalize.sort.input</xsl:with-param>
141 </xsl:call-template>
142</xsl:variable>
143
144<xsl:variable name="uppercase">
145 <xsl:call-template name="gentext">
146 <xsl:with-param name="key">normalize.sort.output</xsl:with-param>
147 </xsl:call-template>
148</xsl:variable>
149
150 <xsl:call-template name="id.warning"/>
151
152 <div>
153 <xsl:apply-templates select="." mode="class.attribute"/>
154 <xsl:apply-templates select="(glossentry[1]/preceding-sibling::*)"/>
155
156 <dl>
157 <xsl:choose>
158 <xsl:when test="$glossary.sort != 0">
159 <xsl:apply-templates select="glossentry">
160 <xsl:sort lang="{$language}" select="translate(glossterm, $lowercase, $uppercase)"/>
161 </xsl:apply-templates>
162 </xsl:when>
163 <xsl:otherwise>
164 <xsl:apply-templates select="glossentry"/>
165 </xsl:otherwise>
166 </xsl:choose>
167 </dl>
168 </div>
169</xsl:template>
170
171<xsl:template match="glossdiv/title">
172 <h3>
173 <xsl:apply-templates select="." mode="class.attribute"/>
174 <xsl:apply-templates/>
175 </h3>
176</xsl:template>
177
178<!-- ==================================================================== -->
179
180<!--
181GlossEntry ::=
182 GlossTerm, Acronym?, Abbrev?,
183 (IndexTerm)*,
184 RevHistory?,
185 (GlossSee | GlossDef+)
186-->
187
188<xsl:template match="glossentry">
189 <xsl:choose>
190 <xsl:when test="$glossentry.show.acronym = 'primary'">
191 <dt>
192 <xsl:call-template name="anchor">
193 <xsl:with-param name="conditional">
194 <xsl:choose>
195 <xsl:when test="$glossterm.auto.link != 0">0</xsl:when>
196 <xsl:otherwise>1</xsl:otherwise>
197 </xsl:choose>
198 </xsl:with-param>
199 </xsl:call-template>
200
201 <xsl:choose>
202 <xsl:when test="acronym|abbrev">
203 <xsl:apply-templates select="acronym|abbrev"/>
204 <xsl:text> (</xsl:text>
205 <xsl:apply-templates select="glossterm"/>
206 <xsl:text>)</xsl:text>
207 </xsl:when>
208 <xsl:otherwise>
209 <xsl:apply-templates select="glossterm"/>
210 </xsl:otherwise>
211 </xsl:choose>
212 </dt>
213 </xsl:when>
214 <xsl:when test="$glossentry.show.acronym = 'yes'">
215 <dt>
216 <xsl:call-template name="anchor">
217 <xsl:with-param name="conditional">
218 <xsl:choose>
219 <xsl:when test="$glossterm.auto.link != 0">0</xsl:when>
220 <xsl:otherwise>1</xsl:otherwise>
221 </xsl:choose>
222 </xsl:with-param>
223 </xsl:call-template>
224
225 <xsl:apply-templates select="glossterm"/>
226
227 <xsl:if test="acronym|abbrev">
228 <xsl:text> (</xsl:text>
229 <xsl:apply-templates select="acronym|abbrev"/>
230 <xsl:text>)</xsl:text>
231 </xsl:if>
232 </dt>
233 </xsl:when>
234 <xsl:otherwise>
235 <dt>
236 <xsl:call-template name="anchor">
237 <xsl:with-param name="conditional">
238 <xsl:choose>
239 <xsl:when test="$glossterm.auto.link != 0">0</xsl:when>
240 <xsl:otherwise>1</xsl:otherwise>
241 </xsl:choose>
242 </xsl:with-param>
243 </xsl:call-template>
244
245 <xsl:apply-templates select="glossterm"/>
246 </dt>
247 </xsl:otherwise>
248 </xsl:choose>
249
250 <xsl:apply-templates select="indexterm|revhistory|glosssee|glossdef"/>
251</xsl:template>
252
253<xsl:template match="glossentry/glossterm">
254 <xsl:apply-templates/>
255 <xsl:if test="following-sibling::glossterm">, </xsl:if>
256</xsl:template>
257
258<xsl:template match="glossentry/acronym">
259 <xsl:apply-templates/>
260 <xsl:if test="following-sibling::acronym|following-sibling::abbrev">, </xsl:if>
261</xsl:template>
262
263<xsl:template match="glossentry/abbrev">
264 <xsl:apply-templates/>
265 <xsl:if test="following-sibling::acronym|following-sibling::abbrev">, </xsl:if>
266</xsl:template>
267
268<xsl:template match="glossentry/revhistory">
269</xsl:template>
270
271<xsl:template match="glossentry/glosssee">
272 <xsl:variable name="otherterm" select="@otherterm"/>
273 <xsl:variable name="targets" select="key('id', $otherterm)"/>
274 <xsl:variable name="target" select="$targets[1]"/>
275
276 <dd>
277 <p>
278 <xsl:variable name="template">
279 <xsl:call-template name="gentext.template">
280 <xsl:with-param name="context" select="'glossary'"/>
281 <xsl:with-param name="name" select="'see'"/>
282 </xsl:call-template>
283 </xsl:variable>
284
285 <xsl:variable name="title">
286 <xsl:choose>
287 <xsl:when test="$target">
288 <a>
289 <xsl:apply-templates select="." mode="class.attribute"/>
290 <xsl:attribute name="href">
291 <xsl:call-template name="href.target">
292 <xsl:with-param name="object" select="$target"/>
293 </xsl:call-template>
294 </xsl:attribute>
295 <xsl:apply-templates select="$target" mode="xref-to"/>
296 </a>
297 </xsl:when>
298 <xsl:when test="$otherterm != '' and not($target)">
299 <xsl:message>
300 <xsl:text>Warning: glosssee @otherterm reference not found: </xsl:text>
301 <xsl:value-of select="$otherterm"/>
302 </xsl:message>
303 <xsl:apply-templates/>
304 </xsl:when>
305 <xsl:otherwise>
306 <xsl:apply-templates/>
307 </xsl:otherwise>
308 </xsl:choose>
309 </xsl:variable>
310
311 <xsl:call-template name="substitute-markup">
312 <xsl:with-param name="template" select="$template"/>
313 <xsl:with-param name="title" select="$title"/>
314 </xsl:call-template>
315 <xsl:text>.</xsl:text>
316 </p>
317 </dd>
318</xsl:template>
319
320<xsl:template match="glossentry/glossdef">
321 <dd>
322 <xsl:apply-templates select="*[local-name(.) != 'glossseealso']"/>
323 <xsl:if test="glossseealso">
324 <p>
325 <xsl:variable name="template">
326 <xsl:call-template name="gentext.template">
327 <xsl:with-param name="context" select="'glossary'"/>
328 <xsl:with-param name="name" select="'seealso'"/>
329 </xsl:call-template>
330 </xsl:variable>
331 <xsl:variable name="title">
332 <xsl:apply-templates select="glossseealso"/>
333 </xsl:variable>
334 <xsl:call-template name="substitute-markup">
335 <xsl:with-param name="template" select="$template"/>
336 <xsl:with-param name="title" select="$title"/>
337 </xsl:call-template>
338 </p>
339 </xsl:if>
340 </dd>
341</xsl:template>
342
343<xsl:template match="glossseealso">
344 <xsl:variable name="otherterm" select="@otherterm"/>
345 <xsl:variable name="targets" select="key('id', $otherterm)"/>
346 <xsl:variable name="target" select="$targets[1]"/>
347
348 <xsl:choose>
349 <xsl:when test="$target">
350 <a>
351 <xsl:apply-templates select="." mode="class.attribute"/>
352 <xsl:attribute name="href">
353 <xsl:call-template name="href.target">
354 <xsl:with-param name="object" select="$target"/>
355 </xsl:call-template>
356 </xsl:attribute>
357 <xsl:apply-templates select="$target" mode="xref-to"/>
358 </a>
359 </xsl:when>
360 <xsl:when test="$otherterm != '' and not($target)">
361 <xsl:message>
362 <xsl:text>Warning: glossseealso @otherterm reference not found: </xsl:text>
363 <xsl:value-of select="$otherterm"/>
364 </xsl:message>
365 <xsl:apply-templates/>
366 </xsl:when>
367 <xsl:otherwise>
368 <xsl:apply-templates/>
369 </xsl:otherwise>
370 </xsl:choose>
371
372 <xsl:choose>
373 <xsl:when test="position() = last()">
374 <xsl:text>.</xsl:text>
375 </xsl:when>
376 <xsl:otherwise>
377 <xsl:text>, </xsl:text>
378 </xsl:otherwise>
379 </xsl:choose>
380</xsl:template>
381
382<!-- ==================================================================== -->
383
384<!-- Glossary collection -->
385
386<xsl:template match="glossary[@role='auto']" priority="2">
387
388<xsl:variable name="language">
389 <xsl:call-template name="l10n.language"/>
390</xsl:variable>
391
392<xsl:variable name="lowercase">
393 <xsl:call-template name="gentext">
394 <xsl:with-param name="key">normalize.sort.input</xsl:with-param>
395 </xsl:call-template>
396</xsl:variable>
397
398<xsl:variable name="uppercase">
399 <xsl:call-template name="gentext">
400 <xsl:with-param name="key">normalize.sort.output</xsl:with-param>
401 </xsl:call-template>
402</xsl:variable>
403
404 <xsl:variable name="terms" select="//glossterm[not(parent::glossdef)]|//firstterm"/>
405 <xsl:variable name="collection" select="document($glossary.collection, .)"/>
406
407 <xsl:call-template name="id.warning"/>
408
409 <xsl:if test="$glossary.collection = ''">
410 <xsl:message>
411 <xsl:text>Warning: processing automatic glossary </xsl:text>
412 <xsl:text>without a glossary.collection file.</xsl:text>
413 </xsl:message>
414 </xsl:if>
415
416 <xsl:if test="not($collection) and $glossary.collection != ''">
417 <xsl:message>
418 <xsl:text>Warning: processing automatic glossary but unable to </xsl:text>
419 <xsl:text>open glossary.collection file '</xsl:text>
420 <xsl:value-of select="$glossary.collection"/>
421 <xsl:text>'</xsl:text>
422 </xsl:message>
423 </xsl:if>
424
425 <div>
426 <xsl:apply-templates select="." mode="class.attribute"/>
427 <xsl:if test="$generate.id.attributes != 0">
428 <xsl:attribute name="id">
429 <xsl:call-template name="object.id"/>
430 </xsl:attribute>
431 </xsl:if>
432
433 <xsl:call-template name="glossary.titlepage"/>
434
435 <xsl:choose>
436 <xsl:when test="glossdiv and $collection//glossdiv">
437 <xsl:for-each select="$collection//glossdiv">
438 <!-- first see if there are any in this div -->
439 <xsl:variable name="exist.test">
440 <xsl:for-each select="glossentry">
441 <xsl:variable name="cterm" select="glossterm"/>
442 <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
443 <xsl:value-of select="glossterm"/>
444 </xsl:if>
445 </xsl:for-each>
446 </xsl:variable>
447
448 <xsl:if test="$exist.test != ''">
449 <xsl:apply-templates select="." mode="auto-glossary">
450 <xsl:with-param name="terms" select="$terms"/>
451 </xsl:apply-templates>
452 </xsl:if>
453 </xsl:for-each>
454 </xsl:when>
455 <xsl:otherwise>
456 <dl>
457 <xsl:choose>
458 <xsl:when test="$glossary.sort != 0">
459 <xsl:for-each select="$collection//glossentry">
460 <xsl:sort lang="{$language}" select="translate(glossterm, $lowercase, $uppercase)"/>
461 <xsl:variable name="cterm" select="glossterm"/>
462 <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
463 <xsl:apply-templates select="." mode="auto-glossary"/>
464 </xsl:if>
465 </xsl:for-each>
466 </xsl:when>
467 <xsl:otherwise>
468 <xsl:for-each select="$collection//glossentry">
469 <xsl:variable name="cterm" select="glossterm"/>
470 <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
471 <xsl:apply-templates select="." mode="auto-glossary"/>
472 </xsl:if>
473 </xsl:for-each>
474 </xsl:otherwise>
475 </xsl:choose>
476 </dl>
477 </xsl:otherwise>
478 </xsl:choose>
479
480 <xsl:if test="not(parent::article)">
481 <xsl:call-template name="process.footnotes"/>
482 </xsl:if>
483 </div>
484</xsl:template>
485
486<xsl:template match="*" mode="auto-glossary">
487 <!-- pop back out to the default mode for most elements -->
488 <xsl:apply-templates select="."/>
489</xsl:template>
490
491<xsl:template match="glossdiv" mode="auto-glossary">
492 <xsl:param name="terms" select="."/>
493
494
495<xsl:variable name="language">
496 <xsl:call-template name="l10n.language"/>
497</xsl:variable>
498
499<xsl:variable name="lowercase">
500 <xsl:call-template name="gentext">
501 <xsl:with-param name="key">normalize.sort.input</xsl:with-param>
502 </xsl:call-template>
503</xsl:variable>
504
505<xsl:variable name="uppercase">
506 <xsl:call-template name="gentext">
507 <xsl:with-param name="key">normalize.sort.output</xsl:with-param>
508 </xsl:call-template>
509</xsl:variable>
510
511
512 <div>
513 <xsl:apply-templates select="." mode="class.attribute"/>
514 <xsl:apply-templates select="(glossentry[1]/preceding-sibling::*)"/>
515
516 <dl>
517 <xsl:choose>
518 <xsl:when test="$glossary.sort != 0">
519 <xsl:for-each select="glossentry">
520 <xsl:sort lang="{$language}" select="translate(glossterm, $lowercase, $uppercase)"/>
521 <xsl:variable name="cterm" select="glossterm"/>
522 <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
523 <xsl:apply-templates select="." mode="auto-glossary"/>
524 </xsl:if>
525 </xsl:for-each>
526 </xsl:when>
527 <xsl:otherwise>
528 <xsl:for-each select="glossentry">
529 <xsl:variable name="cterm" select="glossterm"/>
530 <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
531 <xsl:apply-templates select="." mode="auto-glossary"/>
532 </xsl:if>
533 </xsl:for-each>
534 </xsl:otherwise>
535 </xsl:choose>
536 </dl>
537 </div>
538</xsl:template>
539
540<!-- ==================================================================== -->
541
542</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.