source: BOOK/stylesheets/lfs-xsl/docbook-xsl-snapshot/fo/glossary.xsl@ 862c47b

clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since 862c47b was f8c4e94, checked in by Manuel Canales Esparcia <manuel@…>, 17 years ago

Added LFS XSL Stylesheets.

  • Property mode set to 100644
File size: 40.9 KB
Line 
1<?xml version='1.0'?>
2<!DOCTYPE xsl:stylesheet [
3<!ENTITY % common.entities SYSTEM "../common/entities.ent">
4%common.entities;
5]>
6<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
7 xmlns:fo="http://www.w3.org/1999/XSL/Format"
8 version='1.0'>
9
10<!-- ********************************************************************
11 $Id$
12 ********************************************************************
13
14 This file is part of the XSL DocBook Stylesheet distribution.
15 See ../README or http://docbook.sf.net/release/xsl/current/ for
16 copyright and other information.
17
18 ******************************************************************** -->
19
20<!-- ==================================================================== -->
21
22<xsl:template match="glossary">
23 <xsl:call-template name="make-glossary"/>
24</xsl:template>
25
26<xsl:template match="glossdiv/title"/>
27<xsl:template match="glossdiv/subtitle"/>
28<xsl:template match="glossdiv/titleabbrev"/>
29
30<!-- ==================================================================== -->
31
32<xsl:template name="make-glossary">
33 <xsl:param name="divs" select="glossdiv"/>
34 <xsl:param name="entries" select="glossentry"/>
35 <xsl:param name="preamble" select="*[not(self::title
36 or self::subtitle
37 or self::glossdiv
38 or self::glossentry)]"/>
39
40 &setup-language-variable;
41
42 <xsl:variable name="id">
43 <xsl:call-template name="object.id"/>
44 </xsl:variable>
45
46 <xsl:variable name="presentation">
47 <xsl:call-template name="pi.dbfo_glossary-presentation"/>
48 </xsl:variable>
49
50 <xsl:variable name="term-width">
51 <xsl:call-template name="pi.dbfo_glossterm-width"/>
52 </xsl:variable>
53
54 <xsl:variable name="width">
55 <xsl:choose>
56 <xsl:when test="$term-width = ''">
57 <xsl:value-of select="$glossterm.width"/>
58 </xsl:when>
59 <xsl:otherwise>
60 <xsl:value-of select="$term-width"/>
61 </xsl:otherwise>
62 </xsl:choose>
63 </xsl:variable>
64
65 <fo:block id="{$id}">
66 <xsl:call-template name="glossary.titlepage"/>
67 </fo:block>
68
69 <xsl:if test="$preamble">
70 <xsl:apply-templates select="$preamble"/>
71 </xsl:if>
72
73 <xsl:choose>
74 <xsl:when test="$presentation = 'list'">
75 <xsl:apply-templates select="$divs" mode="glossary.as.list">
76 <xsl:with-param name="width" select="$width"/>
77 </xsl:apply-templates>
78 <xsl:if test="$entries">
79 <fo:list-block provisional-distance-between-starts="{$width}"
80 provisional-label-separation="{$glossterm.separation}"
81 xsl:use-attribute-sets="normal.para.spacing">
82 <xsl:choose>
83 <xsl:when test="$glossary.sort != 0">
84 <xsl:apply-templates select="$entries" mode="glossary.as.list">
85 <xsl:sort lang="{$language}"
86 select="translate(glossterm, $lowercase,
87 $uppercase)"/>
88 </xsl:apply-templates>
89 </xsl:when>
90 <xsl:otherwise>
91 <xsl:apply-templates select="$entries" mode="glossary.as.list"/>
92 </xsl:otherwise>
93 </xsl:choose>
94 </fo:list-block>
95 </xsl:if>
96 </xsl:when>
97 <xsl:when test="$presentation = 'blocks'">
98 <xsl:apply-templates select="$divs" mode="glossary.as.blocks"/>
99 <xsl:choose>
100 <xsl:when test="$glossary.sort != 0">
101 <xsl:apply-templates select="$entries" mode="glossary.as.blocks">
102 <xsl:sort lang="{$language}"
103 select="translate(glossterm, $lowercase,
104 $uppercase)"/>
105 </xsl:apply-templates>
106 </xsl:when>
107 <xsl:otherwise>
108 <xsl:apply-templates select="$entries" mode="glossary.as.blocks"/>
109 </xsl:otherwise>
110 </xsl:choose>
111 </xsl:when>
112 <xsl:when test="$glossary.as.blocks != 0">
113 <xsl:apply-templates select="$divs" mode="glossary.as.blocks"/>
114 <xsl:choose>
115 <xsl:when test="$glossary.sort != 0">
116 <xsl:apply-templates select="$entries" mode="glossary.as.blocks">
117 <xsl:sort lang="{$language}"
118 select="translate(glossterm, $lowercase,
119 $uppercase)"/>
120 </xsl:apply-templates>
121 </xsl:when>
122 <xsl:otherwise>
123 <xsl:apply-templates select="$entries" mode="glossary.as.blocks"/>
124 </xsl:otherwise>
125 </xsl:choose>
126 </xsl:when>
127 <xsl:otherwise>
128 <xsl:apply-templates select="$divs" mode="glossary.as.list">
129 <xsl:with-param name="width" select="$width"/>
130 </xsl:apply-templates>
131 <xsl:if test="$entries">
132 <fo:list-block provisional-distance-between-starts="{$width}"
133 provisional-label-separation="{$glossterm.separation}"
134 xsl:use-attribute-sets="normal.para.spacing">
135 <xsl:choose>
136 <xsl:when test="$glossary.sort != 0">
137 <xsl:apply-templates select="$entries" mode="glossary.as.list">
138 <xsl:sort lang="{$language}"
139 select="translate(glossterm, $lowercase,
140 $uppercase)"/>
141 </xsl:apply-templates>
142 </xsl:when>
143 <xsl:otherwise>
144 <xsl:apply-templates select="$entries" mode="glossary.as.list"/>
145 </xsl:otherwise>
146 </xsl:choose>
147 </fo:list-block>
148 </xsl:if>
149 </xsl:otherwise>
150 </xsl:choose>
151</xsl:template>
152
153<xsl:template match="book/glossary|part/glossary|/glossary" priority="2">
154 <xsl:variable name="id">
155 <xsl:call-template name="object.id"/>
156 </xsl:variable>
157
158 <xsl:variable name="master-reference">
159 <xsl:call-template name="select.pagemaster"/>
160 </xsl:variable>
161
162 <fo:page-sequence hyphenate="{$hyphenate}"
163 master-reference="{$master-reference}">
164 <xsl:attribute name="language">
165 <xsl:call-template name="l10n.language"/>
166 </xsl:attribute>
167
168 <xsl:attribute name="format">
169 <xsl:call-template name="page.number.format">
170 <xsl:with-param name="master-reference" select="$master-reference"/>
171 </xsl:call-template>
172 </xsl:attribute>
173
174 <xsl:attribute name="initial-page-number">
175 <xsl:call-template name="initial.page.number">
176 <xsl:with-param name="master-reference" select="$master-reference"/>
177 </xsl:call-template>
178 </xsl:attribute>
179
180 <xsl:attribute name="force-page-count">
181 <xsl:call-template name="force.page.count">
182 <xsl:with-param name="master-reference" select="$master-reference"/>
183 </xsl:call-template>
184 </xsl:attribute>
185
186 <xsl:attribute name="hyphenation-character">
187 <xsl:call-template name="gentext">
188 <xsl:with-param name="key" select="'hyphenation-character'"/>
189 </xsl:call-template>
190 </xsl:attribute>
191 <xsl:attribute name="hyphenation-push-character-count">
192 <xsl:call-template name="gentext">
193 <xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
194 </xsl:call-template>
195 </xsl:attribute>
196 <xsl:attribute name="hyphenation-remain-character-count">
197 <xsl:call-template name="gentext">
198 <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
199 </xsl:call-template>
200 </xsl:attribute>
201
202 <xsl:apply-templates select="." mode="running.head.mode">
203 <xsl:with-param name="master-reference" select="$master-reference"/>
204 </xsl:apply-templates>
205 <xsl:apply-templates select="." mode="running.foot.mode">
206 <xsl:with-param name="master-reference" select="$master-reference"/>
207 </xsl:apply-templates>
208
209 <fo:flow flow-name="xsl-region-body">
210 <xsl:call-template name="set.flow.properties">
211 <xsl:with-param name="element" select="local-name(.)"/>
212 <xsl:with-param name="master-reference" select="$master-reference"/>
213 </xsl:call-template>
214
215 <xsl:call-template name="make-glossary"/>
216 </fo:flow>
217 </fo:page-sequence>
218</xsl:template>
219
220<xsl:template match="glossary/glossaryinfo"></xsl:template>
221<xsl:template match="glossary/info"></xsl:template>
222<xsl:template match="glossary/title"></xsl:template>
223<xsl:template match="glossary/subtitle"></xsl:template>
224<xsl:template match="glossary/titleabbrev"></xsl:template>
225
226<!-- ==================================================================== -->
227
228<xsl:template match="glosslist">
229 &setup-language-variable;
230
231 <xsl:variable name="presentation">
232 <xsl:call-template name="pi.dbfo_glosslist-presentation"/>
233 </xsl:variable>
234
235 <xsl:variable name="term-width">
236 <xsl:call-template name="pi.dbfo_glossterm-width"/>
237 </xsl:variable>
238
239 <xsl:variable name="width">
240 <xsl:choose>
241 <xsl:when test="$term-width = ''">
242 <xsl:value-of select="$glossterm.width"/>
243 </xsl:when>
244 <xsl:otherwise>
245 <xsl:value-of select="$term-width"/>
246 </xsl:otherwise>
247 </xsl:choose>
248 </xsl:variable>
249
250 <xsl:if test="title or info/title">
251 <xsl:apply-templates select="(title|info/title)[1]" mode="list.title.mode"/>
252 </xsl:if>
253
254 <xsl:choose>
255 <xsl:when test="$presentation = 'list'">
256 <fo:list-block provisional-distance-between-starts="{$width}"
257 provisional-label-separation="{$glossterm.separation}"
258 xsl:use-attribute-sets="normal.para.spacing">
259 <xsl:choose>
260 <xsl:when test="$glossary.sort != 0">
261 <xsl:apply-templates select="glossentry" mode="glossary.as.list">
262 <xsl:sort lang="{$language}"
263 select="translate(glossterm, $lowercase,
264 $uppercase)"/>
265 </xsl:apply-templates>
266 </xsl:when>
267 <xsl:otherwise>
268 <xsl:apply-templates select="glossentry" mode="glossary.as.list"/>
269 </xsl:otherwise>
270 </xsl:choose>
271 </fo:list-block>
272 </xsl:when>
273 <xsl:when test="$presentation = 'blocks'">
274 <xsl:choose>
275 <xsl:when test="$glossary.sort != 0">
276 <xsl:apply-templates select="glossentry" mode="glossary.as.blocks">
277 <xsl:sort lang="{$language}"
278 select="translate(glossterm, $lowercase,
279 $uppercase)"/>
280 </xsl:apply-templates>
281 </xsl:when>
282 <xsl:otherwise>
283 <xsl:apply-templates select="glossentry" mode="glossary.as.blocks"/>
284 </xsl:otherwise>
285 </xsl:choose>
286 </xsl:when>
287 <xsl:when test="$glosslist.as.blocks != 0">
288 <xsl:choose>
289 <xsl:when test="$glossary.sort != 0">
290 <xsl:apply-templates select="glossentry" mode="glossary.as.blocks">
291 <xsl:sort lang="{$language}"
292 select="translate(glossterm, $lowercase,
293 $uppercase)"/>
294 </xsl:apply-templates>
295 </xsl:when>
296 <xsl:otherwise>
297 <xsl:apply-templates select="glossentry" mode="glossary.as.blocks"/>
298 </xsl:otherwise>
299 </xsl:choose>
300 </xsl:when>
301 <xsl:otherwise>
302 <fo:list-block provisional-distance-between-starts="{$width}"
303 provisional-label-separation="{$glossterm.separation}"
304 xsl:use-attribute-sets="normal.para.spacing">
305 <xsl:choose>
306 <xsl:when test="$glossary.sort != 0">
307 <xsl:apply-templates select="glossentry" mode="glossary.as.list">
308 <xsl:sort lang="{$language}"
309 select="translate(glossterm, $lowercase,
310 $uppercase)"/>
311 </xsl:apply-templates>
312 </xsl:when>
313 <xsl:otherwise>
314 <xsl:apply-templates select="glossentry" mode="glossary.as.list"/>
315 </xsl:otherwise>
316 </xsl:choose>
317 </fo:list-block>
318 </xsl:otherwise>
319 </xsl:choose>
320</xsl:template>
321
322<!-- ==================================================================== -->
323<!-- Glossary collection -->
324
325<xsl:template match="glossary[@role='auto']" priority="2">
326 <xsl:variable name="collection" select="document($glossary.collection, .)"/>
327 <xsl:if test="$glossary.collection = ''">
328 <xsl:message>
329 <xsl:text>Warning: processing automatic glossary </xsl:text>
330 <xsl:text>without a glossary.collection file.</xsl:text>
331 </xsl:message>
332 </xsl:if>
333
334 <xsl:if test="not($collection) and $glossary.collection != ''">
335 <xsl:message>
336 <xsl:text>Warning: processing automatic glossary but unable to </xsl:text>
337 <xsl:text>open glossary.collection file '</xsl:text>
338 <xsl:value-of select="$glossary.collection"/>
339 <xsl:text>'</xsl:text>
340 </xsl:message>
341 </xsl:if>
342
343 <xsl:call-template name="make-auto-glossary"/>
344</xsl:template>
345
346<xsl:template name="make-auto-glossary">
347 <xsl:param name="collection" select="document($glossary.collection, .)"/>
348 <xsl:param name="terms" select="//glossterm[not(parent::glossdef)]|//firstterm"/>
349 <xsl:param name="preamble" select="*[not(self::title
350 or self::subtitle
351 or self::glossdiv
352 or self::glossentry)]"/>
353
354 &setup-language-variable;
355
356 <xsl:variable name="id">
357 <xsl:call-template name="object.id"/>
358 </xsl:variable>
359
360 <xsl:variable name="presentation">
361 <xsl:call-template name="pi.dbfo_glossary-presentation"/>
362 </xsl:variable>
363
364 <xsl:variable name="term-width">
365 <xsl:call-template name="pi.dbfo_glossterm-width"/>
366 </xsl:variable>
367
368 <xsl:variable name="width">
369 <xsl:choose>
370 <xsl:when test="$term-width = ''">
371 <xsl:value-of select="$glossterm.width"/>
372 </xsl:when>
373 <xsl:otherwise>
374 <xsl:value-of select="$term-width"/>
375 </xsl:otherwise>
376 </xsl:choose>
377 </xsl:variable>
378
379 <xsl:if test="$glossary.collection = ''">
380 <xsl:message>
381 <xsl:text>Warning: processing automatic glossary </xsl:text>
382 <xsl:text>without a glossary.collection file.</xsl:text>
383 </xsl:message>
384 </xsl:if>
385
386 <fo:block id="{$id}">
387 <xsl:call-template name="glossary.titlepage"/>
388 </fo:block>
389
390 <xsl:if test="$preamble">
391 <xsl:apply-templates select="$preamble"/>
392 </xsl:if>
393
394 <xsl:choose>
395 <xsl:when test="glossdiv and $collection//glossdiv">
396 <xsl:for-each select="$collection//glossdiv">
397 <!-- first see if there are any in this div -->
398 <xsl:variable name="exist.test">
399 <xsl:for-each select="glossentry">
400 <xsl:variable name="cterm" select="glossterm"/>
401 <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
402 <xsl:value-of select="glossterm"/>
403 </xsl:if>
404 </xsl:for-each>
405 </xsl:variable>
406
407 <xsl:if test="$exist.test != ''">
408 <xsl:choose>
409 <xsl:when test="$presentation = 'list'">
410 <xsl:apply-templates select="." mode="auto-glossary-as-list">
411 <xsl:with-param name="width" select="$width"/>
412 <xsl:with-param name="terms" select="$terms"/>
413 </xsl:apply-templates>
414 </xsl:when>
415 <xsl:when test="$presentation = 'blocks'">
416 <xsl:apply-templates select="." mode="auto-glossary-as-blocks">
417 <xsl:with-param name="terms" select="$terms"/>
418 </xsl:apply-templates>
419 </xsl:when>
420 <xsl:when test="$glossary.as.blocks != 0">
421 <xsl:apply-templates select="." mode="auto-glossary-as-blocks">
422 <xsl:with-param name="terms" select="$terms"/>
423 </xsl:apply-templates>
424 </xsl:when>
425 <xsl:otherwise>
426 <xsl:apply-templates select="." mode="auto-glossary-as-list">
427 <xsl:with-param name="width" select="$width"/>
428 <xsl:with-param name="terms" select="$terms"/>
429 </xsl:apply-templates>
430 </xsl:otherwise>
431 </xsl:choose>
432 </xsl:if>
433 </xsl:for-each>
434 </xsl:when>
435 <xsl:otherwise>
436 <xsl:choose>
437 <xsl:when test="$presentation = 'list'">
438 <fo:list-block provisional-distance-between-starts="{$width}"
439 provisional-label-separation="{$glossterm.separation}"
440 xsl:use-attribute-sets="normal.para.spacing">
441 <xsl:choose>
442 <xsl:when test="$glossary.sort != 0">
443 <xsl:for-each select="$collection//glossentry">
444 <xsl:sort lang="{$language}"
445 select="translate(glossterm, $lowercase,
446 $uppercase)"/>
447 <xsl:variable name="cterm" select="glossterm"/>
448 <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
449 <xsl:apply-templates select="."
450 mode="auto-glossary-as-list"/>
451 </xsl:if>
452 </xsl:for-each>
453 </xsl:when>
454 <xsl:otherwise>
455 <xsl:for-each select="$collection//glossentry">
456 <xsl:variable name="cterm" select="glossterm"/>
457 <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
458 <xsl:apply-templates select="."
459 mode="auto-glossary-as-list"/>
460 </xsl:if>
461 </xsl:for-each>
462 </xsl:otherwise>
463 </xsl:choose>
464 </fo:list-block>
465 </xsl:when>
466 <xsl:when test="$presentation = 'blocks' or
467 $glossary.as.blocks != 0">
468 <xsl:choose>
469 <xsl:when test="$glossary.sort != 0">
470 <xsl:for-each select="$collection//glossentry">
471 <xsl:sort lang="{$language}"
472 select="translate(glossterm, $lowercase,
473 $uppercase)"/>
474 <xsl:variable name="cterm" select="glossterm"/>
475 <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
476 <xsl:apply-templates select="."
477 mode="auto-glossary-as-blocks"/>
478 </xsl:if>
479 </xsl:for-each>
480 </xsl:when>
481 <xsl:otherwise>
482 <xsl:for-each select="$collection//glossentry">
483 <xsl:variable name="cterm" select="glossterm"/>
484 <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
485 <xsl:apply-templates select="."
486 mode="auto-glossary-as-blocks"/>
487 </xsl:if>
488 </xsl:for-each>
489 </xsl:otherwise>
490 </xsl:choose>
491 </xsl:when>
492 <xsl:otherwise>
493 <fo:list-block provisional-distance-between-starts="{$width}"
494 provisional-label-separation="{$glossterm.separation}"
495 xsl:use-attribute-sets="normal.para.spacing">
496 <xsl:choose>
497 <xsl:when test="$glossary.sort != 0">
498 <xsl:for-each select="$collection//glossentry">
499 <xsl:sort lang="{$language}"
500 select="translate(glossterm, $lowercase,
501 $uppercase)"/>
502 <xsl:variable name="cterm" select="glossterm"/>
503 <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
504 <xsl:apply-templates select="."
505 mode="auto-glossary-as-list"/>
506 </xsl:if>
507 </xsl:for-each>
508 </xsl:when>
509 <xsl:otherwise>
510 <xsl:for-each select="$collection//glossentry">
511 <xsl:variable name="cterm" select="glossterm"/>
512 <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
513 <xsl:apply-templates select="."
514 mode="auto-glossary-as-list"/>
515 </xsl:if>
516 </xsl:for-each>
517 </xsl:otherwise>
518 </xsl:choose>
519 </fo:list-block>
520 </xsl:otherwise>
521 </xsl:choose>
522 </xsl:otherwise>
523 </xsl:choose>
524</xsl:template>
525
526<xsl:template match="book/glossary[@role='auto']|
527 part/glossary[@role='auto']|
528 /glossary[@role='auto']" priority="2.5">
529 <xsl:variable name="id"><xsl:call-template name="object.id"/></xsl:variable>
530
531 <xsl:variable name="master-reference">
532 <xsl:call-template name="select.pagemaster"/>
533 </xsl:variable>
534
535 <xsl:if test="$glossary.collection = ''">
536 <xsl:message>
537 <xsl:text>Warning: processing automatic glossary </xsl:text>
538 <xsl:text>without a glossary.collection file.</xsl:text>
539 </xsl:message>
540 </xsl:if>
541
542 <fo:page-sequence hyphenate="{$hyphenate}"
543 master-reference="{$master-reference}">
544 <xsl:attribute name="language">
545 <xsl:call-template name="l10n.language"/>
546 </xsl:attribute>
547 <xsl:attribute name="format">
548 <xsl:call-template name="page.number.format">
549 <xsl:with-param name="master-reference" select="$master-reference"/>
550 </xsl:call-template>
551 </xsl:attribute>
552
553 <xsl:attribute name="initial-page-number">
554 <xsl:call-template name="initial.page.number">
555 <xsl:with-param name="master-reference" select="$master-reference"/>
556 </xsl:call-template>
557 </xsl:attribute>
558
559 <xsl:attribute name="force-page-count">
560 <xsl:call-template name="force.page.count">
561 <xsl:with-param name="master-reference" select="$master-reference"/>
562 </xsl:call-template>
563 </xsl:attribute>
564
565 <xsl:attribute name="hyphenation-character">
566 <xsl:call-template name="gentext">
567 <xsl:with-param name="key" select="'hyphenation-character'"/>
568 </xsl:call-template>
569 </xsl:attribute>
570 <xsl:attribute name="hyphenation-push-character-count">
571 <xsl:call-template name="gentext">
572 <xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
573 </xsl:call-template>
574 </xsl:attribute>
575 <xsl:attribute name="hyphenation-remain-character-count">
576 <xsl:call-template name="gentext">
577 <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
578 </xsl:call-template>
579 </xsl:attribute>
580
581 <xsl:apply-templates select="." mode="running.head.mode">
582 <xsl:with-param name="master-reference" select="$master-reference"/>
583 </xsl:apply-templates>
584 <xsl:apply-templates select="." mode="running.foot.mode">
585 <xsl:with-param name="master-reference" select="$master-reference"/>
586 </xsl:apply-templates>
587
588 <fo:flow flow-name="xsl-region-body">
589 <xsl:call-template name="set.flow.properties">
590 <xsl:with-param name="element" select="local-name(.)"/>
591 <xsl:with-param name="master-reference" select="$master-reference"/>
592 </xsl:call-template>
593
594 <xsl:call-template name="make-auto-glossary"/>
595 </fo:flow>
596 </fo:page-sequence>
597</xsl:template>
598
599<xsl:template match="glossdiv" mode="auto-glossary-as-list">
600 <xsl:param name="width" select="$glossterm.width"/>
601 <xsl:param name="terms" select="."/>
602
603 &setup-language-variable;
604
605 <xsl:variable name="preamble"
606 select="*[not(self::title
607 or self::subtitle
608 or self::glossentry)]"/>
609
610 <xsl:call-template name="glossdiv.titlepage"/>
611
612 <xsl:apply-templates select="$preamble"/>
613
614 <fo:list-block provisional-distance-between-starts="{$width}"
615 provisional-label-separation="{$glossterm.separation}"
616 xsl:use-attribute-sets="normal.para.spacing">
617 <xsl:choose>
618 <xsl:when test="$glossary.sort != 0">
619 <xsl:for-each select="glossentry">
620 <xsl:sort lang="{$language}"
621 select="translate(glossterm, $lowercase, $uppercase)"/>
622 <xsl:variable name="cterm" select="glossterm"/>
623 <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
624 <xsl:apply-templates select="." mode="auto-glossary-as-list"/>
625 </xsl:if>
626 </xsl:for-each>
627 </xsl:when>
628 <xsl:otherwise>
629 <xsl:for-each select="glossentry">
630 <xsl:variable name="cterm" select="glossterm"/>
631 <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
632 <xsl:apply-templates select="." mode="auto-glossary-as-list"/>
633 </xsl:if>
634 </xsl:for-each>
635 </xsl:otherwise>
636 </xsl:choose>
637 </fo:list-block>
638</xsl:template>
639
640<xsl:template match="glossentry" mode="auto-glossary-as-list">
641 <xsl:apply-templates select="." mode="glossary.as.list"/>
642</xsl:template>
643
644<xsl:template match="glossdiv" mode="auto-glossary-as-blocks">
645 <xsl:param name="terms" select="."/>
646
647 &setup-language-variable;
648
649 <xsl:variable name="preamble"
650 select="*[not(self::title
651 or self::subtitle
652 or self::glossentry)]"/>
653
654 <xsl:call-template name="glossdiv.titlepage"/>
655
656 <xsl:apply-templates select="$preamble"/>
657
658 <xsl:choose>
659 <xsl:when test="$glossary.sort != 0">
660 <xsl:for-each select="glossentry">
661 <xsl:sort lang="{$language}"
662 select="translate(glossterm, $lowercase, $uppercase)"/>
663 <xsl:variable name="cterm" select="glossterm"/>
664 <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
665 <xsl:apply-templates select="." mode="auto-glossary-as-blocks"/>
666 </xsl:if>
667 </xsl:for-each>
668 </xsl:when>
669 <xsl:otherwise>
670 <xsl:for-each select="glossentry">
671 <xsl:variable name="cterm" select="glossterm"/>
672 <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
673 <xsl:apply-templates select="." mode="auto-glossary-as-blocks"/>
674 </xsl:if>
675 </xsl:for-each>
676 </xsl:otherwise>
677 </xsl:choose>
678
679</xsl:template>
680
681<xsl:template match="glossentry" mode="auto-glossary-as-blocks">
682 <xsl:apply-templates select="." mode="glossary.as.blocks"/>
683</xsl:template>
684
685<!-- ==================================================================== -->
686<!-- Format glossary as a list -->
687
688<xsl:template match="glossdiv" mode="glossary.as.list">
689 <xsl:param name="width" select="$glossterm.width"/>
690
691 &setup-language-variable;
692
693 <xsl:variable name="entries" select="glossentry"/>
694
695 <xsl:variable name="preamble"
696 select="*[not(self::title
697 or self::subtitle
698 or self::glossentry)]"/>
699
700 <xsl:call-template name="glossdiv.titlepage"/>
701
702 <xsl:apply-templates select="$preamble"/>
703
704 <fo:list-block provisional-distance-between-starts="{$width}"
705 provisional-label-separation="{$glossterm.separation}"
706 xsl:use-attribute-sets="normal.para.spacing">
707 <xsl:choose>
708 <xsl:when test="$glossary.sort != 0">
709 <xsl:apply-templates select="$entries" mode="glossary.as.list">
710 <xsl:sort lang="{$language}"
711 select="translate(glossterm, $lowercase,
712 $uppercase)"/>
713 </xsl:apply-templates>
714 </xsl:when>
715 <xsl:otherwise>
716 <xsl:apply-templates select="$entries" mode="glossary.as.list"/>
717 </xsl:otherwise>
718 </xsl:choose>
719 </fo:list-block>
720</xsl:template>
721
722<!--
723GlossEntry ::=
724 GlossTerm, Acronym?, Abbrev?,
725 (IndexTerm)*,
726 RevHistory?,
727 (GlossSee | GlossDef+)
728-->
729
730<xsl:template match="glossentry" mode="glossary.as.list">
731 <xsl:variable name="id">
732 <xsl:call-template name="object.id"/>
733 </xsl:variable>
734
735 <fo:list-item xsl:use-attribute-sets="normal.para.spacing">
736 <xsl:call-template name="anchor">
737 <xsl:with-param name="conditional">
738 <xsl:choose>
739 <xsl:when test="$glossterm.auto.link != 0
740 or $glossary.collection != ''">0</xsl:when>
741 <xsl:otherwise>1</xsl:otherwise>
742 </xsl:choose>
743 </xsl:with-param>
744 </xsl:call-template>
745
746 <fo:list-item-label end-indent="label-end()">
747 <fo:block>
748 <xsl:choose>
749 <xsl:when test="$glossentry.show.acronym = 'primary'">
750 <xsl:choose>
751 <xsl:when test="acronym|abbrev">
752 <xsl:apply-templates select="acronym|abbrev"
753 mode="glossary.as.list"/>
754 <xsl:text> (</xsl:text>
755 <xsl:apply-templates select="glossterm"
756 mode="glossary.as.list"/>
757 <xsl:text>)</xsl:text>
758 </xsl:when>
759 <xsl:otherwise>
760 <xsl:apply-templates select="glossterm"
761 mode="glossary.as.list"/>
762 </xsl:otherwise>
763 </xsl:choose>
764 </xsl:when>
765
766 <xsl:when test="$glossentry.show.acronym = 'yes'">
767 <xsl:apply-templates select="glossterm" mode="glossary.as.list"/>
768
769 <xsl:if test="acronym|abbrev">
770 <xsl:text> (</xsl:text>
771 <xsl:apply-templates select="acronym|abbrev"
772 mode="glossary.as.list"/>
773 <xsl:text>)</xsl:text>
774 </xsl:if>
775 </xsl:when>
776
777 <xsl:otherwise>
778 <xsl:apply-templates select="glossterm" mode="glossary.as.list"/>
779 </xsl:otherwise>
780 </xsl:choose>
781 <xsl:apply-templates select="indexterm"/>
782 </fo:block>
783 </fo:list-item-label>
784
785 <fo:list-item-body start-indent="body-start()">
786 <xsl:apply-templates select="glosssee|glossdef" mode="glossary.as.list"/>
787 </fo:list-item-body>
788 </fo:list-item>
789</xsl:template>
790
791<xsl:template match="glossentry/glossterm" mode="glossary.as.list">
792 <xsl:variable name="id">
793 <xsl:call-template name="object.id"/>
794 </xsl:variable>
795 <fo:inline id="{$id}">
796 <xsl:apply-templates/>
797 </fo:inline>
798 <xsl:if test="following-sibling::glossterm">, </xsl:if>
799</xsl:template>
800
801<xsl:template match="glossentry/acronym" mode="glossary.as.list">
802 <xsl:apply-templates/>
803 <xsl:if test="following-sibling::acronym|following-sibling::abbrev">, </xsl:if>
804</xsl:template>
805
806<xsl:template match="glossentry/abbrev" mode="glossary.as.list">
807 <xsl:apply-templates/>
808 <xsl:if test="following-sibling::acronym|following-sibling::abbrev">, </xsl:if>
809</xsl:template>
810
811<xsl:template match="glossentry/revhistory" mode="glossary.as.list">
812</xsl:template>
813
814<xsl:template match="glossentry/glosssee" mode="glossary.as.list">
815 <xsl:variable name="otherterm" select="@otherterm"/>
816 <xsl:variable name="targets" select="key('id', $otherterm)"/>
817 <xsl:variable name="target" select="$targets[1]"/>
818
819 <fo:block>
820 <xsl:variable name="template">
821 <xsl:call-template name="gentext.template">
822 <xsl:with-param name="context" select="'glossary'"/>
823 <xsl:with-param name="name" select="'see'"/>
824 </xsl:call-template>
825 </xsl:variable>
826 <xsl:variable name="title">
827 <xsl:choose>
828 <xsl:when test="$target">
829 <fo:basic-link internal-destination="{$otherterm}"
830 xsl:use-attribute-sets="xref.properties">
831 <xsl:apply-templates select="$target" mode="xref-to"/>
832 </fo:basic-link>
833 </xsl:when>
834 <xsl:when test="$otherterm != '' and not($target)">
835 <xsl:message>
836 <xsl:text>Warning: glosssee @otherterm reference not found: </xsl:text>
837 <xsl:value-of select="$otherterm"/>
838 </xsl:message>
839 <xsl:apply-templates mode="glossary.as.list"/>
840 </xsl:when>
841 <xsl:otherwise>
842 <xsl:apply-templates mode="glossary.as.list"/>
843 </xsl:otherwise>
844 </xsl:choose>
845 </xsl:variable>
846 <xsl:call-template name="substitute-markup">
847 <xsl:with-param name="template" select="$template"/>
848 <xsl:with-param name="title" select="$title"/>
849 </xsl:call-template>
850
851 <xsl:text>.</xsl:text>
852 </fo:block>
853</xsl:template>
854
855<xsl:template match="glossentry/glossdef" mode="glossary.as.list">
856 <xsl:apply-templates select="*[local-name(.) != 'glossseealso']"/>
857 <xsl:if test="glossseealso">
858 <fo:block>
859 <xsl:variable name="template">
860 <xsl:call-template name="gentext.template">
861 <xsl:with-param name="context" select="'glossary'"/>
862 <xsl:with-param name="name" select="'seealso'"/>
863 </xsl:call-template>
864 </xsl:variable>
865 <xsl:variable name="title">
866 <xsl:apply-templates select="glossseealso" mode="glossary.as.list"/>
867 </xsl:variable>
868 <xsl:call-template name="substitute-markup">
869 <xsl:with-param name="template" select="$template"/>
870 <xsl:with-param name="title" select="$title"/>
871 </xsl:call-template>
872 </fo:block>
873 </xsl:if>
874</xsl:template>
875
876<xsl:template match="glossentry/glossdef/para[1]|glossentry/glossdef/simpara[1]"
877 mode="glossary.as.list">
878 <fo:block>
879 <xsl:apply-templates/>
880 </fo:block>
881</xsl:template>
882
883<xsl:template match="glossseealso" mode="glossary.as.list">
884 <xsl:variable name="otherterm" select="@otherterm"/>
885 <xsl:variable name="targets" select="key('id', $otherterm)"/>
886 <xsl:variable name="target" select="$targets[1]"/>
887
888 <xsl:choose>
889 <xsl:when test="$target">
890 <fo:basic-link internal-destination="{$otherterm}"
891 xsl:use-attribute-sets="xref.properties">
892 <xsl:apply-templates select="$target" mode="xref-to"/>
893 </fo:basic-link>
894 </xsl:when>
895 <xsl:when test="$otherterm != '' and not($target)">
896 <xsl:message>
897 <xsl:text>Warning: glossseealso @otherterm reference not found: </xsl:text>
898 <xsl:value-of select="$otherterm"/>
899 </xsl:message>
900 <xsl:apply-templates mode="glossary.as.list"/>
901 </xsl:when>
902 <xsl:otherwise>
903 <xsl:apply-templates mode="glossary.as.list"/>
904 </xsl:otherwise>
905 </xsl:choose>
906
907 <xsl:choose>
908 <xsl:when test="position() = last()">
909 <xsl:text>.</xsl:text>
910 </xsl:when>
911 <xsl:otherwise>
912 <xsl:text>, </xsl:text>
913 </xsl:otherwise>
914 </xsl:choose>
915</xsl:template>
916
917<!-- ==================================================================== -->
918<!-- Format glossary blocks -->
919
920<xsl:template match="glossdiv" mode="glossary.as.blocks">
921 &setup-language-variable;
922 <xsl:variable name="entries" select="glossentry"/>
923 <xsl:variable name="preamble"
924 select="*[not(self::title
925 or self::subtitle
926 or self::glossentry)]"/>
927
928 <xsl:call-template name="glossdiv.titlepage"/>
929
930 <xsl:apply-templates select="$preamble"/>
931
932 <xsl:choose>
933 <xsl:when test="$glossary.sort != 0">
934 <xsl:apply-templates select="$entries" mode="glossary.as.blocks">
935 <xsl:sort lang="{$language}"
936 select="translate(glossterm, $lowercase,
937 $uppercase)"/>
938 </xsl:apply-templates>
939 </xsl:when>
940 <xsl:otherwise>
941 <xsl:apply-templates select="$entries" mode="glossary.as.blocks"/>
942 </xsl:otherwise>
943 </xsl:choose>
944</xsl:template>
945
946<!--
947GlossEntry ::=
948 GlossTerm, Acronym?, Abbrev?,
949 (IndexTerm)*,
950 RevHistory?,
951 (GlossSee | GlossDef+)
952-->
953
954<xsl:template match="glossentry" mode="glossary.as.blocks">
955 <xsl:variable name="id">
956 <xsl:call-template name="object.id"/>
957 </xsl:variable>
958
959 <fo:block xsl:use-attribute-sets="list.item.spacing"
960 keep-with-next.within-column="always"
961 keep-together.within-column="always">
962 <xsl:call-template name="anchor">
963 <xsl:with-param name="conditional">
964 <xsl:choose>
965 <xsl:when test="$glossterm.auto.link != 0
966 or $glossary.collection != ''">0</xsl:when>
967 <xsl:otherwise>1</xsl:otherwise>
968 </xsl:choose>
969 </xsl:with-param>
970 </xsl:call-template>
971
972 <xsl:choose>
973 <xsl:when test="$glossentry.show.acronym = 'primary'">
974 <xsl:choose>
975 <xsl:when test="acronym|abbrev">
976 <xsl:apply-templates select="acronym|abbrev" mode="glossary.as.blocks"/>
977 <xsl:text> (</xsl:text>
978 <xsl:apply-templates select="glossterm" mode="glossary.as.blocks"/>
979 <xsl:text>)</xsl:text>
980 </xsl:when>
981 <xsl:otherwise>
982 <xsl:apply-templates select="glossterm" mode="glossary.as.blocks"/>
983 </xsl:otherwise>
984 </xsl:choose>
985 </xsl:when>
986
987 <xsl:when test="$glossentry.show.acronym = 'yes'">
988 <xsl:apply-templates select="glossterm" mode="glossary.as.blocks"/>
989
990 <xsl:if test="acronym|abbrev">
991 <xsl:text> (</xsl:text>
992 <xsl:apply-templates select="acronym|abbrev" mode="glossary.as.blocks"/>
993 <xsl:text>)</xsl:text>
994 </xsl:if>
995 </xsl:when>
996
997 <xsl:otherwise>
998 <xsl:apply-templates select="glossterm" mode="glossary.as.blocks"/>
999 </xsl:otherwise>
1000 </xsl:choose>
1001
1002 <xsl:apply-templates select="indexterm"/>
1003 </fo:block>
1004
1005 <fo:block margin-left="0.25in">
1006 <xsl:apply-templates select="glosssee|glossdef" mode="glossary.as.blocks"/>
1007 </fo:block>
1008</xsl:template>
1009
1010<xsl:template match="glossentry/glossterm" mode="glossary.as.blocks">
1011 <xsl:variable name="id">
1012 <xsl:call-template name="object.id"/>
1013 </xsl:variable>
1014 <fo:inline id="{$id}">
1015 <xsl:apply-templates/>
1016 </fo:inline>
1017 <xsl:if test="following-sibling::glossterm">, </xsl:if>
1018</xsl:template>
1019
1020<xsl:template match="glossentry/acronym" mode="glossary.as.blocks">
1021 <xsl:apply-templates/>
1022 <xsl:if test="following-sibling::acronym|following-sibling::abbrev">, </xsl:if>
1023</xsl:template>
1024
1025<xsl:template match="glossentry/abbrev" mode="glossary.as.blocks">
1026 <xsl:apply-templates/>
1027 <xsl:if test="following-sibling::acronym|following-sibling::abbrev">, </xsl:if>
1028</xsl:template>
1029
1030<xsl:template match="glossentry/glosssee" mode="glossary.as.blocks">
1031 <xsl:variable name="otherterm" select="@otherterm"/>
1032 <xsl:variable name="targets" select="key('id', $otherterm)"/>
1033 <xsl:variable name="target" select="$targets[1]"/>
1034
1035 <xsl:variable name="template">
1036 <xsl:call-template name="gentext.template">
1037 <xsl:with-param name="context" select="'glossary'"/>
1038 <xsl:with-param name="name" select="'see'"/>
1039 </xsl:call-template>
1040 </xsl:variable>
1041 <xsl:variable name="title">
1042 <xsl:choose>
1043 <xsl:when test="$target">
1044 <fo:basic-link internal-destination="{$otherterm}"
1045 xsl:use-attribute-sets="xref.properties">
1046 <xsl:apply-templates select="$target" mode="xref-to"/>
1047 </fo:basic-link>
1048 </xsl:when>
1049 <xsl:when test="$otherterm != '' and not($target)">
1050 <xsl:message>
1051 <xsl:text>Warning: glosssee @otherterm reference not found: </xsl:text>
1052 <xsl:value-of select="$otherterm"/>
1053 </xsl:message>
1054 <xsl:apply-templates mode="glossary.as.blocks"/>
1055 </xsl:when>
1056 <xsl:otherwise>
1057 <xsl:apply-templates mode="glossary.as.blocks"/>
1058 </xsl:otherwise>
1059 </xsl:choose>
1060 </xsl:variable>
1061 <xsl:call-template name="substitute-markup">
1062 <xsl:with-param name="template" select="$template"/>
1063 <xsl:with-param name="title" select="$title"/>
1064 </xsl:call-template>
1065
1066 <xsl:text>.</xsl:text>
1067</xsl:template>
1068
1069<xsl:template match="glossentry/glossdef" mode="glossary.as.blocks">
1070 <xsl:apply-templates select="*[local-name(.) != 'glossseealso']"
1071 mode="glossary.as.blocks"/>
1072 <xsl:if test="glossseealso">
1073 <fo:block>
1074 <xsl:variable name="template">
1075 <xsl:call-template name="gentext.template">
1076 <xsl:with-param name="context" select="'glossary'"/>
1077 <xsl:with-param name="name" select="'seealso'"/>
1078 </xsl:call-template>
1079 </xsl:variable>
1080 <xsl:variable name="title">
1081 <xsl:apply-templates select="glossseealso" mode="glossary.as.blocks"/>
1082 </xsl:variable>
1083 <xsl:call-template name="substitute-markup">
1084 <xsl:with-param name="template" select="$template"/>
1085 <xsl:with-param name="title" select="$title"/>
1086 </xsl:call-template>
1087 </fo:block>
1088 </xsl:if>
1089</xsl:template>
1090
1091<xsl:template match="glossentry/glossdef/para[1]|glossentry/glossdef/simpara[1]"
1092 mode="glossary.as.blocks">
1093 <fo:block>
1094 <xsl:apply-templates/>
1095 </fo:block>
1096</xsl:template>
1097
1098<!-- Handle any other glossdef content normally -->
1099<xsl:template match="*" mode="glossary.as.blocks">
1100 <xsl:apply-templates select="." />
1101</xsl:template>
1102
1103<xsl:template match="glossseealso" mode="glossary.as.blocks">
1104 <xsl:variable name="otherterm" select="@otherterm"/>
1105 <xsl:variable name="targets" select="key('id', $otherterm)"/>
1106 <xsl:variable name="target" select="$targets[1]"/>
1107
1108 <xsl:choose>
1109 <xsl:when test="$target">
1110 <fo:basic-link internal-destination="{$otherterm}"
1111 xsl:use-attribute-sets="xref.properties">
1112 <xsl:apply-templates select="$target" mode="xref-to"/>
1113 </fo:basic-link>
1114 </xsl:when>
1115 <xsl:when test="$otherterm != '' and not($target)">
1116 <xsl:message>
1117 <xsl:text>Warning: glossseealso @otherterm reference not found: </xsl:text>
1118 <xsl:value-of select="$otherterm"/>
1119 </xsl:message>
1120 <xsl:apply-templates mode="glossary.as.blocks"/>
1121 </xsl:when>
1122 <xsl:otherwise>
1123 <xsl:apply-templates mode="glossary.as.blocks"/>
1124 </xsl:otherwise>
1125 </xsl:choose>
1126
1127 <xsl:choose>
1128 <xsl:when test="position() = last()">
1129 <xsl:text>.</xsl:text>
1130 </xsl:when>
1131 <xsl:otherwise>
1132 <xsl:text>, </xsl:text>
1133 </xsl:otherwise>
1134 </xsl:choose>
1135</xsl:template>
1136
1137<!-- ==================================================================== -->
1138
1139</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.