2
<!DOCTYPE xsl:stylesheet [
4
<!ENTITY lowercase "'abcdefghijklmnopqrstuvwxyz'">
5
<!ENTITY uppercase "'ABCDEFGHIJKLMNOPQRSTUVWXYZ'">
7
<!ENTITY primary 'normalize-space(concat(primary/@sortas, primary[not(@sortas)]))'>
8
<!ENTITY secondary 'normalize-space(concat(secondary/@sortas, secondary[not(@sortas)]))'>
9
<!ENTITY tertiary 'normalize-space(concat(tertiary/@sortas, tertiary[not(@sortas)]))'>
12
<!ENTITY scope 'count(ancestor::node()|$scope) = count(ancestor::node())'>
14
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
15
xmlns:fo="http://www.w3.org/1999/XSL/Format"
16
xmlns:rx="http://www.renderx.com/XSL/Extensions"
17
xmlns:axf="http://www.antennahouse.com/names/XSL/Extensions"
20
<!-- ********************************************************************
21
$Id: autoidx.xsl 1341 2006-08-02 16:35:13Z telrod $
22
********************************************************************
24
This file is part of the DocBook XSL Stylesheet distribution.
25
See ../README or http://docbook.sf.net/ for copyright
26
and other information.
28
******************************************************************** -->
30
<!-- ==================================================================== -->
31
<!-- Derived from Jeni Tennison's work in the HTML case -->
33
<xsl:key name="letter"
35
use="translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;)"/>
37
<xsl:key name="primary"
41
<xsl:key name="secondary"
43
use="concat(&primary;, &sep;, &secondary;)"/>
45
<xsl:key name="tertiary"
47
use="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;)"/>
49
<xsl:key name="endofrange"
50
match="indexterm[@class='endofrange']"
53
<xsl:key name="see-also"
54
match="indexterm[seealso]"
55
use="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, seealso)"/>
58
match="indexterm[see]"
59
use="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, see)"/>
61
<xsl:template name="generate-index">
62
<xsl:param name="scope" select="(ancestor::book|/)[last()]"/>
64
<xsl:variable name="terms"
65
select="//indexterm[count(.|key('letter',
66
translate(substring(&primary;, 1, 1),
68
&uppercase;))[&scope;][1]) = 1
69
and not(@class = 'endofrange')]"/>
71
<xsl:variable name="alphabetical"
72
select="$terms[contains(concat(&lowercase;, &uppercase;),
73
substring(&primary;, 1, 1))]"/>
75
<xsl:variable name="others" select="$terms[not(contains(concat(&lowercase;,
77
substring(&primary;, 1, 1)))]"/>
79
<xsl:if test="$others">
80
<xsl:call-template name="indexdiv.title">
81
<xsl:with-param name="titlecontent">
82
<xsl:call-template name="gentext">
83
<xsl:with-param name="key" select="'index symbols'"/>
89
<xsl:apply-templates select="$others[count(.|key('primary',
90
&primary;)[&scope;][1]) = 1]"
91
mode="index-symbol-div">
92
<xsl:with-param name="scope" select="$scope"/>
93
<xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
94
</xsl:apply-templates>
98
<xsl:apply-templates select="$alphabetical[count(.|key('letter',
99
translate(substring(&primary;, 1, 1),
100
&lowercase;,&uppercase;))[&scope;][1]) = 1]"
102
<xsl:with-param name="scope" select="$scope"/>
103
<xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
104
</xsl:apply-templates>
108
<xsl:template match="indexterm" mode="index-div">
109
<xsl:param name="scope" select="."/>
111
<xsl:variable name="key"
112
select="translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;)"/>
114
<xsl:if test="key('letter', $key)[&scope;]
115
[count(.|key('primary', &primary;)[&scope;][1]) = 1]">
117
<xsl:if test="contains(concat(&lowercase;, &uppercase;), $key)">
118
<xsl:call-template name="indexdiv.title">
119
<xsl:with-param name="titlecontent">
120
<xsl:value-of select="translate($key, &lowercase;, &uppercase;)"/>
125
<xsl:apply-templates select="key('letter', $key)[&scope;]
126
[count(.|key('primary', &primary;)[&scope;][1])=1]"
127
mode="index-primary">
128
<xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
129
<xsl:with-param name="scope" select="$scope"/>
130
</xsl:apply-templates>
136
<xsl:template match="indexterm" mode="index-symbol-div">
137
<xsl:param name="scope" select="."/>
139
<xsl:variable name="key"
140
select="translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;)"/>
143
<xsl:apply-templates select="key('letter', $key)[&scope;][count(.|key('primary', &primary;)[&scope;][1]) = 1]"
144
mode="index-primary">
145
<xsl:with-param name="scope" select="$scope"/>
146
<xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
147
</xsl:apply-templates>
151
<xsl:template match="indexterm" mode="index-primary">
152
<xsl:param name="scope" select="."/>
154
<xsl:variable name="key" select="&primary;"/>
155
<xsl:variable name="refs" select="key('primary', $key)[&scope;]"/>
157
<xsl:if test="$axf.extensions != 0">
158
<xsl:attribute name="axf:suppress-duplicate-page-number">true</xsl:attribute>
160
<xsl:value-of select="primary"/>
163
<xsl:when test="$xep.extensions != 0">
164
<xsl:if test="$refs[not(see) and not(seealso) and not(secondary)]">
165
<xsl:text>, </xsl:text>
166
<xsl:variable name="primary" select="primary"/>
167
<xsl:variable name="primary.significant" select="concat(primary, $significant.flag)"/>
169
<xsl:if test="$refs[@significance='preferred'][not(see) and not(seealso) and not(secondary)]">
170
<rx:index-item xsl:use-attribute-sets="index.preferred.page.properties xep.index.item.properties"
171
ref-key="{$primary.significant}"/>
173
<xsl:if test="$refs[not(@significance) or @significance!='preferred'][not(see) and not(seealso) and not(secondary)]">
174
<rx:index-item xsl:use-attribute-sets="xep.index.item.properties"
175
ref-key="{$primary}"/>
181
<xsl:variable name="page-number-citations">
182
<xsl:for-each select="$refs[not(see) and not(seealso)
183
and not(secondary)]">
184
<xsl:apply-templates select="." mode="reference">
185
<xsl:with-param name="scope" select="$scope"/>
186
</xsl:apply-templates>
191
<xsl:when test="$passivetex.extensions != '0'">
192
<fotex:sort xmlns:fotex="http://www.tug.org/fotex">
193
<xsl:copy-of select="$page-number-citations"/>
197
<xsl:copy-of select="$page-number-citations"/>
203
<xsl:if test="$refs[not(secondary)]/*[self::see]">
204
<xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &sep;, &sep;, see))[&scope;][1])]"
206
<xsl:with-param name="scope" select="$scope"/>
207
<xsl:sort select="translate(see, &lowercase;, &uppercase;)"/>
208
</xsl:apply-templates>
213
<xsl:if test="$refs/secondary or $refs[not(secondary)]/*[self::seealso]">
214
<fo:block start-indent="1pc">
215
<xsl:apply-templates select="$refs[generate-id() = generate-id(key('see-also', concat(&primary;, &sep;, &sep;, &sep;, seealso))[&scope;][1])]"
216
mode="index-seealso">
217
<xsl:with-param name="scope" select="$scope"/>
218
<xsl:sort select="translate(seealso, &lowercase;, &uppercase;)"/>
219
</xsl:apply-templates>
220
<xsl:apply-templates select="$refs[secondary and count(.|key('secondary', concat($key, &sep;, &secondary;))[&scope;][1]) = 1]"
221
mode="index-secondary">
222
<xsl:with-param name="scope" select="$scope"/>
223
<xsl:sort select="translate(&secondary;, &lowercase;, &uppercase;)"/>
224
</xsl:apply-templates>
229
<xsl:template match="indexterm" mode="index-secondary">
230
<xsl:param name="scope" select="."/>
232
<xsl:variable name="key" select="concat(&primary;, &sep;, &secondary;)"/>
233
<xsl:variable name="refs" select="key('secondary', $key)[&scope;]"/>
235
<xsl:if test="$axf.extensions != 0">
236
<xsl:attribute name="axf:suppress-duplicate-page-number">true</xsl:attribute>
238
<xsl:value-of select="secondary"/>
241
<xsl:when test="$xep.extensions != 0">
242
<xsl:if test="$refs[not(see) and not(seealso) and not(tertiary)]">
243
<xsl:text>, </xsl:text>
244
<xsl:variable name="primary" select="primary"/>
245
<xsl:variable name="secondary" select="secondary"/>
246
<xsl:variable name="primary.significant" select="concat(primary, $significant.flag)"/>
248
<xsl:if test="$refs[@significance='preferred'][not(see) and not(seealso) and not(tertiary)]">
249
<rx:index-item xsl:use-attribute-sets="index.preferred.page.properties xep.index.item.properties">
250
<xsl:attribute name="ref-key">
251
<xsl:value-of select="$primary.significant"/>
252
<xsl:text>, </xsl:text>
253
<xsl:value-of select="$secondary"/>
257
<xsl:if test="$refs[not(@significance) or @significance!='preferred'][not(see) and not(seealso) and not(tertiary)]">
258
<rx:index-item xsl:use-attribute-sets="xep.index.item.properties">
259
<xsl:attribute name="ref-key">
260
<xsl:value-of select="$primary"/>
261
<xsl:text>, </xsl:text>
262
<xsl:value-of select="$secondary"/>
270
<xsl:variable name="page-number-citations">
271
<xsl:for-each select="$refs[not(see) and not(seealso)
273
<xsl:apply-templates select="." mode="reference">
274
<xsl:with-param name="scope" select="$scope"/>
275
</xsl:apply-templates>
280
<xsl:when test="$passivetex.extensions != '0'">
281
<fotex:sort xmlns:fotex="http://www.tug.org/fotex">
282
<xsl:copy-of select="$page-number-citations"/>
286
<xsl:copy-of select="$page-number-citations"/>
292
<xsl:if test="$refs[not(tertiary)]/*[self::see]">
293
<xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &secondary;, &sep;, &sep;, see))[&scope;][1])]"
295
<xsl:with-param name="scope" select="$scope"/>
296
<xsl:sort select="translate(see, &lowercase;, &uppercase;)"/>
297
</xsl:apply-templates>
302
<xsl:if test="$refs/tertiary or $refs[not(tertiary)]/*[self::seealso]">
303
<fo:block start-indent="2pc">
304
<xsl:apply-templates select="$refs[generate-id() = generate-id(key('see-also', concat(&primary;, &sep;, &secondary;, &sep;, &sep;, seealso))[&scope;][1])]"
305
mode="index-seealso">
306
<xsl:with-param name="scope" select="$scope"/>
307
<xsl:sort select="translate(seealso, &lowercase;, &uppercase;)"/>
308
</xsl:apply-templates>
309
<xsl:apply-templates select="$refs[tertiary and count(.|key('tertiary', concat($key, &sep;, &tertiary;))[&scope;][1]) = 1]"
310
mode="index-tertiary">
311
<xsl:with-param name="scope" select="$scope"/>
312
<xsl:sort select="translate(&tertiary;, &lowercase;, &uppercase;)"/>
313
</xsl:apply-templates>
318
<xsl:template match="indexterm" mode="index-tertiary">
319
<xsl:param name="scope" select="."/>
320
<xsl:variable name="key" select="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;)"/>
321
<xsl:variable name="refs" select="key('tertiary', $key)[&scope;]"/>
323
<xsl:if test="$axf.extensions != 0">
324
<xsl:attribute name="axf:suppress-duplicate-page-number">true</xsl:attribute>
326
<xsl:value-of select="tertiary"/>
329
<xsl:when test="$xep.extensions != 0">
330
<xsl:if test="$refs[not(see) and not(seealso)]">
331
<xsl:text>, </xsl:text>
332
<xsl:variable name="primary" select="primary"/>
333
<xsl:variable name="secondary" select="secondary"/>
334
<xsl:variable name="tertiary" select="tertiary"/>
335
<xsl:variable name="primary.significant" select="concat(primary, $significant.flag)"/>
337
<xsl:if test="$refs[@significance='preferred'][not(see) and not(seealso)]">
338
<rx:index-item xsl:use-attribute-sets="index.preferred.page.properties xep.index.item.properties">
339
<xsl:attribute name="ref-key">
340
<xsl:value-of select="$primary.significant"/>
341
<xsl:text>, </xsl:text>
342
<xsl:value-of select="$secondary"/>
343
<xsl:text>, </xsl:text>
344
<xsl:value-of select="$tertiary"/>
348
<xsl:if test="$refs[not(@significance) or @significance!='preferred'][not(see) and not(seealso)]">
349
<rx:index-item xsl:use-attribute-sets="xep.index.item.properties">
350
<xsl:attribute name="ref-key">
351
<xsl:value-of select="$primary"/>
352
<xsl:text>, </xsl:text>
353
<xsl:value-of select="$secondary"/>
354
<xsl:text>, </xsl:text>
355
<xsl:value-of select="$tertiary"/>
363
<xsl:variable name="page-number-citations">
364
<xsl:for-each select="$refs[not(see) and not(seealso)]">
365
<xsl:apply-templates select="." mode="reference">
366
<xsl:with-param name="scope" select="$scope"/>
367
</xsl:apply-templates>
372
<xsl:when test="$passivetex.extensions != '0'">
373
<fotex:sort xmlns:fotex="http://www.tug.org/fotex">
374
<xsl:copy-of select="$page-number-citations"/>
378
<xsl:copy-of select="$page-number-citations"/>
384
<xsl:if test="$refs/see">
385
<xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, see))[&scope;][1])]"
387
<xsl:with-param name="scope" select="$scope"/>
388
<xsl:sort select="translate(see, &lowercase;, &uppercase;)"/>
389
</xsl:apply-templates>
394
<xsl:if test="$refs/seealso">
396
<xsl:apply-templates select="$refs[generate-id() = generate-id(key('see-also', concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, seealso))[&scope;][1])]"
397
mode="index-seealso">
398
<xsl:with-param name="scope" select="$scope"/>
399
<xsl:sort select="translate(seealso, &lowercase;, &uppercase;)"/>
400
</xsl:apply-templates>
405
<xsl:template match="indexterm" mode="reference">
406
<xsl:param name="scope" select="."/>
407
<xsl:param name="separator" select="', '"/>
409
<xsl:if test="$passivetex.extensions = '0'">
410
<xsl:value-of select="$separator"/>
414
<xsl:when test="@zone and string(@zone)">
415
<xsl:call-template name="reference">
416
<xsl:with-param name="zones" select="normalize-space(@zone)"/>
417
<xsl:with-param name="scope" select="$scope"/>
421
<xsl:variable name="id">
422
<xsl:call-template name="object.id"/>
425
<fo:basic-link internal-destination="{$id}">
426
<fo:page-number-citation ref-id="{$id}"/>
429
<xsl:if test="key('endofrange', @id)[&scope;]">
430
<xsl:apply-templates select="key('endofrange', @id)[&scope;][last()]"
432
<xsl:with-param name="scope" select="$scope"/>
433
<xsl:with-param name="separator" select="'-'"/>
434
</xsl:apply-templates>
440
<xsl:template name="reference">
441
<xsl:param name="scope" select="."/>
442
<xsl:param name="zones"/>
445
<xsl:when test="contains($zones, ' ')">
446
<xsl:variable name="zone" select="substring-before($zones, ' ')"/>
447
<xsl:variable name="target" select="key('id', $zone)[&scope;]"/>
449
<xsl:variable name="id">
450
<xsl:call-template name="object.id">
451
<xsl:with-param name="object" select="$target[1]"/>
455
<fo:basic-link internal-destination="{$id}">
456
<fo:page-number-citation ref-id="{$id}"/>
459
<xsl:if test="$passivetex.extensions = '0'">
460
<xsl:text>, </xsl:text>
462
<xsl:call-template name="reference">
463
<xsl:with-param name="zones" select="substring-after($zones, ' ')"/>
464
<xsl:with-param name="scope" select="$scope"/>
468
<xsl:variable name="zone" select="$zones"/>
469
<xsl:variable name="target" select="key('id', $zone)[&scope;]"/>
471
<xsl:variable name="id">
472
<xsl:call-template name="object.id">
473
<xsl:with-param name="object" select="$target[1]"/>
477
<fo:basic-link internal-destination="{$id}">
478
<fo:page-number-citation ref-id="{$id}"/>
484
<xsl:template match="indexterm" mode="index-see">
485
<xsl:param name="scope" select="."/>
488
<xsl:text> (</xsl:text>
489
<xsl:call-template name="gentext">
490
<xsl:with-param name="key" select="'see'"/>
492
<xsl:text> </xsl:text>
493
<xsl:value-of select="see"/>
494
<xsl:text>)</xsl:text>
498
<xsl:template match="indexterm" mode="index-seealso">
499
<xsl:param name="scope" select="."/>
502
<xsl:text>(</xsl:text>
503
<xsl:call-template name="gentext">
504
<xsl:with-param name="key" select="'seealso'"/>
506
<xsl:text> </xsl:text>
507
<xsl:value-of select="seealso"/>
508
<xsl:text>)</xsl:text>
512
<!-- ====================================================================== -->
514
<xsl:template name="generate-index-markup">
515
<xsl:param name="scope" select="(ancestor::book|/)[last()]"/>
517
<xsl:variable name="terms" select="$scope//indexterm[count(.|key('letter',
518
translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;))[&scope;][1]) = 1]"/>
519
<xsl:variable name="alphabetical"
520
select="$terms[contains(concat(&lowercase;, &uppercase;),
521
substring(&primary;, 1, 1))]"/>
522
<xsl:variable name="others" select="$terms[not(contains(concat(&lowercase;,
524
substring(&primary;, 1, 1)))]"/>
526
<xsl:text><index> </xsl:text>
527
<xsl:if test="$others">
528
<xsl:text> <indexdiv> </xsl:text>
529
<xsl:text><title></xsl:text>
530
<xsl:call-template name="gentext">
531
<xsl:with-param name="key" select="'index symbols'"/>
533
<xsl:text></title> </xsl:text>
534
<xsl:apply-templates select="$others[count(.|key('primary',
535
&primary;)[&scope;][1]) = 1]"
536
mode="index-symbol-div-markup">
537
<xsl:with-param name="scope" select="$scope"/>
538
<xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
539
</xsl:apply-templates>
540
<xsl:text></indexdiv> </xsl:text>
543
<xsl:apply-templates select="$alphabetical[count(.|key('letter',
544
translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;))[&scope;][1]) = 1]"
545
mode="index-div-markup">
546
<xsl:with-param name="scope" select="$scope"/>
547
<xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
548
</xsl:apply-templates>
549
<xsl:text></index> </xsl:text>
552
<xsl:template match="*" mode="index-markup">
553
<xsl:param name="scope" select="."/>
555
<xsl:text><</xsl:text>
556
<xsl:value-of select="name(.)"/>
557
<xsl:text>> </xsl:text>
558
<xsl:apply-templates mode="index-markup">
559
<xsl:with-param name="scope" select="$scope"/>
560
</xsl:apply-templates>
563
<xsl:template match="indexterm" mode="index-div-markup">
564
<xsl:param name="scope" select="."/>
565
<xsl:variable name="key" select="translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;)"/>
566
<xsl:text> <indexdiv> </xsl:text>
567
<xsl:text><title></xsl:text>
568
<xsl:value-of select="translate($key, &lowercase;, &uppercase;)"/>
569
<xsl:text></title> </xsl:text>
571
<xsl:apply-templates select="key('letter', $key)[&scope;][count(.|key('primary', &primary;)[&scope;][1]) = 1]"
572
mode="index-primary-markup">
573
<xsl:with-param name="scope" select="$scope"/>
574
<xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
575
</xsl:apply-templates>
576
<xsl:text></indexdiv> </xsl:text>
579
<xsl:template match="indexterm" mode="index-symbol-div-markup">
580
<xsl:param name="scope" select="."/>
581
<xsl:variable name="key" select="translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;)"/>
583
<xsl:apply-templates select="key('letter', $key)[&scope;][count(.|key('primary', &primary;)[&scope;][1]) = 1]"
584
mode="index-primary-markup">
585
<xsl:with-param name="scope" select="$scope"/>
586
<xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
587
</xsl:apply-templates>
590
<xsl:template match="indexterm" mode="index-primary-markup">
591
<xsl:param name="scope" select="."/>
592
<xsl:variable name="key" select="&primary;"/>
593
<xsl:variable name="refs" select="key('primary', $key)[&scope;]"/>
594
<xsl:variable name="pages" select="$refs[not(see) and not(seealso)]"/>
596
<xsl:text> <indexentry> </xsl:text>
597
<xsl:text><primaryie></xsl:text>
598
<xsl:text><phrase></xsl:text>
599
<xsl:call-template name="escape-text">
600
<xsl:with-param name="text" select="string(primary)"/>
602
<xsl:text></phrase></xsl:text>
603
<xsl:if test="$pages">,</xsl:if>
604
<xsl:text> </xsl:text>
606
<xsl:for-each select="$pages">
607
<xsl:apply-templates select="." mode="reference-markup">
608
<xsl:with-param name="scope" select="$scope"/>
609
</xsl:apply-templates>
612
<xsl:text></primaryie> </xsl:text>
614
<xsl:if test="$refs/secondary or $refs[not(secondary)]/*[self::see or self::seealso]">
615
<xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &sep;, &sep;, see))[&scope;][1])]"
616
mode="index-see-markup">
617
<xsl:with-param name="scope" select="$scope"/>
618
<xsl:sort select="translate(see, &lowercase;, &uppercase;)"/>
619
</xsl:apply-templates>
621
<xsl:apply-templates select="$refs[generate-id() = generate-id(key('see-also', concat(&primary;, &sep;, &sep;, &sep;, seealso))[&scope;][1])]"
622
mode="index-seealso-markup">
623
<xsl:with-param name="scope" select="$scope"/>
624
<xsl:sort select="translate(seealso, &lowercase;, &uppercase;)"/>
625
</xsl:apply-templates>
627
<xsl:apply-templates select="$refs[secondary and count(.|key('secondary', concat($key, &sep;, &secondary;))[&scope;][1]) = 1]"
628
mode="index-secondary-markup">
629
<xsl:with-param name="scope" select="$scope"/>
630
<xsl:sort select="translate(&secondary;, &lowercase;, &uppercase;)"/>
631
</xsl:apply-templates>
633
<xsl:text></indexentry> </xsl:text>
636
<xsl:template match="indexterm" mode="index-secondary-markup">
637
<xsl:param name="scope" select="."/>
638
<xsl:variable name="key" select="concat(&primary;, &sep;, &secondary;)"/>
639
<xsl:variable name="refs" select="key('secondary', $key)[&scope;]"/>
640
<xsl:variable name="pages" select="$refs[not(see) and not(seealso)]"/>
642
<xsl:text><secondaryie></xsl:text>
643
<xsl:text><phrase></xsl:text>
644
<xsl:call-template name="escape-text">
645
<xsl:with-param name="text" select="string(secondary)"/>
647
<xsl:text></phrase></xsl:text>
648
<xsl:if test="$pages">,</xsl:if>
649
<xsl:text> </xsl:text>
651
<xsl:for-each select="$pages">
652
<xsl:apply-templates select="." mode="reference-markup">
653
<xsl:with-param name="scope" select="$scope"/>
654
</xsl:apply-templates>
657
<xsl:text></secondaryie> </xsl:text>
659
<xsl:if test="$refs/tertiary or $refs[not(tertiary)]/*[self::see or self::seealso]">
660
<xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &secondary;, &sep;, &sep;, see))[&scope;][1])]"
661
mode="index-see-markup">
662
<xsl:with-param name="scope" select="$scope"/>
663
<xsl:sort select="translate(see, &lowercase;, &uppercase;)"/>
664
</xsl:apply-templates>
665
<xsl:apply-templates select="$refs[generate-id() = generate-id(key('see-also', concat(&primary;, &sep;, &secondary;, &sep;, &sep;, seealso))[&scope;][1])]"
666
mode="index-seealso-markup">
667
<xsl:with-param name="scope" select="$scope"/>
668
<xsl:sort select="translate(seealso, &lowercase;, &uppercase;)"/>
669
</xsl:apply-templates>
670
<xsl:apply-templates select="$refs[tertiary and count(.|key('tertiary', concat($key, &sep;, &tertiary;))[&scope;][1]) = 1]"
671
mode="index-tertiary-markup">
672
<xsl:with-param name="scope" select="$scope"/>
673
<xsl:sort select="translate(&tertiary;, &lowercase;, &uppercase;)"/>
674
</xsl:apply-templates>
678
<xsl:template match="indexterm" mode="index-tertiary-markup">
679
<xsl:param name="scope" select="."/>
680
<xsl:variable name="key" select="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;)"/>
681
<xsl:variable name="refs" select="key('tertiary', $key)[&scope;]"/>
682
<xsl:variable name="pages" select="$refs[not(see) and not(seealso)]"/>
684
<xsl:text><tertiaryie></xsl:text>
685
<xsl:text><phrase></xsl:text>
686
<xsl:call-template name="escape-text">
687
<xsl:with-param name="text" select="string(tertiary)"/>
689
<xsl:text></phrase></xsl:text>
690
<xsl:if test="$pages">,</xsl:if>
691
<xsl:text> </xsl:text>
693
<xsl:for-each select="$pages">
694
<xsl:apply-templates select="." mode="reference-markup">
695
<xsl:with-param name="scope" select="$scope"/>
696
</xsl:apply-templates>
699
<xsl:text></tertiaryie> </xsl:text>
701
<xsl:variable name="see" select="$refs/see | $refs/seealso"/>
703
<xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, see))[&scope;][1])]"
704
mode="index-see-markup">
705
<xsl:with-param name="scope" select="$scope"/>
706
<xsl:sort select="translate(see, &lowercase;, &uppercase;)"/>
707
</xsl:apply-templates>
708
<xsl:apply-templates select="$refs[generate-id() = generate-id(key('see-also', concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, seealso))[&scope;][1])]"
709
mode="index-seealso-markup">
710
<xsl:with-param name="scope" select="$scope"/>
711
<xsl:sort select="translate(seealso, &lowercase;, &uppercase;)"/>
712
</xsl:apply-templates>
716
<xsl:template match="indexterm" mode="reference-markup">
717
<xsl:param name="scope" select="."/>
719
<xsl:when test="@zone and string(@zone)">
720
<xsl:call-template name="reference-markup">
721
<xsl:with-param name="zones" select="normalize-space(@zone)"/>
722
<xsl:with-param name="scope" select="$scope"/>
726
<xsl:variable name="id">
727
<xsl:call-template name="object.id"/>
732
<xsl:when test="@startref and @class='endofrange'">
733
<xsl:text><phrase role="pageno"></xsl:text>
734
<xsl:text><link linkend="</xsl:text>
735
<xsl:value-of select="@startref"/>
736
<xsl:text>"></xsl:text>
737
<fo:basic-link internal-destination="{@startref}">
738
<fo:page-number-citation ref-id="{@startref}"/>
739
<xsl:text>-</xsl:text>
740
<fo:page-number-citation ref-id="{$id}"/>
742
<xsl:text></link></xsl:text>
743
<xsl:text></phrase> </xsl:text>
746
<xsl:text><phrase role="pageno"></xsl:text>
748
<xsl:text><link linkend="</xsl:text>
749
<xsl:value-of select="$id"/>
750
<xsl:text>"></xsl:text>
752
<fo:basic-link internal-destination="{$id}">
753
<fo:page-number-citation ref-id="{$id}"/>
756
<xsl:text></link></xsl:text>
758
<xsl:text></phrase> </xsl:text>
765
<xsl:template name="reference-markup">
766
<xsl:param name="scope" select="."/>
767
<xsl:param name="zones"/>
769
<xsl:when test="contains($zones, ' ')">
770
<xsl:variable name="zone" select="substring-before($zones, ' ')"/>
771
<xsl:variable name="target" select="key('id', $zone)[&scope;]"/>
773
<xsl:variable name="id">
774
<xsl:call-template name="object.id">
775
<xsl:with-param name="object" select="$target[1]"/>
779
<xsl:text><phrase fole="pageno"></xsl:text>
780
<xsl:if test="$target[1]/@id">
781
<xsl:text><link linkend="</xsl:text>
782
<xsl:value-of select="$id"/>
783
<xsl:text>"></xsl:text>
785
<fo:basic-link internal-destination="{$id}">
786
<fo:page-number-citation ref-id="{$id}"/>
788
<xsl:if test="$target[1]/@id">
789
<xsl:text></link></xsl:text>
791
<xsl:text></phrase> </xsl:text>
793
<xsl:call-template name="reference">
794
<xsl:with-param name="zones" select="substring-after($zones, ' ')"/>
795
<xsl:with-param name="scope" select="$scope"/>
799
<xsl:variable name="zone" select="$zones"/>
800
<xsl:variable name="target" select="key('id', $zone)[&scope;]"/>
802
<xsl:variable name="id">
803
<xsl:call-template name="object.id">
804
<xsl:with-param name="object" select="$target[1]"/>
808
<xsl:text><phrase role="pageno"></xsl:text>
809
<xsl:if test="$target[1]/@id">
810
<xsl:text><link linkend="</xsl:text>
811
<xsl:value-of select="$id"/>
812
<xsl:text>"></xsl:text>
814
<fo:basic-link internal-destination="{$id}">
815
<fo:page-number-citation ref-id="{$id}"/>
817
<xsl:if test="$target[1]/@id">
818
<xsl:text></link></xsl:text>
820
<xsl:text></phrase> </xsl:text>
825
<xsl:template match="indexterm" mode="index-see-markup">
826
<xsl:param name="scope" select="."/>
828
<xsl:text><seeie></xsl:text>
829
<xsl:text><phrase></xsl:text>
830
<xsl:call-template name="escape-text">
831
<xsl:with-param name="text" select="string(see)"/>
833
<xsl:text></phrase></xsl:text>
834
<xsl:text></seeie> </xsl:text>
838
<xsl:template match="indexterm" mode="index-seealso-markup">
839
<xsl:param name="scope" select="."/>
841
<xsl:text><seealsoie></xsl:text>
842
<xsl:text><phrase></xsl:text>
843
<xsl:call-template name="escape-text">
844
<xsl:with-param name="text" select="string(seealso)"/>
846
<xsl:text></phrase></xsl:text>
847
<xsl:text></seealsoie> </xsl:text>
851
<xsl:template name="escape-text">
852
<xsl:param name="text" select="''"/>
854
<xsl:variable name="ltpos" select="substring-before($text, '<')"/>
855
<xsl:variable name="amppos" select="substring-before($text, '&')"/>
858
<xsl:when test="contains($text,'<') and contains($text, '&')
859
and string-length($ltpos) < string-length($amppos)">
860
<xsl:value-of select="$ltpos"/>
861
<xsl:text>&lt;</xsl:text>
862
<xsl:call-template name="escape-text">
863
<xsl:with-param name="text" select="substring-after($text, '<')"/>
867
<xsl:when test="contains($text,'<') and contains($text, '&')
868
and string-length($amppos) < string-length($ltpos)">
869
<xsl:value-of select="$amppos"/>
870
<xsl:text>&amp;</xsl:text>
871
<xsl:call-template name="escape-text">
872
<xsl:with-param name="text" select="substring-after($text, '&')"/>
876
<xsl:when test="contains($text, '<')">
877
<xsl:value-of select="$ltpos"/>
878
<xsl:text>&lt;</xsl:text>
879
<xsl:call-template name="escape-text">
880
<xsl:with-param name="text" select="substring-after($text, '<')"/>
884
<xsl:when test="contains($text, '&')">
885
<xsl:value-of select="$amppos"/>
886
<xsl:text>&amp;</xsl:text>
887
<xsl:call-template name="escape-text">
888
<xsl:with-param name="text" select="substring-after($text, '&')"/>
893
<xsl:value-of select="$text"/>