source: BOOK/stylesheets/lfs-xsl/docbook-xsl-snapshot/fo/autoidx.xsl@ 902b794

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

Added LFS XSL Stylesheets.

  • Property mode set to 100644
File size: 52.1 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 xmlns:rx="http://www.renderx.com/XSL/Extensions"
9 xmlns:axf="http://www.antennahouse.com/names/XSL/Extensions"
10 xmlns:exslt="http://exslt.org/common"
11 extension-element-prefixes="exslt"
12 exclude-result-prefixes="exslt"
13 version="1.0">
14
15<!-- ********************************************************************
16 $Id$
17 ********************************************************************
18
19 This file is part of the DocBook XSL Stylesheet distribution.
20 See ../README or http://docbook.sf.net/ for copyright
21 copyright and other information.
22
23 ******************************************************************** -->
24
25<!-- ==================================================================== -->
26<!-- The "basic" method derived from Jeni Tennison's work. -->
27<!-- The "kosek" method contributed by Jirka Kosek. -->
28<!-- The "kimber" method contributed by Eliot Kimber of Innodata Isogen. -->
29
30<!-- Importing module for kimber or kosek method overrides one of these -->
31<xsl:param name="kimber.imported" select="0"/>
32<xsl:param name="kosek.imported" select="0"/>
33
34<!-- These keys used primary in all methods -->
35<xsl:key name="letter"
36 match="indexterm"
37 use="translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;)"/>
38
39<xsl:key name="primary"
40 match="indexterm"
41 use="&primary;"/>
42
43<xsl:key name="secondary"
44 match="indexterm"
45 use="concat(&primary;, &sep;, &secondary;)"/>
46
47<xsl:key name="tertiary"
48 match="indexterm"
49 use="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;)"/>
50
51<xsl:key name="endofrange"
52 match="indexterm[@class='endofrange']"
53 use="@startref"/>
54
55<xsl:key name="see-also"
56 match="indexterm[seealso]"
57 use="concat(&primary;, &sep;,
58 &secondary;, &sep;,
59 &tertiary;, &sep;, seealso)"/>
60
61<xsl:key name="see"
62 match="indexterm[see]"
63 use="concat(&primary;, &sep;,
64 &secondary;, &sep;,
65 &tertiary;, &sep;, see)"/>
66
67
68<xsl:template name="generate-index">
69 <xsl:param name="scope" select="(ancestor::book|/)[last()]"/>
70
71 <xsl:choose>
72 <xsl:when test="$index.method = 'kosek'">
73 <xsl:call-template name="generate-kosek-index">
74 <xsl:with-param name="scope" select="$scope"/>
75 </xsl:call-template>
76 </xsl:when>
77 <xsl:when test="$index.method = 'kimber'">
78 <xsl:call-template name="generate-kimber-index">
79 <xsl:with-param name="scope" select="$scope"/>
80 </xsl:call-template>
81 </xsl:when>
82
83 <xsl:otherwise>
84 <xsl:call-template name="generate-basic-index">
85 <xsl:with-param name="scope" select="$scope"/>
86 </xsl:call-template>
87 </xsl:otherwise>
88 </xsl:choose>
89</xsl:template>
90
91<xsl:template name="generate-basic-index">
92 <xsl:param name="scope" select="NOTANODE"/>
93
94 <xsl:variable name="role">
95 <xsl:if test="$index.on.role != 0">
96 <xsl:value-of select="@role"/>
97 </xsl:if>
98 </xsl:variable>
99
100 <xsl:variable name="type">
101 <xsl:if test="$index.on.type != 0">
102 <xsl:value-of select="@type"/>
103 </xsl:if>
104 </xsl:variable>
105
106 <xsl:variable name="terms"
107 select="//indexterm
108 [count(.|key('letter',
109 translate(substring(&primary;, 1, 1),
110 &lowercase;,
111 &uppercase;))
112 [&scope;][1]) = 1
113 and not(@class = 'endofrange')]"/>
114
115 <xsl:variable name="alphabetical"
116 select="$terms[contains(concat(&lowercase;, &uppercase;),
117 substring(&primary;, 1, 1))]"/>
118
119 <xsl:variable name="others" select="$terms[not(contains(
120 concat(&lowercase;,
121 &uppercase;),
122 substring(&primary;, 1, 1)))]"/>
123 <fo:block>
124 <xsl:if test="$others">
125 <xsl:call-template name="indexdiv.title">
126 <xsl:with-param name="titlecontent">
127 <xsl:call-template name="gentext">
128 <xsl:with-param name="key" select="'index symbols'"/>
129 </xsl:call-template>
130 </xsl:with-param>
131 </xsl:call-template>
132
133 <fo:block>
134 <xsl:apply-templates select="$others[count(.|key('primary',
135 &primary;)[&scope;][1]) = 1]"
136 mode="index-symbol-div">
137 <xsl:with-param name="scope" select="$scope"/>
138 <xsl:with-param name="role" select="$role"/>
139 <xsl:with-param name="type" select="$type"/>
140 <xsl:sort select="translate(&primary;, &lowercase;,
141 &uppercase;)"/>
142 </xsl:apply-templates>
143 </fo:block>
144 </xsl:if>
145
146 <xsl:apply-templates select="$alphabetical[count(.|key('letter',
147 translate(substring(&primary;, 1, 1),
148 &lowercase;,&uppercase;))
149 [&scope;][1]) = 1]"
150 mode="index-div-basic">
151 <xsl:with-param name="scope" select="$scope"/>
152 <xsl:with-param name="role" select="$role"/>
153 <xsl:with-param name="type" select="$type"/>
154 <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
155 </xsl:apply-templates>
156 </fo:block>
157</xsl:template>
158
159<!-- This template not used if fo/autoidx-kosek.xsl is imported -->
160<xsl:template name="generate-kosek-index">
161 <xsl:param name="scope" select="NOTANODE"/>
162
163 <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
164 <xsl:if test="contains($vendor, 'libxslt')">
165 <xsl:message terminate="yes">
166 <xsl:text>ERROR: the 'kosek' index method does not </xsl:text>
167 <xsl:text>work with the xsltproc XSLT processor.</xsl:text>
168 </xsl:message>
169 </xsl:if>
170
171
172 <xsl:if test="not(function-available('exslt:node-set') or
173 function-available('exslt:nodeSet'))">
174 <xsl:message terminate="yes">
175 <xsl:text>ERROR: the 'kosek' index method requires the </xsl:text>
176 <xsl:text>exslt:node-set() function. Use a processor that </xsl:text>
177 <xsl:text>has it, or use a different index method.</xsl:text>
178 </xsl:message>
179 </xsl:if>
180
181 <xsl:if test="$kosek.imported = 0">
182 <xsl:message terminate="yes">
183 <xsl:text>ERROR: the 'kosek' index method requires the&#xA;</xsl:text>
184 <xsl:text>kosek index extensions be imported:&#xA;</xsl:text>
185 <xsl:text> xsl:import href="fo/autoidx-kosek.xsl"</xsl:text>
186 </xsl:message>
187 </xsl:if>
188
189</xsl:template>
190
191
192<!-- This template not used if fo/autoidx-kimber.xsl is imported -->
193<xsl:template name="generate-kimber-index">
194 <xsl:param name="scope" select="NOTANODE"/>
195
196 <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
197 <xsl:if test="not(contains($vendor, 'SAXON '))">
198 <xsl:message terminate="yes">
199 <xsl:text>ERROR: the 'kimber' index method requires the </xsl:text>
200 <xsl:text>Saxon version 6 or 8 XSLT processor.</xsl:text>
201 </xsl:message>
202 </xsl:if>
203
204 <xsl:if test="$kimber.imported = 0">
205 <xsl:message terminate="yes">
206 <xsl:text>ERROR: the 'kimber' index method requires the&#xA;</xsl:text>
207 <xsl:text>kimber index extensions be imported:&#xA;</xsl:text>
208 <xsl:text> xsl:import href="fo/autoidx-kimber.xsl"</xsl:text>
209 </xsl:message>
210 </xsl:if>
211
212</xsl:template>
213
214<xsl:template match="indexterm" mode="index-div-basic">
215 <xsl:param name="scope" select="."/>
216 <xsl:param name="role" select="''"/>
217 <xsl:param name="type" select="''"/>
218
219 <xsl:variable name="key"
220 select="translate(substring(&primary;, 1, 1),
221 &lowercase;,&uppercase;)"/>
222
223 <xsl:if test="key('letter', $key)[&scope;]
224 [count(.|key('primary', &primary;)[&scope;][1]) = 1]">
225 <fo:block>
226 <xsl:if test="contains(concat(&lowercase;, &uppercase;), $key)">
227 <xsl:call-template name="indexdiv.title">
228 <xsl:with-param name="titlecontent">
229 <xsl:value-of select="translate($key, &lowercase;, &uppercase;)"/>
230 </xsl:with-param>
231 </xsl:call-template>
232 </xsl:if>
233 <fo:block xsl:use-attribute-sets="index.entry.properties">
234 <xsl:apply-templates select="key('letter', $key)[&scope;]
235 [count(.|key('primary', &primary;)
236 [&scope;][1])=1]"
237 mode="index-primary">
238 <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
239 <xsl:with-param name="scope" select="$scope"/>
240 <xsl:with-param name="role" select="$role"/>
241 <xsl:with-param name="type" select="$type"/>
242 </xsl:apply-templates>
243 </fo:block>
244 </fo:block>
245 </xsl:if>
246</xsl:template>
247
248<xsl:template match="indexterm" mode="index-symbol-div">
249 <xsl:param name="scope" select="."/>
250 <xsl:param name="role" select="''"/>
251 <xsl:param name="type" select="''"/>
252
253 <xsl:variable name="key"
254 select="translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;)"/>
255
256 <fo:block xsl:use-attribute-sets="index.entry.properties">
257 <xsl:apply-templates select="key('letter', $key)[&scope;][count(.|key('primary', &primary;)[&scope;][1]) = 1]"
258 mode="index-primary">
259 <xsl:with-param name="scope" select="$scope"/>
260 <xsl:with-param name="role" select="$role"/>
261 <xsl:with-param name="type" select="$type"/>
262 <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
263 </xsl:apply-templates>
264 </fo:block>
265</xsl:template>
266
267<xsl:template match="indexterm" mode="index-primary">
268 <xsl:param name="scope" select="."/>
269 <xsl:param name="role" select="''"/>
270 <xsl:param name="type" select="''"/>
271
272 <xsl:variable name="key" select="&primary;"/>
273 <xsl:variable name="refs" select="key('primary', $key)[&scope;]"/>
274
275 <xsl:variable name="term.separator">
276 <xsl:call-template name="index.separator">
277 <xsl:with-param name="key" select="'index.term.separator'"/>
278 </xsl:call-template>
279 </xsl:variable>
280
281 <xsl:variable name="range.separator">
282 <xsl:call-template name="index.separator">
283 <xsl:with-param name="key" select="'index.range.separator'"/>
284 </xsl:call-template>
285 </xsl:variable>
286
287 <xsl:variable name="number.separator">
288 <xsl:call-template name="index.separator">
289 <xsl:with-param name="key" select="'index.number.separator'"/>
290 </xsl:call-template>
291 </xsl:variable>
292
293 <fo:block>
294 <xsl:if test="$axf.extensions != 0">
295 <xsl:attribute name="axf:suppress-duplicate-page-number">true</xsl:attribute>
296 </xsl:if>
297 <xsl:value-of select="primary"/>
298
299 <xsl:choose>
300 <xsl:when test="$xep.extensions != 0">
301 <xsl:if test="$refs[not(see) and not(secondary)]">
302 <xsl:copy-of select="$term.separator"/>
303 <xsl:variable name="primary" select="&primary;"/>
304 <xsl:variable name="primary.significant" select="concat(&primary;, $significant.flag)"/>
305 <rx:page-index list-separator="{$number.separator}"
306 range-separator="{$range.separator}">
307 <xsl:if test="$refs[@significance='preferred'][not(see) and not(secondary)]">
308 <rx:index-item xsl:use-attribute-sets="index.preferred.page.properties xep.index.item.properties"
309 ref-key="{$primary.significant}"/>
310 </xsl:if>
311 <xsl:if test="$refs[not(@significance) or @significance!='preferred'][not(see) and not(secondary)]">
312 <rx:index-item xsl:use-attribute-sets="xep.index.item.properties"
313 ref-key="{$primary}"/>
314 </xsl:if>
315 </rx:page-index>
316 </xsl:if>
317 </xsl:when>
318 <xsl:otherwise>
319 <xsl:variable name="page-number-citations">
320 <xsl:for-each select="$refs[not(see)
321 and not(secondary)]">
322 <xsl:apply-templates select="." mode="reference">
323 <xsl:with-param name="scope" select="$scope"/>
324 <xsl:with-param name="role" select="$role"/>
325 <xsl:with-param name="type" select="$type"/>
326 <xsl:with-param name="position" select="position()"/>
327 </xsl:apply-templates>
328 </xsl:for-each>
329 </xsl:variable>
330
331 <xsl:choose>
332 <xsl:when test="$passivetex.extensions != '0'">
333 <fotex:sort xmlns:fotex="http://www.tug.org/fotex">
334 <xsl:copy-of select="$page-number-citations"/>
335 </fotex:sort>
336 </xsl:when>
337 <xsl:otherwise>
338 <xsl:copy-of select="$page-number-citations"/>
339 </xsl:otherwise>
340 </xsl:choose>
341 </xsl:otherwise>
342 </xsl:choose>
343
344 <xsl:if test="$refs[not(secondary)]/*[self::see]">
345 <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &sep;, &sep;, see))[&scope;][1])]"
346 mode="index-see">
347 <xsl:with-param name="scope" select="$scope"/>
348 <xsl:with-param name="role" select="$role"/>
349 <xsl:with-param name="type" select="$type"/>
350 <xsl:sort select="translate(see, &lowercase;, &uppercase;)"/>
351 </xsl:apply-templates>
352 </xsl:if>
353
354 </fo:block>
355
356 <xsl:if test="$refs/secondary or $refs[not(secondary)]/*[self::seealso]">
357 <fo:block start-indent="1pc">
358 <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see-also', concat(&primary;, &sep;, &sep;, &sep;, seealso))[&scope;][1])]"
359 mode="index-seealso">
360 <xsl:with-param name="scope" select="$scope"/>
361 <xsl:with-param name="role" select="$role"/>
362 <xsl:with-param name="type" select="$type"/>
363 <xsl:sort select="translate(seealso, &lowercase;, &uppercase;)"/>
364 </xsl:apply-templates>
365 <xsl:apply-templates select="$refs[secondary and count(.|key('secondary', concat($key, &sep;, &secondary;))[&scope;][1]) = 1]"
366 mode="index-secondary">
367 <xsl:with-param name="scope" select="$scope"/>
368 <xsl:with-param name="role" select="$role"/>
369 <xsl:with-param name="type" select="$type"/>
370 <xsl:sort select="translate(&secondary;, &lowercase;, &uppercase;)"/>
371 </xsl:apply-templates>
372 </fo:block>
373 </xsl:if>
374</xsl:template>
375
376<xsl:template match="indexterm" mode="index-secondary">
377 <xsl:param name="scope" select="."/>
378 <xsl:param name="role" select="''"/>
379 <xsl:param name="type" select="''"/>
380
381 <xsl:variable name="key" select="concat(&primary;, &sep;, &secondary;)"/>
382 <xsl:variable name="refs" select="key('secondary', $key)[&scope;]"/>
383
384 <xsl:variable name="term.separator">
385 <xsl:call-template name="index.separator">
386 <xsl:with-param name="key" select="'index.term.separator'"/>
387 </xsl:call-template>
388 </xsl:variable>
389
390 <xsl:variable name="range.separator">
391 <xsl:call-template name="index.separator">
392 <xsl:with-param name="key" select="'index.range.separator'"/>
393 </xsl:call-template>
394 </xsl:variable>
395
396 <xsl:variable name="number.separator">
397 <xsl:call-template name="index.separator">
398 <xsl:with-param name="key" select="'index.number.separator'"/>
399 </xsl:call-template>
400 </xsl:variable>
401
402 <fo:block>
403 <xsl:if test="$axf.extensions != 0">
404 <xsl:attribute name="axf:suppress-duplicate-page-number">true</xsl:attribute>
405 </xsl:if>
406 <xsl:value-of select="secondary"/>
407
408 <xsl:choose>
409 <xsl:when test="$xep.extensions != 0">
410 <xsl:if test="$refs[not(see) and not(tertiary)]">
411 <xsl:copy-of select="$term.separator"/>
412 <xsl:variable name="primary" select="&primary;"/>
413 <xsl:variable name="secondary" select="&secondary;"/>
414 <xsl:variable name="primary.significant" select="concat(&primary;, $significant.flag)"/>
415 <rx:page-index list-separator="{$number.separator}"
416 range-separator="{$range.separator}">
417 <xsl:if test="$refs[@significance='preferred'][not(see) and not(tertiary)]">
418 <rx:index-item xsl:use-attribute-sets="index.preferred.page.properties xep.index.item.properties">
419 <xsl:attribute name="ref-key">
420 <xsl:value-of select="$primary.significant"/>
421 <xsl:text>, </xsl:text>
422 <xsl:value-of select="$secondary"/>
423 </xsl:attribute>
424 </rx:index-item>
425 </xsl:if>
426 <xsl:if test="$refs[not(@significance) or @significance!='preferred'][not(see) and not(tertiary)]">
427 <rx:index-item xsl:use-attribute-sets="xep.index.item.properties">
428 <xsl:attribute name="ref-key">
429 <xsl:value-of select="$primary"/>
430 <xsl:text>, </xsl:text>
431 <xsl:value-of select="$secondary"/>
432 </xsl:attribute>
433 </rx:index-item>
434 </xsl:if>
435 </rx:page-index>
436 </xsl:if>
437 </xsl:when>
438 <xsl:otherwise>
439 <xsl:variable name="page-number-citations">
440 <xsl:for-each select="$refs[not(see)
441 and not(tertiary)]">
442 <xsl:apply-templates select="." mode="reference">
443 <xsl:with-param name="scope" select="$scope"/>
444 <xsl:with-param name="role" select="$role"/>
445 <xsl:with-param name="type" select="$type"/>
446 <xsl:with-param name="position" select="position()"/>
447 </xsl:apply-templates>
448 </xsl:for-each>
449 </xsl:variable>
450
451 <xsl:choose>
452 <xsl:when test="$passivetex.extensions != '0'">
453 <fotex:sort xmlns:fotex="http://www.tug.org/fotex">
454 <xsl:copy-of select="$page-number-citations"/>
455 </fotex:sort>
456 </xsl:when>
457 <xsl:otherwise>
458 <xsl:copy-of select="$page-number-citations"/>
459 </xsl:otherwise>
460 </xsl:choose>
461 </xsl:otherwise>
462 </xsl:choose>
463
464 <xsl:if test="$refs[not(tertiary)]/*[self::see]">
465 <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &secondary;, &sep;, &sep;, see))[&scope;][1])]"
466 mode="index-see">
467 <xsl:with-param name="scope" select="$scope"/>
468 <xsl:with-param name="role" select="$role"/>
469 <xsl:with-param name="type" select="$type"/>
470 <xsl:sort select="translate(see, &lowercase;, &uppercase;)"/>
471 </xsl:apply-templates>
472 </xsl:if>
473
474 </fo:block>
475
476 <xsl:if test="$refs/tertiary or $refs[not(tertiary)]/*[self::seealso]">
477 <fo:block start-indent="2pc">
478 <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see-also', concat(&primary;, &sep;, &secondary;, &sep;, &sep;, seealso))[&scope;][1])]"
479 mode="index-seealso">
480 <xsl:with-param name="scope" select="$scope"/>
481 <xsl:with-param name="role" select="$role"/>
482 <xsl:with-param name="type" select="$type"/>
483 <xsl:sort select="translate(seealso, &lowercase;, &uppercase;)"/>
484 </xsl:apply-templates>
485 <xsl:apply-templates select="$refs[tertiary and count(.|key('tertiary', concat($key, &sep;, &tertiary;))[&scope;][1]) = 1]"
486 mode="index-tertiary">
487 <xsl:with-param name="scope" select="$scope"/>
488 <xsl:with-param name="role" select="$role"/>
489 <xsl:with-param name="type" select="$type"/>
490 <xsl:sort select="translate(&tertiary;, &lowercase;, &uppercase;)"/>
491 </xsl:apply-templates>
492 </fo:block>
493 </xsl:if>
494</xsl:template>
495
496<xsl:template match="indexterm" mode="index-tertiary">
497 <xsl:param name="scope" select="."/>
498 <xsl:param name="role" select="''"/>
499 <xsl:param name="type" select="''"/>
500 <xsl:variable name="key" select="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;)"/>
501 <xsl:variable name="refs" select="key('tertiary', $key)[&scope;]"/>
502
503 <xsl:variable name="term.separator">
504 <xsl:call-template name="index.separator">
505 <xsl:with-param name="key" select="'index.term.separator'"/>
506 </xsl:call-template>
507 </xsl:variable>
508
509 <xsl:variable name="range.separator">
510 <xsl:call-template name="index.separator">
511 <xsl:with-param name="key" select="'index.range.separator'"/>
512 </xsl:call-template>
513 </xsl:variable>
514
515 <xsl:variable name="number.separator">
516 <xsl:call-template name="index.separator">
517 <xsl:with-param name="key" select="'index.number.separator'"/>
518 </xsl:call-template>
519 </xsl:variable>
520
521 <fo:block>
522 <xsl:if test="$axf.extensions != 0">
523 <xsl:attribute name="axf:suppress-duplicate-page-number">true</xsl:attribute>
524 </xsl:if>
525 <xsl:value-of select="tertiary"/>
526
527 <xsl:choose>
528 <xsl:when test="$xep.extensions != 0">
529 <xsl:if test="$refs[not(see)]">
530 <xsl:copy-of select="$term.separator"/>
531 <xsl:variable name="primary" select="&primary;"/>
532 <xsl:variable name="secondary" select="&secondary;"/>
533 <xsl:variable name="tertiary" select="&tertiary;"/>
534 <xsl:variable name="primary.significant" select="concat(&primary;, $significant.flag)"/>
535 <rx:page-index list-separator="{$number.separator}"
536 range-separator="{$range.separator}">
537 <xsl:if test="$refs[@significance='preferred'][not(see)]">
538 <rx:index-item xsl:use-attribute-sets="index.preferred.page.properties xep.index.item.properties">
539 <xsl:attribute name="ref-key">
540 <xsl:value-of select="$primary.significant"/>
541 <xsl:text>, </xsl:text>
542 <xsl:value-of select="$secondary"/>
543 <xsl:text>, </xsl:text>
544 <xsl:value-of select="$tertiary"/>
545 </xsl:attribute>
546 </rx:index-item>
547 </xsl:if>
548 <xsl:if test="$refs[not(@significance) or @significance!='preferred'][not(see)]">
549 <rx:index-item xsl:use-attribute-sets="xep.index.item.properties">
550 <xsl:attribute name="ref-key">
551 <xsl:value-of select="$primary"/>
552 <xsl:text>, </xsl:text>
553 <xsl:value-of select="$secondary"/>
554 <xsl:text>, </xsl:text>
555 <xsl:value-of select="$tertiary"/>
556 </xsl:attribute>
557 </rx:index-item>
558 </xsl:if>
559 </rx:page-index>
560 </xsl:if>
561 </xsl:when>
562 <xsl:otherwise>
563 <xsl:variable name="page-number-citations">
564 <xsl:for-each select="$refs[not(see)]">
565 <xsl:apply-templates select="." mode="reference">
566 <xsl:with-param name="scope" select="$scope"/>
567 <xsl:with-param name="role" select="$role"/>
568 <xsl:with-param name="type" select="$type"/>
569 <xsl:with-param name="position" select="position()"/>
570 </xsl:apply-templates>
571 </xsl:for-each>
572 </xsl:variable>
573
574 <xsl:choose>
575 <xsl:when test="$passivetex.extensions != '0'">
576 <fotex:sort xmlns:fotex="http://www.tug.org/fotex">
577 <xsl:copy-of select="$page-number-citations"/>
578 </fotex:sort>
579 </xsl:when>
580 <xsl:otherwise>
581 <xsl:copy-of select="$page-number-citations"/>
582 </xsl:otherwise>
583 </xsl:choose>
584 </xsl:otherwise>
585 </xsl:choose>
586
587 <xsl:if test="$refs/see">
588 <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, see))[&scope;][1])]"
589 mode="index-see">
590 <xsl:with-param name="scope" select="$scope"/>
591 <xsl:with-param name="role" select="$role"/>
592 <xsl:with-param name="type" select="$type"/>
593 <xsl:sort select="translate(see, &lowercase;, &uppercase;)"/>
594 </xsl:apply-templates>
595 </xsl:if>
596
597 </fo:block>
598
599 <xsl:if test="$refs/seealso">
600 <fo:block>
601 <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see-also', concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, seealso))[&scope;][1])]"
602 mode="index-seealso">
603 <xsl:with-param name="scope" select="$scope"/>
604 <xsl:with-param name="role" select="$role"/>
605 <xsl:with-param name="type" select="$type"/>
606 <xsl:sort select="translate(seealso, &lowercase;, &uppercase;)"/>
607 </xsl:apply-templates>
608 </fo:block>
609 </xsl:if>
610</xsl:template>
611
612<xsl:template match="indexterm" mode="reference">
613 <xsl:param name="scope" select="."/>
614 <xsl:param name="role" select="''"/>
615 <xsl:param name="type" select="''"/>
616 <xsl:param name="position" select="0"/>
617 <xsl:param name="separator" select="''"/>
618
619 <xsl:variable name="term.separator">
620 <xsl:call-template name="index.separator">
621 <xsl:with-param name="key" select="'index.term.separator'"/>
622 </xsl:call-template>
623 </xsl:variable>
624
625 <xsl:variable name="range.separator">
626 <xsl:call-template name="index.separator">
627 <xsl:with-param name="key" select="'index.range.separator'"/>
628 </xsl:call-template>
629 </xsl:variable>
630
631 <xsl:variable name="number.separator">
632 <xsl:call-template name="index.separator">
633 <xsl:with-param name="key" select="'index.number.separator'"/>
634 </xsl:call-template>
635 </xsl:variable>
636
637 <xsl:choose>
638 <xsl:when test="$separator != ''">
639 <xsl:value-of select="$separator"/>
640 </xsl:when>
641 <xsl:when test="$position = 1">
642 <xsl:value-of select="$term.separator"/>
643 </xsl:when>
644 <xsl:otherwise>
645 <xsl:value-of select="$number.separator"/>
646 </xsl:otherwise>
647 </xsl:choose>
648
649 <xsl:choose>
650 <xsl:when test="@zone and string(@zone)">
651 <xsl:call-template name="reference">
652 <xsl:with-param name="zones" select="normalize-space(@zone)"/>
653 <xsl:with-param name="scope" select="$scope"/>
654 <xsl:with-param name="role" select="$role"/>
655 <xsl:with-param name="type" select="$type"/>
656 </xsl:call-template>
657 </xsl:when>
658 <xsl:when test="ancestor::*[contains(local-name(),'info') and not(starts-with(local-name(),'info'))]">
659 <xsl:call-template name="info.reference">
660 <xsl:with-param name="scope" select="$scope"/>
661 <xsl:with-param name="role" select="$role"/>
662 <xsl:with-param name="type" select="$type"/>
663 </xsl:call-template>
664 </xsl:when>
665 <xsl:otherwise>
666 <xsl:variable name="id">
667 <xsl:call-template name="object.id"/>
668 </xsl:variable>
669
670 <fo:basic-link internal-destination="{$id}"
671 xsl:use-attribute-sets="index.page.number.properties">
672 <fo:page-number-citation ref-id="{$id}"/>
673 </fo:basic-link>
674
675 <xsl:if test="key('endofrange', $id)[&scope;]">
676 <xsl:apply-templates select="key('endofrange', $id)[&scope;][last()]"
677 mode="reference">
678 <xsl:with-param name="scope" select="$scope"/>
679 <xsl:with-param name="role" select="$role"/>
680 <xsl:with-param name="type" select="$type"/>
681 <xsl:with-param name="separator" select="$range.separator"/>
682 </xsl:apply-templates>
683 </xsl:if>
684 </xsl:otherwise>
685 </xsl:choose>
686</xsl:template>
687
688<xsl:template name="reference">
689 <xsl:param name="scope" select="."/>
690 <xsl:param name="role" select="''"/>
691 <xsl:param name="type" select="''"/>
692 <xsl:param name="zones"/>
693
694 <xsl:variable name="number.separator">
695 <xsl:call-template name="index.separator">
696 <xsl:with-param name="key" select="'index.number.separator'"/>
697 </xsl:call-template>
698 </xsl:variable>
699
700 <xsl:choose>
701 <xsl:when test="contains($zones, ' ')">
702 <xsl:variable name="zone" select="substring-before($zones, ' ')"/>
703 <xsl:variable name="target" select="key('id', $zone)[&scope;]"/>
704
705 <xsl:variable name="id">
706 <xsl:call-template name="object.id">
707 <xsl:with-param name="object" select="$target[1]"/>
708 </xsl:call-template>
709 </xsl:variable>
710
711 <fo:basic-link internal-destination="{$id}"
712 xsl:use-attribute-sets="index.page.number.properties">
713 <fo:page-number-citation ref-id="{$id}"/>
714 </fo:basic-link>
715
716 <xsl:if test="$passivetex.extensions = '0'">
717 <xsl:copy-of select="$number.separator"/>
718 </xsl:if>
719 <xsl:call-template name="reference">
720 <xsl:with-param name="zones" select="substring-after($zones, ' ')"/>
721 <xsl:with-param name="scope" select="$scope"/>
722 <xsl:with-param name="role" select="$role"/>
723 <xsl:with-param name="type" select="$type"/>
724 </xsl:call-template>
725 </xsl:when>
726 <xsl:otherwise>
727 <xsl:variable name="zone" select="$zones"/>
728 <xsl:variable name="target" select="key('id', $zone)[&scope;]"/>
729
730 <xsl:variable name="id">
731 <xsl:call-template name="object.id">
732 <xsl:with-param name="object" select="$target[1]"/>
733 </xsl:call-template>
734 </xsl:variable>
735
736 <fo:basic-link internal-destination="{$id}"
737 xsl:use-attribute-sets="index.page.number.properties">
738 <fo:page-number-citation ref-id="{$id}"/>
739 </fo:basic-link>
740 </xsl:otherwise>
741 </xsl:choose>
742</xsl:template>
743
744<xsl:template name="info.reference">
745 <!-- This is not perfect. It doesn't treat indexterm inside info element as a range covering whole parent of info.
746 It also not work when there is no ID generated for parent element. But it works in the most common cases. -->
747 <xsl:param name="scope" select="."/>
748 <xsl:param name="role" select="''"/>
749 <xsl:param name="type" select="''"/>
750
751 <xsl:variable name="target" select="(ancestor::appendix|ancestor::article|ancestor::bibliography|ancestor::book|
752 ancestor::chapter|ancestor::glossary|ancestor::part|ancestor::preface|
753 ancestor::refentry|ancestor::reference|ancestor::refsect1|ancestor::refsect2|
754 ancestor::refsect3|ancestor::refsection|ancestor::refsynopsisdiv|
755 ancestor::sect1|ancestor::sect2|ancestor::sect3|ancestor::sect4|ancestor::sect5|
756 ancestor::section|ancestor::setindex|ancestor::set|ancestor::sidebar)[&scope;]"/>
757
758 <xsl:variable name="id">
759 <xsl:call-template name="object.id">
760 <xsl:with-param name="object" select="$target[1]"/>
761 </xsl:call-template>
762 </xsl:variable>
763
764 <fo:basic-link internal-destination="{$id}"
765 xsl:use-attribute-sets="index.page.number.properties">
766 <fo:page-number-citation ref-id="{$id}"/>
767 </fo:basic-link>
768</xsl:template>
769
770<xsl:template match="indexterm" mode="index-see">
771 <xsl:param name="scope" select="."/>
772 <xsl:param name="role" select="''"/>
773 <xsl:param name="type" select="''"/>
774
775 <fo:inline>
776 <xsl:text> (</xsl:text>
777 <xsl:call-template name="gentext">
778 <xsl:with-param name="key" select="'see'"/>
779 </xsl:call-template>
780 <xsl:text> </xsl:text>
781 <xsl:value-of select="see"/>
782 <xsl:text>)</xsl:text>
783 </fo:inline>
784</xsl:template>
785
786<xsl:template match="indexterm" mode="index-seealso">
787 <xsl:param name="scope" select="."/>
788 <xsl:param name="role" select="''"/>
789 <xsl:param name="type" select="''"/>
790
791 <xsl:for-each select="seealso">
792 <xsl:sort select="translate(., &lowercase;, &uppercase;)"/>
793 <fo:block>
794 <xsl:text>(</xsl:text>
795 <xsl:call-template name="gentext">
796 <xsl:with-param name="key" select="'seealso'"/>
797 </xsl:call-template>
798 <xsl:text> </xsl:text>
799 <xsl:value-of select="."/>
800 <xsl:text>)</xsl:text>
801 </fo:block>
802 </xsl:for-each>
803
804</xsl:template>
805
806<!-- ====================================================================== -->
807
808<xsl:template name="generate-index-markup">
809 <xsl:param name="scope" select="(ancestor::book|/)[last()]"/>
810 <xsl:param name="role" select="@role"/>
811 <xsl:param name="type" select="@type"/>
812
813 <xsl:variable name="terms" select="$scope//indexterm[count(.|key('letter',
814 translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;))[&scope;][1]) = 1]"/>
815 <xsl:variable name="alphabetical"
816 select="$terms[contains(concat(&lowercase;, &uppercase;),
817 substring(&primary;, 1, 1))]"/>
818 <xsl:variable name="others" select="$terms[not(contains(concat(&lowercase;,
819 &uppercase;),
820 substring(&primary;, 1, 1)))]"/>
821
822 <xsl:text>&lt;index&gt;&#10;</xsl:text>
823 <xsl:if test="$others">
824 <xsl:text>&#10;&lt;indexdiv&gt;&#10;</xsl:text>
825 <xsl:text>&lt;title&gt;</xsl:text>
826 <xsl:call-template name="gentext">
827 <xsl:with-param name="key" select="'index symbols'"/>
828 </xsl:call-template>
829 <xsl:text>&lt;/title&gt;&#10;</xsl:text>
830 <xsl:apply-templates select="$others[count(.|key('primary',
831 &primary;)[&scope;][1]) = 1]"
832 mode="index-symbol-div-markup">
833 <xsl:with-param name="scope" select="$scope"/>
834 <xsl:with-param name="role" select="$role"/>
835 <xsl:with-param name="type" select="$type"/>
836 <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
837 </xsl:apply-templates>
838 <xsl:text>&lt;/indexdiv&gt;&#10;</xsl:text>
839 </xsl:if>
840
841 <xsl:apply-templates select="$alphabetical[count(.|key('letter',
842 translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;))[&scope;][1]) = 1]"
843 mode="index-div-markup">
844 <xsl:with-param name="scope" select="$scope"/>
845 <xsl:with-param name="role" select="$role"/>
846 <xsl:with-param name="type" select="$type"/>
847 <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
848 </xsl:apply-templates>
849 <xsl:text>&lt;/index&gt;&#10;</xsl:text>
850</xsl:template>
851
852<xsl:template match="*" mode="index-markup">
853 <xsl:param name="scope" select="."/>
854 <xsl:param name="role" select="''"/>
855 <xsl:param name="type" select="''"/>
856
857 <xsl:text>&lt;</xsl:text>
858 <xsl:value-of select="local-name(.)"/>
859 <xsl:text>&gt;&#10;</xsl:text>
860 <xsl:apply-templates mode="index-markup">
861 <xsl:with-param name="scope" select="$scope"/>
862 <xsl:with-param name="role" select="$role"/>
863 <xsl:with-param name="type" select="$type"/>
864 </xsl:apply-templates>
865</xsl:template>
866
867<xsl:template match="indexterm" mode="index-div-markup">
868 <xsl:param name="scope" select="."/>
869 <xsl:param name="role" select="''"/>
870 <xsl:param name="type" select="''"/>
871 <xsl:variable name="key" select="translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;)"/>
872 <xsl:text>&#10;&lt;indexdiv&gt;&#10;</xsl:text>
873 <xsl:text>&lt;title&gt;</xsl:text>
874 <xsl:value-of select="translate($key, &lowercase;, &uppercase;)"/>
875 <xsl:text>&lt;/title&gt;&#10;</xsl:text>
876
877 <xsl:apply-templates select="key('letter', $key)[&scope;][count(.|key('primary', &primary;)[&scope;][1]) = 1]"
878 mode="index-primary-markup">
879 <xsl:with-param name="scope" select="$scope"/>
880 <xsl:with-param name="role" select="$role"/>
881 <xsl:with-param name="type" select="$type"/>
882 <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
883 </xsl:apply-templates>
884 <xsl:text>&lt;/indexdiv&gt;&#10;</xsl:text>
885</xsl:template>
886
887<xsl:template match="indexterm" mode="index-symbol-div-markup">
888 <xsl:param name="scope" select="."/>
889 <xsl:param name="role" select="''"/>
890 <xsl:param name="type" select="''"/>
891 <xsl:variable name="key" select="translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;)"/>
892
893 <xsl:apply-templates select="key('letter', $key)[&scope;][count(.|key('primary', &primary;)[&scope;][1]) = 1]"
894 mode="index-primary-markup">
895 <xsl:with-param name="scope" select="$scope"/>
896 <xsl:with-param name="role" select="$role"/>
897 <xsl:with-param name="type" select="$type"/>
898 <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
899 </xsl:apply-templates>
900</xsl:template>
901
902<xsl:template match="indexterm" mode="index-primary-markup">
903 <xsl:param name="scope" select="."/>
904 <xsl:param name="role" select="''"/>
905 <xsl:param name="type" select="''"/>
906 <xsl:variable name="key" select="&primary;"/>
907 <xsl:variable name="refs" select="key('primary', $key)[&scope;]"/>
908 <xsl:variable name="pages" select="$refs[not(see) and not(seealso)]"/>
909
910 <xsl:text>&#10;&lt;indexentry&gt;&#10;</xsl:text>
911 <xsl:text>&lt;primaryie&gt;</xsl:text>
912 <xsl:text>&lt;phrase&gt;</xsl:text>
913 <xsl:call-template name="escape-text">
914 <xsl:with-param name="text" select="string(primary)"/>
915 </xsl:call-template>
916 <xsl:text>&lt;/phrase&gt;</xsl:text>
917 <xsl:if test="$pages">,</xsl:if>
918 <xsl:text>&#10;</xsl:text>
919
920 <xsl:for-each select="$pages">
921 <xsl:apply-templates select="." mode="reference-markup">
922 <xsl:with-param name="scope" select="$scope"/>
923 <xsl:with-param name="role" select="$role"/>
924 <xsl:with-param name="type" select="$type"/>
925 </xsl:apply-templates>
926 </xsl:for-each>
927
928 <xsl:text>&lt;/primaryie&gt;&#10;</xsl:text>
929
930 <xsl:if test="$refs/secondary or $refs[not(secondary)]/*[self::see or self::seealso]">
931 <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &sep;, &sep;, see))[&scope;][1])]"
932 mode="index-see-markup">
933 <xsl:with-param name="scope" select="$scope"/>
934 <xsl:with-param name="role" select="$role"/>
935 <xsl:with-param name="type" select="$type"/>
936 <xsl:sort select="translate(see, &lowercase;, &uppercase;)"/>
937 </xsl:apply-templates>
938
939 <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see-also', concat(&primary;, &sep;, &sep;, &sep;, seealso))[&scope;][1])]"
940 mode="index-seealso-markup">
941 <xsl:with-param name="scope" select="$scope"/>
942 <xsl:with-param name="role" select="$role"/>
943 <xsl:with-param name="type" select="$type"/>
944 <xsl:sort select="translate(seealso, &lowercase;, &uppercase;)"/>
945 </xsl:apply-templates>
946
947 <xsl:apply-templates select="$refs[secondary and count(.|key('secondary', concat($key, &sep;, &secondary;))[&scope;][1]) = 1]"
948 mode="index-secondary-markup">
949 <xsl:with-param name="scope" select="$scope"/>
950 <xsl:with-param name="role" select="$role"/>
951 <xsl:with-param name="type" select="$type"/>
952 <xsl:sort select="translate(&secondary;, &lowercase;, &uppercase;)"/>
953 </xsl:apply-templates>
954 </xsl:if>
955 <xsl:text>&lt;/indexentry&gt;&#10;</xsl:text>
956</xsl:template>
957
958<xsl:template match="indexterm" mode="index-secondary-markup">
959 <xsl:param name="scope" select="."/>
960 <xsl:param name="role" select="''"/>
961 <xsl:param name="type" select="''"/>
962 <xsl:variable name="key" select="concat(&primary;, &sep;, &secondary;)"/>
963 <xsl:variable name="refs" select="key('secondary', $key)[&scope;]"/>
964 <xsl:variable name="pages" select="$refs[not(see) and not(seealso)]"/>
965
966 <xsl:text>&lt;secondaryie&gt;</xsl:text>
967 <xsl:text>&lt;phrase&gt;</xsl:text>
968 <xsl:call-template name="escape-text">
969 <xsl:with-param name="text" select="string(secondary)"/>
970 </xsl:call-template>
971 <xsl:text>&lt;/phrase&gt;</xsl:text>
972 <xsl:if test="$pages">,</xsl:if>
973 <xsl:text>&#10;</xsl:text>
974
975 <xsl:for-each select="$pages">
976 <xsl:apply-templates select="." mode="reference-markup">
977 <xsl:with-param name="scope" select="$scope"/>
978 <xsl:with-param name="role" select="$role"/>
979 <xsl:with-param name="type" select="$type"/>
980 </xsl:apply-templates>
981 </xsl:for-each>
982
983 <xsl:text>&lt;/secondaryie&gt;&#10;</xsl:text>
984
985 <xsl:if test="$refs/tertiary or $refs[not(tertiary)]/*[self::see or self::seealso]">
986 <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &secondary;, &sep;, &sep;, see))[&scope;][1])]"
987 mode="index-see-markup">
988 <xsl:with-param name="scope" select="$scope"/>
989 <xsl:with-param name="role" select="$role"/>
990 <xsl:with-param name="type" select="$type"/>
991 <xsl:sort select="translate(see, &lowercase;, &uppercase;)"/>
992 </xsl:apply-templates>
993 <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see-also', concat(&primary;, &sep;, &secondary;, &sep;, &sep;, seealso))[&scope;][1])]"
994 mode="index-seealso-markup">
995 <xsl:with-param name="scope" select="$scope"/>
996 <xsl:with-param name="role" select="$role"/>
997 <xsl:with-param name="type" select="$type"/>
998 <xsl:sort select="translate(seealso, &lowercase;, &uppercase;)"/>
999 </xsl:apply-templates>
1000 <xsl:apply-templates select="$refs[tertiary and count(.|key('tertiary', concat($key, &sep;, &tertiary;))[&scope;][1]) = 1]"
1001 mode="index-tertiary-markup">
1002 <xsl:with-param name="scope" select="$scope"/>
1003 <xsl:with-param name="role" select="$role"/>
1004 <xsl:with-param name="type" select="$type"/>
1005 <xsl:sort select="translate(&tertiary;, &lowercase;, &uppercase;)"/>
1006 </xsl:apply-templates>
1007 </xsl:if>
1008</xsl:template>
1009
1010<xsl:template match="indexterm" mode="index-tertiary-markup">
1011 <xsl:param name="scope" select="."/>
1012 <xsl:param name="role" select="''"/>
1013 <xsl:param name="type" select="''"/>
1014 <xsl:variable name="key" select="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;)"/>
1015 <xsl:variable name="refs" select="key('tertiary', $key)[&scope;]"/>
1016 <xsl:variable name="pages" select="$refs[not(see) and not(seealso)]"/>
1017
1018 <xsl:text>&lt;tertiaryie&gt;</xsl:text>
1019 <xsl:text>&lt;phrase&gt;</xsl:text>
1020 <xsl:call-template name="escape-text">
1021 <xsl:with-param name="text" select="string(tertiary)"/>
1022 </xsl:call-template>
1023 <xsl:text>&lt;/phrase&gt;</xsl:text>
1024 <xsl:if test="$pages">,</xsl:if>
1025 <xsl:text>&#10;</xsl:text>
1026
1027 <xsl:for-each select="$pages">
1028 <xsl:apply-templates select="." mode="reference-markup">
1029 <xsl:with-param name="scope" select="$scope"/>
1030 <xsl:with-param name="role" select="$role"/>
1031 <xsl:with-param name="type" select="$type"/>
1032 </xsl:apply-templates>
1033 </xsl:for-each>
1034
1035 <xsl:text>&lt;/tertiaryie&gt;&#10;</xsl:text>
1036
1037 <xsl:variable name="see" select="$refs/see | $refs/seealso"/>
1038 <xsl:if test="$see">
1039 <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, see))[&scope;][1])]"
1040 mode="index-see-markup">
1041 <xsl:with-param name="scope" select="$scope"/>
1042 <xsl:with-param name="role" select="$role"/>
1043 <xsl:with-param name="type" select="$type"/>
1044 <xsl:sort select="translate(see, &lowercase;, &uppercase;)"/>
1045 </xsl:apply-templates>
1046 <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see-also', concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, seealso))[&scope;][1])]"
1047 mode="index-seealso-markup">
1048 <xsl:with-param name="scope" select="$scope"/>
1049 <xsl:with-param name="role" select="$role"/>
1050 <xsl:with-param name="type" select="$type"/>
1051 <xsl:sort select="translate(seealso, &lowercase;, &uppercase;)"/>
1052 </xsl:apply-templates>
1053 </xsl:if>
1054</xsl:template>
1055
1056<xsl:template match="indexterm" mode="reference-markup">
1057 <xsl:param name="scope" select="."/>
1058 <xsl:param name="role" select="''"/>
1059 <xsl:param name="type" select="''"/>
1060
1061 <xsl:choose>
1062 <xsl:when test="@zone and string(@zone)">
1063 <xsl:call-template name="reference-markup">
1064 <xsl:with-param name="zones" select="normalize-space(@zone)"/>
1065 <xsl:with-param name="scope" select="$scope"/>
1066 <xsl:with-param name="role" select="$role"/>
1067 <xsl:with-param name="type" select="$type"/>
1068 </xsl:call-template>
1069 </xsl:when>
1070 <xsl:otherwise>
1071 <xsl:variable name="id">
1072 <xsl:call-template name="object.id"/>
1073 </xsl:variable>
1074
1075
1076 <xsl:choose>
1077 <xsl:when test="@startref and @class='endofrange'">
1078 <xsl:text>&lt;phrase role="pageno"&gt;</xsl:text>
1079 <xsl:text>&lt;link linkend="</xsl:text>
1080 <xsl:value-of select="@startref"/>
1081 <xsl:text>"&gt;</xsl:text>
1082 <fo:basic-link internal-destination="{@startref}"
1083 xsl:use-attribute-sets="index.page.number.properties">
1084 <fo:page-number-citation ref-id="{@startref}"/>
1085 <xsl:text>-</xsl:text>
1086 <fo:page-number-citation ref-id="{$id}"/>
1087 </fo:basic-link>
1088 <xsl:text>&lt;/link&gt;</xsl:text>
1089 <xsl:text>&lt;/phrase&gt;&#10;</xsl:text>
1090 </xsl:when>
1091 <xsl:otherwise>
1092 <xsl:text>&lt;phrase role="pageno"&gt;</xsl:text>
1093 <xsl:if test="$id">
1094 <xsl:text>&lt;link linkend="</xsl:text>
1095 <xsl:value-of select="$id"/>
1096 <xsl:text>"&gt;</xsl:text>
1097 </xsl:if>
1098 <fo:basic-link internal-destination="{$id}"
1099 xsl:use-attribute-sets="index.page.number.properties">
1100 <fo:page-number-citation ref-id="{$id}"/>
1101 </fo:basic-link>
1102 <xsl:if test="$id">
1103 <xsl:text>&lt;/link&gt;</xsl:text>
1104 </xsl:if>
1105 <xsl:text>&lt;/phrase&gt;&#10;</xsl:text>
1106 </xsl:otherwise>
1107 </xsl:choose>
1108 </xsl:otherwise>
1109 </xsl:choose>
1110</xsl:template>
1111
1112<xsl:template name="reference-markup">
1113 <xsl:param name="scope" select="."/>
1114 <xsl:param name="role" select="''"/>
1115 <xsl:param name="type" select="''"/>
1116 <xsl:param name="zones"/>
1117 <xsl:choose>
1118 <xsl:when test="contains($zones, ' ')">
1119 <xsl:variable name="zone" select="substring-before($zones, ' ')"/>
1120 <xsl:variable name="target" select="key('id', $zone)[&scope;]"/>
1121
1122 <xsl:variable name="id">
1123 <xsl:call-template name="object.id">
1124 <xsl:with-param name="object" select="$target[1]"/>
1125 </xsl:call-template>
1126 </xsl:variable>
1127
1128 <xsl:text>&lt;phrase fole="pageno"&gt;</xsl:text>
1129 <xsl:if test="$target[1]/@id or $target[1]/@xml:id">
1130 <xsl:text>&lt;link linkend="</xsl:text>
1131 <xsl:value-of select="$id"/>
1132 <xsl:text>"&gt;</xsl:text>
1133 </xsl:if>
1134 <fo:basic-link internal-destination="{$id}"
1135 xsl:use-attribute-sets="index.page.number.properties">
1136 <fo:page-number-citation ref-id="{$id}"/>
1137 </fo:basic-link>
1138 <xsl:if test="$target[1]/@id or $target[1]/@xml:id">
1139 <xsl:text>&lt;/link&gt;</xsl:text>
1140 </xsl:if>
1141 <xsl:text>&lt;/phrase&gt;&#10;</xsl:text>
1142
1143 <xsl:call-template name="reference">
1144 <xsl:with-param name="zones" select="substring-after($zones, ' ')"/>
1145 <xsl:with-param name="scope" select="$scope"/>
1146 <xsl:with-param name="role" select="$role"/>
1147 <xsl:with-param name="type" select="$type"/>
1148 </xsl:call-template>
1149 </xsl:when>
1150 <xsl:otherwise>
1151 <xsl:variable name="zone" select="$zones"/>
1152 <xsl:variable name="target" select="key('id', $zone)[&scope;]"/>
1153
1154 <xsl:variable name="id">
1155 <xsl:call-template name="object.id">
1156 <xsl:with-param name="object" select="$target[1]"/>
1157 </xsl:call-template>
1158 </xsl:variable>
1159
1160 <xsl:text>&lt;phrase role="pageno"&gt;</xsl:text>
1161 <xsl:if test="$target[1]/@id or target[1]/@xml:id">
1162 <xsl:text>&lt;link linkend="</xsl:text>
1163 <xsl:value-of select="$id"/>
1164 <xsl:text>"&gt;</xsl:text>
1165 </xsl:if>
1166 <fo:basic-link internal-destination="{$id}"
1167 xsl:use-attribute-sets="index.page.number.properties">
1168 <fo:page-number-citation ref-id="{$id}"/>
1169 </fo:basic-link>
1170 <xsl:if test="$target[1]/@id or target[1]/@xml:id">
1171 <xsl:text>&lt;/link&gt;</xsl:text>
1172 </xsl:if>
1173 <xsl:text>&lt;/phrase&gt;&#10;</xsl:text>
1174 </xsl:otherwise>
1175 </xsl:choose>
1176</xsl:template>
1177
1178<xsl:template match="indexterm" mode="index-see-markup">
1179 <xsl:param name="scope" select="."/>
1180 <xsl:param name="role" select="''"/>
1181 <xsl:param name="type" select="''"/>
1182 <fo:block>
1183 <xsl:text>&lt;seeie&gt;</xsl:text>
1184 <xsl:text>&lt;phrase&gt;</xsl:text>
1185 <xsl:call-template name="escape-text">
1186 <xsl:with-param name="text" select="string(see)"/>
1187 </xsl:call-template>
1188 <xsl:text>&lt;/phrase&gt;</xsl:text>
1189 <xsl:text>&lt;/seeie&gt;&#10;</xsl:text>
1190 </fo:block>
1191</xsl:template>
1192
1193<xsl:template match="indexterm" mode="index-seealso-markup">
1194 <xsl:param name="scope" select="."/>
1195 <xsl:param name="role" select="''"/>
1196 <xsl:param name="type" select="''"/>
1197 <fo:block>
1198 <xsl:text>&lt;seealsoie&gt;</xsl:text>
1199 <xsl:text>&lt;phrase&gt;</xsl:text>
1200 <xsl:call-template name="escape-text">
1201 <xsl:with-param name="text" select="string(seealso)"/>
1202 </xsl:call-template>
1203 <xsl:text>&lt;/phrase&gt;</xsl:text>
1204 <xsl:text>&lt;/seealsoie&gt;&#10;</xsl:text>
1205 </fo:block>
1206</xsl:template>
1207
1208<xsl:template name="escape-text">
1209 <xsl:param name="text" select="''"/>
1210
1211 <xsl:variable name="ltpos" select="substring-before($text, '&lt;')"/>
1212 <xsl:variable name="amppos" select="substring-before($text, '&amp;')"/>
1213
1214 <xsl:choose>
1215 <xsl:when test="contains($text,'&lt;') and contains($text, '&amp;')
1216 and string-length($ltpos) &lt; string-length($amppos)">
1217 <xsl:value-of select="$ltpos"/>
1218 <xsl:text>&amp;lt;</xsl:text>
1219 <xsl:call-template name="escape-text">
1220 <xsl:with-param name="text" select="substring-after($text, '&lt;')"/>
1221 </xsl:call-template>
1222 </xsl:when>
1223
1224 <xsl:when test="contains($text,'&lt;') and contains($text, '&amp;')
1225 and string-length($amppos) &lt; string-length($ltpos)">
1226 <xsl:value-of select="$amppos"/>
1227 <xsl:text>&amp;amp;</xsl:text>
1228 <xsl:call-template name="escape-text">
1229 <xsl:with-param name="text" select="substring-after($text, '&amp;')"/>
1230 </xsl:call-template>
1231 </xsl:when>
1232
1233 <xsl:when test="contains($text, '&lt;')">
1234 <xsl:value-of select="$ltpos"/>
1235 <xsl:text>&amp;lt;</xsl:text>
1236 <xsl:call-template name="escape-text">
1237 <xsl:with-param name="text" select="substring-after($text, '&lt;')"/>
1238 </xsl:call-template>
1239 </xsl:when>
1240
1241 <xsl:when test="contains($text, '&amp;')">
1242 <xsl:value-of select="$amppos"/>
1243 <xsl:text>&amp;amp;</xsl:text>
1244 <xsl:call-template name="escape-text">
1245 <xsl:with-param name="text" select="substring-after($text, '&amp;')"/>
1246 </xsl:call-template>
1247 </xsl:when>
1248
1249 <xsl:otherwise>
1250 <xsl:value-of select="$text"/>
1251 </xsl:otherwise>
1252 </xsl:choose>
1253</xsl:template>
1254
1255<xsl:template name="index.separator">
1256 <xsl:param name="key" select="''"/>
1257 <xsl:param name="lang">
1258 <xsl:call-template name="l10n.language"/>
1259 </xsl:param>
1260
1261 <xsl:choose>
1262 <xsl:when test="$key = 'index.term.separator'">
1263 <xsl:choose>
1264 <!-- Use the override if not blank -->
1265 <xsl:when test="$index.term.separator != ''">
1266 <xsl:copy-of select="$index.term.separator"/>
1267 </xsl:when>
1268 <xsl:otherwise>
1269 <xsl:call-template name="gentext.template">
1270 <xsl:with-param name="lang" select="$lang"/>
1271 <xsl:with-param name="context">index</xsl:with-param>
1272 <xsl:with-param name="name">term-separator</xsl:with-param>
1273 </xsl:call-template>
1274 </xsl:otherwise>
1275 </xsl:choose>
1276 </xsl:when>
1277 <xsl:when test="$key = 'index.number.separator'">
1278 <xsl:choose>
1279 <!-- Use the override if not blank -->
1280 <xsl:when test="$index.number.separator != ''">
1281 <xsl:copy-of select="$index.number.separator"/>
1282 </xsl:when>
1283 <xsl:otherwise>
1284 <xsl:call-template name="gentext.template">
1285 <xsl:with-param name="lang" select="$lang"/>
1286 <xsl:with-param name="context">index</xsl:with-param>
1287 <xsl:with-param name="name">number-separator</xsl:with-param>
1288 </xsl:call-template>
1289 </xsl:otherwise>
1290 </xsl:choose>
1291 </xsl:when>
1292 <xsl:when test="$key = 'index.range.separator'">
1293 <xsl:choose>
1294 <!-- Use the override if not blank -->
1295 <xsl:when test="$index.range.separator != ''">
1296 <xsl:copy-of select="$index.range.separator"/>
1297 </xsl:when>
1298 <xsl:otherwise>
1299 <xsl:call-template name="gentext.template">
1300 <xsl:with-param name="lang" select="$lang"/>
1301 <xsl:with-param name="context">index</xsl:with-param>
1302 <xsl:with-param name="name">range-separator</xsl:with-param>
1303 </xsl:call-template>
1304 </xsl:otherwise>
1305 </xsl:choose>
1306 </xsl:when>
1307 </xsl:choose>
1308</xsl:template>
1309
1310</xsl:stylesheet>
Note: See TracBrowser for help on using the repository browser.