~todd-deshane/openstack-manuals/working

« back to all changes in this revision

Viewing changes to doc/build/docbook-xsl-1.76.1/fo/glossary.xsl

  • Committer: Anne Gentle
  • Date: 2011-04-04 17:54:52 UTC
  • Revision ID: anne@openstack.org-20110404175452-gtth3hfrniqhpp5o
Switching from Ant builds to Maven, still working out kinks but should be functional

Show diffs side-by-side

added added

removed removed

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