OLD | NEW |
| (Empty) |
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:exslt="http://exslt.org/common" | |
8 extension-element-prefixes="exslt" | |
9 exclude-result-prefixes="exslt" | |
10 version="1.0"> | |
11 | |
12 <!-- ******************************************************************** | |
13 $Id: autoidx.xsl 9376 2012-05-24 18:32:40Z 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 <!-- The "basic" method derived from Jeni Tennison's work. --> | |
24 <!-- The "kosek" method contributed by Jirka Kosek. --> | |
25 <!-- The "kimber" method contributed by Eliot Kimber of Innodata Isogen. --> | |
26 | |
27 <xsl:variable name="kimber.imported" select="0"/> | |
28 <xsl:variable name="kosek.imported" select="0"/> | |
29 | |
30 <xsl:key name="letter" | |
31 match="indexterm" | |
32 use="translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;)"/> | |
33 | |
34 <xsl:key name="primary" | |
35 match="indexterm" | |
36 use="&primary;"/> | |
37 | |
38 <xsl:key name="secondary" | |
39 match="indexterm" | |
40 use="concat(&primary;, &sep;, &secondary;)"/> | |
41 | |
42 <xsl:key name="tertiary" | |
43 match="indexterm" | |
44 use="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;)"/> | |
45 | |
46 <xsl:key name="endofrange" | |
47 match="indexterm[@class='endofrange']" | |
48 use="@startref"/> | |
49 | |
50 <xsl:key name="primary-section" | |
51 match="indexterm[not(secondary) and not(see)]" | |
52 use="concat(&primary;, &sep;, §ion.id;)"/> | |
53 | |
54 <xsl:key name="secondary-section" | |
55 match="indexterm[not(tertiary) and not(see)]" | |
56 use="concat(&primary;, &sep;, &secondary;, &sep;, §ion.id;)"/> | |
57 | |
58 <xsl:key name="tertiary-section" | |
59 match="indexterm[not(see)]" | |
60 use="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, &s
ection.id;)"/> | |
61 | |
62 <xsl:key name="see-also" | |
63 match="indexterm[seealso]" | |
64 use="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, se
ealso)"/> | |
65 | |
66 <xsl:key name="see" | |
67 match="indexterm[see]" | |
68 use="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, se
e)"/> | |
69 | |
70 <xsl:key name="sections" match="*[@id or @xml:id]" use="@id|@xml:id"/> | |
71 | |
72 | |
73 <xsl:template name="generate-index"> | |
74 <xsl:param name="scope" select="(ancestor::book|/)[last()]"/> | |
75 | |
76 <xsl:choose> | |
77 <xsl:when test="$index.method = 'kosek'"> | |
78 <xsl:call-template name="generate-kosek-index"> | |
79 <xsl:with-param name="scope" select="$scope"/> | |
80 </xsl:call-template> | |
81 </xsl:when> | |
82 <xsl:when test="$index.method = 'kimber'"> | |
83 <xsl:call-template name="generate-kimber-index"> | |
84 <xsl:with-param name="scope" select="$scope"/> | |
85 </xsl:call-template> | |
86 </xsl:when> | |
87 | |
88 <xsl:otherwise> | |
89 <xsl:call-template name="generate-basic-index"> | |
90 <xsl:with-param name="scope" select="$scope"/> | |
91 </xsl:call-template> | |
92 </xsl:otherwise> | |
93 </xsl:choose> | |
94 </xsl:template> | |
95 | |
96 <xsl:template name="generate-basic-index"> | |
97 <xsl:param name="scope" select="NOTANODE"/> | |
98 | |
99 <xsl:variable name="role"> | |
100 <xsl:if test="$index.on.role != 0"> | |
101 <xsl:value-of select="@role"/> | |
102 </xsl:if> | |
103 </xsl:variable> | |
104 | |
105 <xsl:variable name="type"> | |
106 <xsl:if test="$index.on.type != 0"> | |
107 <xsl:value-of select="@type"/> | |
108 </xsl:if> | |
109 </xsl:variable> | |
110 | |
111 <xsl:variable name="terms" | |
112 select="//indexterm | |
113 [count(.|key('letter', | |
114 translate(substring(&primary;, 1, 1), | |
115 &lowercase;, | |
116 &uppercase;)) | |
117 [&scope;][1]) = 1 | |
118 and not(@class = 'endofrange')]"/> | |
119 | |
120 <xsl:variable name="alphabetical" | |
121 select="$terms[contains(concat(&lowercase;, &uppercase;), | |
122 substring(&primary;, 1, 1))]"/> | |
123 | |
124 <xsl:variable name="others" select="$terms[not(contains(concat(&lowercase;, | |
125 &uppercase;), | |
126 substring(&primary;, 1, 1)))]"/> | |
127 <div class="index"> | |
128 <xsl:if test="$others"> | |
129 <xsl:choose> | |
130 <xsl:when test="normalize-space($type) != '' and | |
131 $others[@type = $type][count(.|key('primary', &primary;)
[&scope;][1]) = 1]"> | |
132 <div class="indexdiv"> | |
133 <h3> | |
134 <xsl:call-template name="gentext"> | |
135 <xsl:with-param name="key" select="'index symbols'"/> | |
136 </xsl:call-template> | |
137 </h3> | |
138 <dl> | |
139 <xsl:apply-templates select="$others[count(.|key('primary', &prima
ry;)[&scope;][1]) = 1]" | |
140 mode="index-symbol-div"> | |
141 <xsl:with-param name="position" select="position()"/>
| |
142 <xsl:with-param name="scope" select="$scope"/> | |
143 <xsl:with-param name="role" select="$role"/> | |
144 <xsl:with-param name="type" select="$type"/> | |
145 <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)
"/> | |
146 </xsl:apply-templates> | |
147 </dl> | |
148 </div> | |
149 </xsl:when> | |
150 <xsl:when test="normalize-space($type) != ''"> | |
151 <!-- Output nothing, as there isn't a match for $other using this $typ
e --> | |
152 </xsl:when> | |
153 <xsl:otherwise> | |
154 <div class="indexdiv"> | |
155 <h3> | |
156 <xsl:call-template name="gentext"> | |
157 <xsl:with-param name="key" select="'index symbols'"/> | |
158 </xsl:call-template> | |
159 </h3> | |
160 <dl> | |
161 <xsl:apply-templates select="$others[count(.|key('primary', | |
162 &primary;)[&scope;][1]) = 1]" | |
163 mode="index-symbol-div"> | |
164 <xsl:with-param name="position" select="position()"/>
| |
165 <xsl:with-param name="scope" select="$scope"/> | |
166 <xsl:with-param name="role" select="$role"/> | |
167 <xsl:with-param name="type" select="$type"/> | |
168 <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)
"/> | |
169 </xsl:apply-templates> | |
170 </dl> | |
171 </div> | |
172 </xsl:otherwise> | |
173 </xsl:choose> | |
174 </xsl:if> | |
175 | |
176 <xsl:apply-templates select="$alphabetical[count(.|key('letter', | |
177 translate(substring(&primary;, 1, 1), | |
178 &lowercase;,&uppercase;))[&scope;][1]
) = 1]" | |
179 mode="index-div-basic"> | |
180 <xsl:with-param name="position" select="position()"/> | |
181 <xsl:with-param name="scope" select="$scope"/> | |
182 <xsl:with-param name="role" select="$role"/> | |
183 <xsl:with-param name="type" select="$type"/> | |
184 <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/> | |
185 </xsl:apply-templates> | |
186 </div> | |
187 </xsl:template> | |
188 | |
189 <!-- This template not used if html/autoidx-kosek.xsl is imported --> | |
190 <xsl:template name="generate-kosek-index"> | |
191 <xsl:param name="scope" select="NOTANODE"/> | |
192 | |
193 <xsl:variable name="vendor" select="system-property('xsl:vendor')"/> | |
194 <xsl:if test="contains($vendor, 'libxslt')"> | |
195 <xsl:message terminate="yes"> | |
196 <xsl:text>ERROR: the 'kosek' index method does not </xsl:text> | |
197 <xsl:text>work with the xsltproc XSLT processor.</xsl:text> | |
198 </xsl:message> | |
199 </xsl:if> | |
200 | |
201 | |
202 <xsl:if test="$exsl.node.set.available = 0"> | |
203 <xsl:message terminate="yes"> | |
204 <xsl:text>ERROR: the 'kosek' index method requires the </xsl:text> | |
205 <xsl:text>exslt:node-set() function. Use a processor that </xsl:text> | |
206 <xsl:text>has it, or use a different index method.</xsl:text> | |
207 </xsl:message> | |
208 </xsl:if> | |
209 | |
210 <xsl:if test="$kosek.imported = 0"> | |
211 <xsl:message terminate="yes"> | |
212 <xsl:text>ERROR: the 'kosek' index method requires the
</xsl:text> | |
213 <xsl:text>kosek index extensions be imported:
</xsl:text> | |
214 <xsl:text> xsl:import href="html/autoidx-kosek.xsl"</xsl:text> | |
215 </xsl:message> | |
216 </xsl:if> | |
217 | |
218 </xsl:template> | |
219 | |
220 <!-- This template not used if html/autoidx-kimber.xsl is imported --> | |
221 <xsl:template name="generate-kimber-index"> | |
222 <xsl:param name="scope" select="NOTANODE"/> | |
223 | |
224 <xsl:variable name="vendor" select="system-property('xsl:vendor')"/> | |
225 <xsl:if test="not(contains($vendor, 'SAXON '))"> | |
226 <xsl:message terminate="yes"> | |
227 <xsl:text>ERROR: the 'kimber' index method requires the </xsl:text> | |
228 <xsl:text>Saxon version 6 or 8 XSLT processor.</xsl:text> | |
229 </xsl:message> | |
230 </xsl:if> | |
231 | |
232 <xsl:if test="$kimber.imported = 0"> | |
233 <xsl:message terminate="yes"> | |
234 <xsl:text>ERROR: the 'kimber' index method requires the
</xsl:text> | |
235 <xsl:text>kimber index extensions be imported:
</xsl:text> | |
236 <xsl:text> xsl:import href="html/autoidx-kimber.xsl"</xsl:text> | |
237 </xsl:message> | |
238 </xsl:if> | |
239 | |
240 </xsl:template> | |
241 | |
242 <xsl:template match="indexterm" mode="index-div-basic"> | |
243 <xsl:param name="scope" select="."/> | |
244 <xsl:param name="role" select="''"/> | |
245 <xsl:param name="type" select="''"/> | |
246 | |
247 <xsl:variable name="key" | |
248 select="translate(substring(&primary;, 1, 1), | |
249 &lowercase;,&uppercase;)"/> | |
250 | |
251 <xsl:if test="key('letter', $key)[&scope;] | |
252 [count(.|key('primary', &primary;)[&scope;][1]) = 1]"> | |
253 <div class="indexdiv"> | |
254 <xsl:if test="contains(concat(&lowercase;, &uppercase;), $key)"> | |
255 <h3> | |
256 <xsl:value-of select="translate($key, &lowercase;, &uppercase;)"/> | |
257 </h3> | |
258 </xsl:if> | |
259 <dl> | |
260 <xsl:apply-templates select="key('letter', $key)[&scope;] | |
261 [count(.|key('primary', &primary;) | |
262 [&scope;][1])=1]" | |
263 mode="index-primary"> | |
264 <xsl:with-param name="position" select="position()"/> | |
265 <xsl:with-param name="scope" select="$scope"/> | |
266 <xsl:with-param name="role" select="$role"/> | |
267 <xsl:with-param name="type" select="$type"/> | |
268 <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/> | |
269 </xsl:apply-templates> | |
270 </dl> | |
271 </div> | |
272 </xsl:if> | |
273 </xsl:template> | |
274 | |
275 <xsl:template match="indexterm" mode="index-symbol-div"> | |
276 <xsl:param name="scope" select="/"/> | |
277 <xsl:param name="role" select="''"/> | |
278 <xsl:param name="type" select="''"/> | |
279 | |
280 <xsl:variable name="key" select="translate(substring(&primary;, 1, 1), | |
281 &lowercase;,&uppercase;)"/> | |
282 | |
283 <xsl:apply-templates select="key('letter', $key) | |
284 [&scope;][count(.|key('primary', &primary;)[1]) =
1]" | |
285 mode="index-primary"> | |
286 <xsl:with-param name="position" select="position()"/> | |
287 <xsl:with-param name="scope" select="$scope"/> | |
288 <xsl:with-param name="role" select="$role"/> | |
289 <xsl:with-param name="type" select="$type"/> | |
290 <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/> | |
291 </xsl:apply-templates> | |
292 </xsl:template> | |
293 | |
294 <xsl:template match="indexterm" mode="index-primary"> | |
295 <xsl:param name="scope" select="."/> | |
296 <xsl:param name="role" select="''"/> | |
297 <xsl:param name="type" select="''"/> | |
298 | |
299 <xsl:variable name="key" select="&primary;"/> | |
300 <xsl:variable name="refs" select="key('primary', $key)[&scope;]"/> | |
301 <dt> | |
302 <xsl:for-each select="$refs/primary"> | |
303 <xsl:if test="@id or @xml:id"> | |
304 <xsl:choose> | |
305 <xsl:when test="$generate.id.attributes = 0"> | |
306 <a name="{(@id|@xml:id)[1]}"/> | |
307 </xsl:when> | |
308 <xsl:otherwise> | |
309 <span> | |
310 <xsl:call-template name="id.attribute"/> | |
311 </span> | |
312 </xsl:otherwise> | |
313 </xsl:choose> | |
314 </xsl:if> | |
315 </xsl:for-each> | |
316 <xsl:value-of select="primary"/> | |
317 <xsl:choose> | |
318 <xsl:when test="$index.links.to.section = 1"> | |
319 <xsl:for-each select="$refs[@zone != '' or generate-id() = generate-id(k
ey('primary-section', concat($key, &sep;, §ion.id;))[&scope;][1])]"> | |
320 <xsl:apply-templates select="." mode="reference"> | |
321 <xsl:with-param name="position" select="position()"/> | |
322 <xsl:with-param name="scope" select="$scope"/> | |
323 <xsl:with-param name="role" select="$role"/> | |
324 <xsl:with-param name="type" select="$type"/> | |
325 </xsl:apply-templates> | |
326 </xsl:for-each> | |
327 </xsl:when> | |
328 <xsl:otherwise> | |
329 <xsl:for-each select="$refs[not(see) | |
330 and not(secondary)][&scope;]"> | |
331 <xsl:apply-templates select="." mode="reference"> | |
332 <xsl:with-param name="position" select="position()"/> | |
333 <xsl:with-param name="scope" select="$scope"/> | |
334 <xsl:with-param name="role" select="$role"/> | |
335 <xsl:with-param name="type" select="$type"/> | |
336 </xsl:apply-templates> | |
337 </xsl:for-each> | |
338 </xsl:otherwise> | |
339 </xsl:choose> | |
340 | |
341 <xsl:if test="$refs[not(secondary)]/*[self::see]"> | |
342 <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see',
concat(&primary;, &sep;, &sep;, &sep;, see))[&scope;][1])]" | |
343 mode="index-see"> | |
344 <xsl:with-param name="position" select="position()"/> | |
345 <xsl:with-param name="scope" select="$scope"/> | |
346 <xsl:with-param name="role" select="$role"/> | |
347 <xsl:with-param name="type" select="$type"/> | |
348 <xsl:sort select="translate(see, &lowercase;, &uppercase;)"/> | |
349 </xsl:apply-templates> | |
350 </xsl:if> | |
351 </dt> | |
352 <xsl:choose> | |
353 <xsl:when test="$refs/secondary or $refs[not(secondary)]/*[self::seealso]"> | |
354 <dd> | |
355 <dl> | |
356 <xsl:apply-templates select="$refs[generate-id() = generate-id(key('se
e-also', concat(&primary;, &sep;, &sep;, &sep;, seealso))[&scope;][1])]" | |
357 mode="index-seealso"> | |
358 <xsl:with-param name="position" select="position()"/> | |
359 <xsl:with-param name="scope" select="$scope"/> | |
360 <xsl:with-param name="role" select="$role"/> | |
361 <xsl:with-param name="type" select="$type"/> | |
362 <xsl:sort select="translate(seealso, &lowercase;, &uppercase;)"/> | |
363 </xsl:apply-templates> | |
364 <xsl:apply-templates select="$refs[secondary and count(.|key('secondar
y', concat($key, &sep;, &secondary;))[&scope;][1]) = 1]" | |
365 mode="index-secondary"> | |
366 <xsl:with-param name="position" select="position()"/> | |
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 </dl> | |
373 </dd> | |
374 </xsl:when> | |
375 <!-- HTML5 requires dd for each dt --> | |
376 <xsl:when test="$div.element = 'section'"> | |
377 <dd></dd> | |
378 </xsl:when> | |
379 </xsl:choose> | |
380 </xsl:template> | |
381 | |
382 <xsl:template match="indexterm" mode="index-secondary"> | |
383 <xsl:param name="scope" select="."/> | |
384 <xsl:param name="role" select="''"/> | |
385 <xsl:param name="type" select="''"/> | |
386 | |
387 <xsl:variable name="key" select="concat(&primary;, &sep;, &secondary;)"/> | |
388 <xsl:variable name="refs" select="key('secondary', $key)[&scope;]"/> | |
389 <dt> | |
390 <xsl:for-each select="$refs/secondary"> | |
391 <xsl:if test="@id or @xml:id"> | |
392 <xsl:choose> | |
393 <xsl:when test="$generate.id.attributes = 0"> | |
394 <a name="{(@id|@xml:id)[1]}"/> | |
395 </xsl:when> | |
396 <xsl:otherwise> | |
397 <span> | |
398 <xsl:call-template name="id.attribute"/> | |
399 </span> | |
400 </xsl:otherwise> | |
401 </xsl:choose> | |
402 </xsl:if> | |
403 </xsl:for-each> | |
404 <xsl:value-of select="secondary"/> | |
405 <xsl:choose> | |
406 <xsl:when test="$index.links.to.section = 1"> | |
407 <xsl:for-each select="$refs[@zone != '' or generate-id() = generate-id(k
ey('secondary-section', concat($key, &sep;, §ion.id;))[&scope;][1])]"> | |
408 <xsl:apply-templates select="." mode="reference"> | |
409 <xsl:with-param name="position" select="position()"/> | |
410 <xsl:with-param name="scope" select="$scope"/> | |
411 <xsl:with-param name="role" select="$role"/> | |
412 <xsl:with-param name="type" select="$type"/> | |
413 </xsl:apply-templates> | |
414 </xsl:for-each> | |
415 </xsl:when> | |
416 <xsl:otherwise> | |
417 <xsl:for-each select="$refs[not(see) | |
418 and not(tertiary)][&scope;]"> | |
419 <xsl:apply-templates select="." mode="reference"> | |
420 <xsl:with-param name="position" select="position()"/> | |
421 <xsl:with-param name="scope" select="$scope"/> | |
422 <xsl:with-param name="role" select="$role"/> | |
423 <xsl:with-param name="type" select="$type"/> | |
424 </xsl:apply-templates> | |
425 </xsl:for-each> | |
426 </xsl:otherwise> | |
427 </xsl:choose> | |
428 | |
429 <xsl:if test="$refs[not(tertiary)]/*[self::see]"> | |
430 <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see',
concat(&primary;, &sep;, &secondary;, &sep;, &sep;, see))[&scope;][1])]" | |
431 mode="index-see"> | |
432 <xsl:with-param name="position" select="position()"/> | |
433 <xsl:with-param name="scope" select="$scope"/> | |
434 <xsl:with-param name="role" select="$role"/> | |
435 <xsl:with-param name="type" select="$type"/> | |
436 <xsl:sort select="translate(see, &lowercase;, &uppercase;)"/> | |
437 </xsl:apply-templates> | |
438 </xsl:if> | |
439 </dt> | |
440 <xsl:choose> | |
441 <xsl:when test="$refs/tertiary or $refs[not(tertiary)]/*[self::seealso]"> | |
442 <dd> | |
443 <dl> | |
444 <xsl:apply-templates select="$refs[generate-id() = generate-id(key('se
e-also', concat(&primary;, &sep;, &secondary;, &sep;, &sep;, seealso))[&scope;][
1])]" | |
445 mode="index-seealso"> | |
446 <xsl:with-param name="position" select="position()"/> | |
447 <xsl:with-param name="scope" select="$scope"/> | |
448 <xsl:with-param name="role" select="$role"/> | |
449 <xsl:with-param name="type" select="$type"/> | |
450 <xsl:sort select="translate(seealso, &lowercase;, &uppercase;)"/> | |
451 </xsl:apply-templates> | |
452 <xsl:apply-templates select="$refs[tertiary and count(.|key('tertiary'
, concat($key, &sep;, &tertiary;))[&scope;][1]) = 1]" | |
453 mode="index-tertiary"> | |
454 <xsl:with-param name="position" select="position()"/> | |
455 <xsl:with-param name="scope" select="$scope"/> | |
456 <xsl:with-param name="role" select="$role"/> | |
457 <xsl:with-param name="type" select="$type"/> | |
458 <xsl:sort select="translate(&tertiary;, &lowercase;, &uppercase;)"/> | |
459 </xsl:apply-templates> | |
460 </dl> | |
461 </dd> | |
462 </xsl:when> | |
463 <!-- HTML5 requires dd for each dt --> | |
464 <xsl:when test="$div.element = 'section'"> | |
465 <dd></dd> | |
466 </xsl:when> | |
467 </xsl:choose> | |
468 </xsl:template> | |
469 | |
470 <xsl:template match="indexterm" mode="index-tertiary"> | |
471 <xsl:param name="scope" select="."/> | |
472 <xsl:param name="role" select="''"/> | |
473 <xsl:param name="type" select="''"/> | |
474 | |
475 <xsl:variable name="key" select="concat(&primary;, &sep;, &secondary;, &sep;,
&tertiary;)"/> | |
476 <xsl:variable name="refs" select="key('tertiary', $key)[&scope;]"/> | |
477 <dt> | |
478 <xsl:for-each select="$refs/tertiary"> | |
479 <xsl:if test="@id or @xml:id"> | |
480 <xsl:choose> | |
481 <xsl:when test="$generate.id.attributes = 0"> | |
482 <a name="{(@id|@xml:id)[1]}"/> | |
483 </xsl:when> | |
484 <xsl:otherwise> | |
485 <span> | |
486 <xsl:call-template name="id.attribute"/> | |
487 </span> | |
488 </xsl:otherwise> | |
489 </xsl:choose> | |
490 </xsl:if> | |
491 </xsl:for-each> | |
492 <xsl:value-of select="tertiary"/> | |
493 <xsl:choose> | |
494 <xsl:when test="$index.links.to.section = 1"> | |
495 <xsl:for-each select="$refs[@zone != '' or generate-id() = generate-id(k
ey('tertiary-section', concat($key, &sep;, §ion.id;))[&scope;][1])]"> | |
496 <xsl:apply-templates select="." mode="reference"> | |
497 <xsl:with-param name="position" select="position()"/> | |
498 <xsl:with-param name="scope" select="$scope"/> | |
499 <xsl:with-param name="role" select="$role"/> | |
500 <xsl:with-param name="type" select="$type"/> | |
501 </xsl:apply-templates> | |
502 </xsl:for-each> | |
503 </xsl:when> | |
504 <xsl:otherwise> | |
505 <xsl:for-each select="$refs[not(see)][&scope;]"> | |
506 <xsl:apply-templates select="." mode="reference"> | |
507 <xsl:with-param name="position" select="position()"/> | |
508 <xsl:with-param name="scope" select="$scope"/> | |
509 <xsl:with-param name="role" select="$role"/> | |
510 <xsl:with-param name="type" select="$type"/> | |
511 </xsl:apply-templates> | |
512 </xsl:for-each> | |
513 </xsl:otherwise> | |
514 </xsl:choose> | |
515 | |
516 <xsl:if test="$refs/see"> | |
517 <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see',
concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, see))[&scope;][1
])]" | |
518 mode="index-see"> | |
519 <xsl:with-param name="position" select="position()"/> | |
520 <xsl:with-param name="scope" select="$scope"/> | |
521 <xsl:with-param name="role" select="$role"/> | |
522 <xsl:with-param name="type" select="$type"/> | |
523 <xsl:sort select="translate(see, &lowercase;, &uppercase;)"/> | |
524 </xsl:apply-templates> | |
525 </xsl:if> | |
526 </dt> | |
527 <xsl:choose> | |
528 <xsl:when test="$refs/seealso"> | |
529 <dd> | |
530 <dl> | |
531 <xsl:apply-templates select="$refs[generate-id() = generate-id(key('se
e-also', concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, seealso
))[&scope;][1])]" | |
532 mode="index-seealso"> | |
533 <xsl:with-param name="position" select="position()"/> | |
534 <xsl:with-param name="scope" select="$scope"/> | |
535 <xsl:with-param name="role" select="$role"/> | |
536 <xsl:with-param name="type" select="$type"/> | |
537 <xsl:sort select="translate(seealso, &lowercase;, &uppercase;)"/> | |
538 </xsl:apply-templates> | |
539 </dl> | |
540 </dd> | |
541 </xsl:when> | |
542 <!-- HTML5 requires dd for each dt --> | |
543 <xsl:when test="$div.element = 'section'"> | |
544 <dd></dd> | |
545 </xsl:when> | |
546 </xsl:choose> | |
547 </xsl:template> | |
548 | |
549 <xsl:template match="indexterm" mode="reference"> | |
550 <xsl:param name="scope" select="."/> | |
551 <xsl:param name="role" select="''"/> | |
552 <xsl:param name="type" select="''"/> | |
553 <xsl:param name="position"/> | |
554 <xsl:param name="separator" select="''"/> | |
555 | |
556 <xsl:variable name="term.separator"> | |
557 <xsl:call-template name="index.separator"> | |
558 <xsl:with-param name="key" select="'index.term.separator'"/> | |
559 </xsl:call-template> | |
560 </xsl:variable> | |
561 | |
562 <xsl:variable name="number.separator"> | |
563 <xsl:call-template name="index.separator"> | |
564 <xsl:with-param name="key" select="'index.number.separator'"/> | |
565 </xsl:call-template> | |
566 </xsl:variable> | |
567 | |
568 <xsl:variable name="range.separator"> | |
569 <xsl:call-template name="index.separator"> | |
570 <xsl:with-param name="key" select="'index.range.separator'"/> | |
571 </xsl:call-template> | |
572 </xsl:variable> | |
573 | |
574 <xsl:choose> | |
575 <xsl:when test="$separator != ''"> | |
576 <xsl:value-of select="$separator"/> | |
577 </xsl:when> | |
578 <xsl:when test="$position = 1"> | |
579 <xsl:value-of select="$term.separator"/> | |
580 </xsl:when> | |
581 <xsl:otherwise> | |
582 <xsl:value-of select="$number.separator"/> | |
583 </xsl:otherwise> | |
584 </xsl:choose> | |
585 | |
586 <xsl:choose> | |
587 <xsl:when test="@zone and string(@zone)"> | |
588 <xsl:call-template name="reference"> | |
589 <xsl:with-param name="zones" select="normalize-space(@zone)"/> | |
590 <xsl:with-param name="position" select="position()"/> | |
591 <xsl:with-param name="scope" select="$scope"/> | |
592 <xsl:with-param name="role" select="$role"/> | |
593 <xsl:with-param name="type" select="$type"/> | |
594 </xsl:call-template> | |
595 </xsl:when> | |
596 <xsl:otherwise> | |
597 <a> | |
598 <xsl:apply-templates select="." mode="class.attribute"/> | |
599 <xsl:variable name="title"> | |
600 <xsl:choose> | |
601 <xsl:when test="§ion;/titleabbrev and $index.prefer.titleabbrev
!= 0"> | |
602 <xsl:apply-templates select="§ion;" mode="titleabbrev.markup"/
> | |
603 </xsl:when> | |
604 <xsl:otherwise> | |
605 <xsl:apply-templates select="§ion;" mode="title.markup"/> | |
606 </xsl:otherwise> | |
607 </xsl:choose> | |
608 </xsl:variable> | |
609 | |
610 <xsl:attribute name="href"> | |
611 <xsl:choose> | |
612 <xsl:when test="$index.links.to.section = 1"> | |
613 <xsl:call-template name="href.target"> | |
614 <xsl:with-param name="object" select="§ion;"/> | |
615 <xsl:with-param name="context" | |
616 select="(//index[&scope;] | //setindex[&scope;])
[1]"/> | |
617 </xsl:call-template> | |
618 </xsl:when> | |
619 <xsl:otherwise> | |
620 <xsl:call-template name="href.target"> | |
621 <xsl:with-param name="object" select="."/> | |
622 <xsl:with-param name="context" | |
623 select="(//index[&scope;] | //setindex[&scope;])
[1]"/> | |
624 </xsl:call-template> | |
625 </xsl:otherwise> | |
626 </xsl:choose> | |
627 | |
628 </xsl:attribute> | |
629 | |
630 <xsl:value-of select="$title"/> <!-- text only --> | |
631 </a> | |
632 | |
633 <xsl:variable name="id" select="(@id|@xml:id)[1]"/> | |
634 <xsl:if test="key('endofrange', $id)[&scope;]"> | |
635 <xsl:apply-templates select="key('endofrange', $id)[&scope;][last()]" | |
636 mode="reference"> | |
637 <xsl:with-param name="position" select="position()"/> | |
638 <xsl:with-param name="scope" select="$scope"/> | |
639 <xsl:with-param name="role" select="$role"/> | |
640 <xsl:with-param name="type" select="$type"/> | |
641 <xsl:with-param name="separator" select="$range.separator"/> | |
642 </xsl:apply-templates> | |
643 </xsl:if> | |
644 </xsl:otherwise> | |
645 </xsl:choose> | |
646 </xsl:template> | |
647 | |
648 <xsl:template name="reference"> | |
649 <xsl:param name="scope" select="."/> | |
650 <xsl:param name="role" select="''"/> | |
651 <xsl:param name="type" select="''"/> | |
652 <xsl:param name="zones"/> | |
653 | |
654 <xsl:choose> | |
655 <xsl:when test="contains($zones, ' ')"> | |
656 <xsl:variable name="zone" select="substring-before($zones, ' ')"/> | |
657 <xsl:variable name="target" select="key('sections', $zone)"/> | |
658 | |
659 <a> | |
660 <xsl:apply-templates select="." mode="class.attribute"/> | |
661 <xsl:call-template name="id.attribute"/> | |
662 <xsl:attribute name="href"> | |
663 <xsl:call-template name="href.target"> | |
664 <xsl:with-param name="object" select="$target[1]"/> | |
665 <xsl:with-param name="context" select="//index[&scope;][1]"/> | |
666 </xsl:call-template> | |
667 </xsl:attribute> | |
668 <xsl:apply-templates select="$target[1]" mode="index-title-content"/> | |
669 </a> | |
670 <xsl:text>, </xsl:text> | |
671 <xsl:call-template name="reference"> | |
672 <xsl:with-param name="zones" select="substring-after($zones, ' ')"/> | |
673 <xsl:with-param name="position" select="position()"/> | |
674 <xsl:with-param name="scope" select="$scope"/> | |
675 <xsl:with-param name="role" select="$role"/> | |
676 <xsl:with-param name="type" select="$type"/> | |
677 </xsl:call-template> | |
678 </xsl:when> | |
679 <xsl:otherwise> | |
680 <xsl:variable name="zone" select="$zones"/> | |
681 <xsl:variable name="target" select="key('sections', $zone)"/> | |
682 | |
683 <a> | |
684 <xsl:apply-templates select="." mode="class.attribute"/> | |
685 <xsl:call-template name="id.attribute"/> | |
686 <xsl:attribute name="href"> | |
687 <xsl:call-template name="href.target"> | |
688 <xsl:with-param name="object" select="$target[1]"/> | |
689 <xsl:with-param name="context" select="//index[&scope;][1]"/> | |
690 </xsl:call-template> | |
691 </xsl:attribute> | |
692 <xsl:apply-templates select="$target[1]" mode="index-title-content"/> | |
693 </a> | |
694 </xsl:otherwise> | |
695 </xsl:choose> | |
696 </xsl:template> | |
697 | |
698 <xsl:template match="indexterm" mode="index-see"> | |
699 <xsl:param name="scope" select="."/> | |
700 <xsl:param name="role" select="''"/> | |
701 <xsl:param name="type" select="''"/> | |
702 | |
703 <xsl:text> (</xsl:text> | |
704 <xsl:call-template name="gentext"> | |
705 <xsl:with-param name="key" select="'see'"/> | |
706 </xsl:call-template> | |
707 <xsl:text> </xsl:text> | |
708 <xsl:value-of select="see"/> | |
709 <xsl:text>)</xsl:text> | |
710 </xsl:template> | |
711 | |
712 <xsl:template match="indexterm" mode="index-seealso"> | |
713 <xsl:param name="scope" select="."/> | |
714 <xsl:param name="role" select="''"/> | |
715 <xsl:param name="type" select="''"/> | |
716 | |
717 <xsl:for-each select="seealso"> | |
718 <xsl:sort select="translate(., &lowercase;, &uppercase;)"/> | |
719 <dt> | |
720 <xsl:text>(</xsl:text> | |
721 <xsl:call-template name="gentext"> | |
722 <xsl:with-param name="key" select="'seealso'"/> | |
723 </xsl:call-template> | |
724 <xsl:text> </xsl:text> | |
725 <xsl:value-of select="."/> | |
726 <xsl:text>)</xsl:text> | |
727 </dt> | |
728 <xsl:if test="$div.element = 'section'"> | |
729 <dd></dd> | |
730 </xsl:if> | |
731 </xsl:for-each> | |
732 </xsl:template> | |
733 | |
734 <xsl:template match="*" mode="index-title-content"> | |
735 <xsl:variable name="title"> | |
736 <xsl:apply-templates select="§ion;" mode="title.markup"/> | |
737 </xsl:variable> | |
738 | |
739 <xsl:value-of select="$title"/> | |
740 </xsl:template> | |
741 | |
742 <xsl:template name="index.separator"> | |
743 <xsl:param name="key" select="''"/> | |
744 <xsl:param name="lang"> | |
745 <xsl:call-template name="l10n.language"/> | |
746 </xsl:param> | |
747 | |
748 <xsl:choose> | |
749 <xsl:when test="$key = 'index.term.separator'"> | |
750 <xsl:choose> | |
751 <!-- Use the override if not blank --> | |
752 <xsl:when test="$index.term.separator != ''"> | |
753 <xsl:copy-of select="$index.term.separator"/> | |
754 </xsl:when> | |
755 <xsl:otherwise> | |
756 <xsl:call-template name="gentext.template"> | |
757 <xsl:with-param name="lang" select="$lang"/> | |
758 <xsl:with-param name="context">index</xsl:with-param> | |
759 <xsl:with-param name="name">term-separator</xsl:with-param> | |
760 </xsl:call-template> | |
761 </xsl:otherwise> | |
762 </xsl:choose> | |
763 </xsl:when> | |
764 <xsl:when test="$key = 'index.number.separator'"> | |
765 <xsl:choose> | |
766 <!-- Use the override if not blank --> | |
767 <xsl:when test="$index.number.separator != ''"> | |
768 <xsl:copy-of select="$index.number.separator"/> | |
769 </xsl:when> | |
770 <xsl:otherwise> | |
771 <xsl:call-template name="gentext.template"> | |
772 <xsl:with-param name="lang" select="$lang"/> | |
773 <xsl:with-param name="context">index</xsl:with-param> | |
774 <xsl:with-param name="name">number-separator</xsl:with-param> | |
775 </xsl:call-template> | |
776 </xsl:otherwise> | |
777 </xsl:choose> | |
778 </xsl:when> | |
779 <xsl:when test="$key = 'index.range.separator'"> | |
780 <xsl:choose> | |
781 <!-- Use the override if not blank --> | |
782 <xsl:when test="$index.range.separator != ''"> | |
783 <xsl:copy-of select="$index.range.separator"/> | |
784 </xsl:when> | |
785 <xsl:otherwise> | |
786 <xsl:call-template name="gentext.template"> | |
787 <xsl:with-param name="lang" select="$lang"/> | |
788 <xsl:with-param name="context">index</xsl:with-param> | |
789 <xsl:with-param name="name">range-separator</xsl:with-param> | |
790 </xsl:call-template> | |
791 </xsl:otherwise> | |
792 </xsl:choose> | |
793 </xsl:when> | |
794 </xsl:choose> | |
795 </xsl:template> | |
796 | |
797 </xsl:stylesheet> | |
OLD | NEW |