| 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 6910 2007-06-28 23:23:30Z xmldoc $ |
| 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;, §ion.id;)"/> |
| 61 |
|
| 62 |
<xsl:key name="see-also" |
| 63 |
match="indexterm[seealso]" |
| 64 |
use="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, seealso)"/> |
| 65 |
|
| 66 |
<xsl:key name="see" |
| 67 |
match="indexterm[see]" |
| 68 |
use="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, see)"/> |
| 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 |
<div class="indexdiv"> |
| 130 |
<h3> |
| 131 |
<xsl:call-template name="gentext"> |
| 132 |
<xsl:with-param name="key" select="'index symbols'"/> |
| 133 |
</xsl:call-template> |
| 134 |
</h3> |
| 135 |
<dl> |
| 136 |
<xsl:apply-templates select="$others[count(.|key('primary', |
| 137 |
&primary;)[&scope;][1]) = 1]" |
| 138 |
mode="index-symbol-div"> |
| 139 |
<xsl:with-param name="position" select="position()"/> |
| 140 |
<xsl:with-param name="scope" select="$scope"/> |
| 141 |
<xsl:with-param name="role" select="$role"/> |
| 142 |
<xsl:with-param name="type" select="$type"/> |
| 143 |
<xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/> |
| 144 |
</xsl:apply-templates> |
| 145 |
</dl> |
| 146 |
</div> |
| 147 |
</xsl:if> |
| 148 |
|
| 149 |
<xsl:apply-templates select="$alphabetical[count(.|key('letter', |
| 150 |
translate(substring(&primary;, 1, 1), |
| 151 |
&lowercase;,&uppercase;))[&scope;][1]) = 1]" |
| 152 |
mode="index-div-basic"> |
| 153 |
<xsl:with-param name="position" select="position()"/> |
| 154 |
<xsl:with-param name="scope" select="$scope"/> |
| 155 |
<xsl:with-param name="role" select="$role"/> |
| 156 |
<xsl:with-param name="type" select="$type"/> |
| 157 |
<xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/> |
| 158 |
</xsl:apply-templates> |
| 159 |
</div> |
| 160 |
</xsl:template> |
| 161 |
|
| 162 |
<!-- This template not used if html/autoidx-kosek.xsl is imported --> |
| 163 |
<xsl:template name="generate-kosek-index"> |
| 164 |
<xsl:param name="scope" select="NOTANODE"/> |
| 165 |
|
| 166 |
<xsl:variable name="vendor" select="system-property('xsl:vendor')"/> |
| 167 |
<xsl:if test="contains($vendor, 'libxslt')"> |
| 168 |
<xsl:message terminate="yes"> |
| 169 |
<xsl:text>ERROR: the 'kosek' index method does not </xsl:text> |
| 170 |
<xsl:text>work with the xsltproc XSLT processor.</xsl:text> |
| 171 |
</xsl:message> |
| 172 |
</xsl:if> |
| 173 |
|
| 174 |
|
| 175 |
<xsl:if test="not(function-available('exslt:node-set') or |
| 176 |
function-available('exslt:nodeSet'))"> |
| 177 |
<xsl:message terminate="yes"> |
| 178 |
<xsl:text>ERROR: the 'kosek' index method requires the </xsl:text> |
| 179 |
<xsl:text>exslt:node-set() function. Use a processor that </xsl:text> |
| 180 |
<xsl:text>has it, or use a different index method.</xsl:text> |
| 181 |
</xsl:message> |
| 182 |
</xsl:if> |
| 183 |
|
| 184 |
<xsl:if test="$kosek.imported = 0"> |
| 185 |
<xsl:message terminate="yes"> |
| 186 |
<xsl:text>ERROR: the 'kosek' index method requires the
</xsl:text> |
| 187 |
<xsl:text>kosek index extensions be imported:
</xsl:text> |
| 188 |
<xsl:text> xsl:import href="html/autoidx-kosek.xsl"</xsl:text> |
| 189 |
</xsl:message> |
| 190 |
</xsl:if> |
| 191 |
|
| 192 |
</xsl:template> |
| 193 |
|
| 194 |
<!-- This template not used if html/autoidx-kimber.xsl is imported --> |
| 195 |
<xsl:template name="generate-kimber-index"> |
| 196 |
<xsl:param name="scope" select="NOTANODE"/> |
| 197 |
|
| 198 |
<xsl:variable name="vendor" select="system-property('xsl:vendor')"/> |
| 199 |
<xsl:if test="not(contains($vendor, 'SAXON '))"> |
| 200 |
<xsl:message terminate="yes"> |
| 201 |
<xsl:text>ERROR: the 'kimber' index method requires the </xsl:text> |
| 202 |
<xsl:text>Saxon version 6 or 8 XSLT processor.</xsl:text> |
| 203 |
</xsl:message> |
| 204 |
</xsl:if> |
| 205 |
|
| 206 |
<xsl:if test="$kimber.imported = 0"> |
| 207 |
<xsl:message terminate="yes"> |
| 208 |
<xsl:text>ERROR: the 'kimber' index method requires the
</xsl:text> |
| 209 |
<xsl:text>kimber index extensions be imported:
</xsl:text> |
| 210 |
<xsl:text> xsl:import href="html/autoidx-kimber.xsl"</xsl:text> |
| 211 |
</xsl:message> |
| 212 |
</xsl:if> |
| 213 |
|
| 214 |
</xsl:template> |
| 215 |
|
| 216 |
<xsl:template match="indexterm" mode="index-div-basic"> |
| 217 |
<xsl:param name="scope" select="."/> |
| 218 |
<xsl:param name="role" select="''"/> |
| 219 |
<xsl:param name="type" select="''"/> |
| 220 |
|
| 221 |
<xsl:variable name="key" |
| 222 |
select="translate(substring(&primary;, 1, 1), |
| 223 |
&lowercase;,&uppercase;)"/> |
| 224 |
|
| 225 |
<xsl:if test="key('letter', $key)[&scope;] |
| 226 |
[count(.|key('primary', &primary;)[&scope;][1]) = 1]"> |
| 227 |
<div class="indexdiv"> |
| 228 |
<xsl:if test="contains(concat(&lowercase;, &uppercase;), $key)"> |
| 229 |
<h3> |
| 230 |
<xsl:value-of select="translate($key, &lowercase;, &uppercase;)"/> |
| 231 |
</h3> |
| 232 |
</xsl:if> |
| 233 |
<dl> |
| 234 |
<xsl:apply-templates select="key('letter', $key)[&scope;] |
| 235 |
[count(.|key('primary', &primary;) |
| 236 |
[&scope;][1])=1]" |
| 237 |
mode="index-primary"> |
| 238 |
<xsl:with-param name="position" select="position()"/> |
| 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:sort select="translate(&primary;, &lowercase;, &uppercase;)"/> |
| 243 |
</xsl:apply-templates> |
| 244 |
</dl> |
| 245 |
</div> |
| 246 |
</xsl:if> |
| 247 |
</xsl:template> |
| 248 |
|
| 249 |
<xsl:template match="indexterm" mode="index-symbol-div"> |
| 250 |
<xsl:param name="scope" select="/"/> |
| 251 |
<xsl:param name="role" select="''"/> |
| 252 |
<xsl:param name="type" select="''"/> |
| 253 |
|
| 254 |
<xsl:variable name="key" select="translate(substring(&primary;, 1, 1), |
| 255 |
&lowercase;,&uppercase;)"/> |
| 256 |
|
| 257 |
<xsl:apply-templates select="key('letter', $key) |
| 258 |
[&scope;][count(.|key('primary', &primary;)[1]) = 1]" |
| 259 |
mode="index-primary"> |
| 260 |
<xsl:with-param name="position" select="position()"/> |
| 261 |
<xsl:with-param name="scope" select="$scope"/> |
| 262 |
<xsl:with-param name="role" select="$role"/> |
| 263 |
<xsl:with-param name="type" select="$type"/> |
| 264 |
<xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/> |
| 265 |
</xsl:apply-templates> |
| 266 |
</xsl:template> |
| 267 |
|
| 268 |
<xsl:template match="indexterm" mode="index-primary"> |
| 269 |
<xsl:param name="scope" select="."/> |
| 270 |
<xsl:param name="role" select="''"/> |
| 271 |
<xsl:param name="type" select="''"/> |
| 272 |
|
| 273 |
<xsl:variable name="key" select="&primary;"/> |
| 274 |
<xsl:variable name="refs" select="key('primary', $key)[&scope;]"/> |
| 275 |
<dt> |
| 276 |
<xsl:value-of select="primary"/> |
| 277 |
<xsl:for-each select="$refs[generate-id() = generate-id(key('primary-section', concat($key, &sep;, §ion.id;))[&scope;][1])]"> |
| 278 |
<xsl:apply-templates select="." mode="reference"> |
| 279 |
<xsl:with-param name="position" select="position()"/> |
| 280 |
<xsl:with-param name="scope" select="$scope"/> |
| 281 |
<xsl:with-param name="role" select="$role"/> |
| 282 |
<xsl:with-param name="type" select="$type"/> |
| 283 |
</xsl:apply-templates> |
| 284 |
</xsl:for-each> |
| 285 |
|
| 286 |
<xsl:if test="$refs[not(secondary)]/*[self::see]"> |
| 287 |
<xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &sep;, &sep;, see))[&scope;][1])]" |
| 288 |
mode="index-see"> |
| 289 |
<xsl:with-param name="position" select="position()"/> |
| 290 |
<xsl:with-param name="scope" select="$scope"/> |
| 291 |
<xsl:with-param name="role" select="$role"/> |
| 292 |
<xsl:with-param name="type" select="$type"/> |
| 293 |
<xsl:sort select="translate(see, &lowercase;, &uppercase;)"/> |
| 294 |
</xsl:apply-templates> |
| 295 |
</xsl:if> |
| 296 |
</dt> |
| 297 |
<xsl:if test="$refs/secondary or $refs[not(secondary)]/*[self::seealso]"> |
| 298 |
<dd> |
| 299 |
<dl> |
| 300 |
<xsl:apply-templates select="$refs[generate-id() = generate-id(key('see-also', concat(&primary;, &sep;, &sep;, &sep;, seealso))[&scope;][1])]" |
| 301 |
mode="index-seealso"> |
| 302 |
<xsl:with-param name="position" select="position()"/> |
| 303 |
<xsl:with-param name="scope" select="$scope"/> |
| 304 |
<xsl:with-param name="role" select="$role"/> |
| 305 |
<xsl:with-param name="type" select="$type"/> |
| 306 |
<xsl:sort select="translate(seealso, &lowercase;, &uppercase;)"/> |
| 307 |
</xsl:apply-templates> |
| 308 |
<xsl:apply-templates select="$refs[secondary and count(.|key('secondary', concat($key, &sep;, &secondary;))[&scope;][1]) = 1]" |
| 309 |
mode="index-secondary"> |
| 310 |
<xsl:with-param name="position" select="position()"/> |
| 311 |
<xsl:with-param name="scope" select="$scope"/> |
| 312 |
<xsl:with-param name="role" select="$role"/> |
| 313 |
<xsl:with-param name="type" select="$type"/> |
| 314 |
<xsl:sort select="translate(&secondary;, &lowercase;, &uppercase;)"/> |
| 315 |
</xsl:apply-templates> |
| 316 |
</dl> |
| 317 |
</dd> |
| 318 |
</xsl:if> |
| 319 |
</xsl:template> |
| 320 |
|
| 321 |
<xsl:template match="indexterm" mode="index-secondary"> |
| 322 |
<xsl:param name="scope" select="."/> |
| 323 |
<xsl:param name="role" select="''"/> |
| 324 |
<xsl:param name="type" select="''"/> |
| 325 |
|
| 326 |
<xsl:variable name="key" select="concat(&primary;, &sep;, &secondary;)"/> |
| 327 |
<xsl:variable name="refs" select="key('secondary', $key)[&scope;]"/> |
| 328 |
<dt> |
| 329 |
<xsl:value-of select="secondary"/> |
| 330 |
<xsl:for-each select="$refs[generate-id() = generate-id(key('secondary-section', concat($key, &sep;, §ion.id;))[&scope;][1])]"> |
| 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 |
|
| 339 |
<xsl:if test="$refs[not(tertiary)]/*[self::see]"> |
| 340 |
<xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &secondary;, &sep;, &sep;, see))[&scope;][1])]" |
| 341 |
mode="index-see"> |
| 342 |
<xsl:with-param name="position" select="position()"/> |
| 343 |
<xsl:with-param name="scope" select="$scope"/> |
| 344 |
<xsl:with-param name="role" select="$role"/> |
| 345 |
<xsl:with-param name="type" select="$type"/> |
| 346 |
<xsl:sort select="translate(see, &lowercase;, &uppercase;)"/> |
| 347 |
</xsl:apply-templates> |
| 348 |
</xsl:if> |
| 349 |
</dt> |
| 350 |
<xsl:if test="$refs/tertiary or $refs[not(tertiary)]/*[self::seealso]"> |
| 351 |
<dd> |
| 352 |
<dl> |
| 353 |
<xsl:apply-templates select="$refs[generate-id() = generate-id(key('see-also', concat(&primary;, &sep;, &secondary;, &sep;, &sep;, seealso))[&scope;][1])]" |
| 354 |
mode="index-seealso"> |
| 355 |
<xsl:with-param name="position" select="position()"/> |
| 356 |
<xsl:with-param name="scope" select="$scope"/> |
| 357 |
<xsl:with-param name="role" select="$role"/> |
| 358 |
<xsl:with-param name="type" select="$type"/> |
| 359 |
<xsl:sort select="translate(seealso, &lowercase;, &uppercase;)"/> |
| 360 |
</xsl:apply-templates> |
| 361 |
<xsl:apply-templates select="$refs[tertiary and count(.|key('tertiary', concat($key, &sep;, &tertiary;))[&scope;][1]) = 1]" |
| 362 |
mode="index-tertiary"> |
| 363 |
<xsl:with-param name="position" select="position()"/> |
| 364 |
<xsl:with-param name="scope" select="$scope"/> |
| 365 |
<xsl:with-param name="role" select="$role"/> |
| 366 |
<xsl:with-param name="type" select="$type"/> |
| 367 |
<xsl:sort select="translate(&tertiary;, &lowercase;, &uppercase;)"/> |
| 368 |
</xsl:apply-templates> |
| 369 |
</dl> |
| 370 |
</dd> |
| 371 |
</xsl:if> |
| 372 |
</xsl:template> |
| 373 |
|
| 374 |
<xsl:template match="indexterm" mode="index-tertiary"> |
| 375 |
<xsl:param name="scope" select="."/> |
| 376 |
<xsl:param name="role" select="''"/> |
| 377 |
<xsl:param name="type" select="''"/> |
| 378 |
|
| 379 |
<xsl:variable name="key" select="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;)"/> |
| 380 |
<xsl:variable name="refs" select="key('tertiary', $key)[&scope;]"/> |
| 381 |
<dt> |
| 382 |
<xsl:value-of select="tertiary"/> |
| 383 |
<xsl:for-each select="$refs[generate-id() = generate-id(key('tertiary-section', concat($key, &sep;, §ion.id;))[&scope;][1])]"> |
| 384 |
<xsl:apply-templates select="." mode="reference"> |
| 385 |
<xsl:with-param name="position" select="position()"/> |
| 386 |
<xsl:with-param name="scope" select="$scope"/> |
| 387 |
<xsl:with-param name="role" select="$role"/> |
| 388 |
<xsl:with-param name="type" select="$type"/> |
| 389 |
</xsl:apply-templates> |
| 390 |
</xsl:for-each> |
| 391 |
|
| 392 |
<xsl:if test="$refs/see"> |
| 393 |
<xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, see))[&scope;][1])]" |
| 394 |
mode="index-see"> |
| 395 |
<xsl:with-param name="position" select="position()"/> |
| 396 |
<xsl:with-param name="scope" select="$scope"/> |
| 397 |
<xsl:with-param name="role" select="$role"/> |
| 398 |
<xsl:with-param name="type" select="$type"/> |
| 399 |
<xsl:sort select="translate(see, &lowercase;, &uppercase;)"/> |
| 400 |
</xsl:apply-templates> |
| 401 |
</xsl:if> |
| 402 |
</dt> |
| 403 |
<xsl:if test="$refs/seealso"> |
| 404 |
<dd> |
| 405 |
<dl> |
| 406 |
<xsl:apply-templates select="$refs[generate-id() = generate-id(key('see-also', concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, seealso))[&scope;][1])]" |
| 407 |
mode="index-seealso"> |
| 408 |
<xsl:with-param name="position" select="position()"/> |
| 409 |
<xsl:with-param name="scope" select="$scope"/> |
| 410 |
<xsl:with-param name="role" select="$role"/> |
| 411 |
<xsl:with-param name="type" select="$type"/> |
| 412 |
<xsl:sort select="translate(seealso, &lowercase;, &uppercase;)"/> |
| 413 |
</xsl:apply-templates> |
| 414 |
</dl> |
| 415 |
</dd> |
| 416 |
</xsl:if> |
| 417 |
</xsl:template> |
| 418 |
|
| 419 |
<xsl:template match="indexterm" mode="reference"> |
| 420 |
<xsl:param name="scope" select="."/> |
| 421 |
<xsl:param name="role" select="''"/> |
| 422 |
<xsl:param name="type" select="''"/> |
| 423 |
<xsl:param name="position"/> |
| 424 |
|
| 425 |
<xsl:variable name="term.separator"> |
| 426 |
<xsl:call-template name="index.separator"> |
| 427 |
<xsl:with-param name="key" select="'index.term.separator'"/> |
| 428 |
</xsl:call-template> |
| 429 |
</xsl:variable> |
| 430 |
|
| 431 |
<xsl:variable name="number.separator"> |
| 432 |
<xsl:call-template name="index.separator"> |
| 433 |
<xsl:with-param name="key" select="'index.number.separator'"/> |
| 434 |
</xsl:call-template> |
| 435 |
</xsl:variable> |
| 436 |
|
| 437 |
<xsl:variable name="range.separator"> |
| 438 |
<xsl:call-template name="index.separator"> |
| 439 |
<xsl:with-param name="key" select="'index.range.separator'"/> |
| 440 |
</xsl:call-template> |
| 441 |
</xsl:variable> |
| 442 |
|
| 443 |
<xsl:choose> |
| 444 |
<xsl:when test="$position = 1"> |
| 445 |
<xsl:value-of select="$term.separator"/> |
| 446 |
</xsl:when> |
| 447 |
<xsl:otherwise> |
| 448 |
<xsl:value-of select="$number.separator"/> |
| 449 |
</xsl:otherwise> |
| 450 |
</xsl:choose> |
| 451 |
|
| 452 |
<xsl:choose> |
| 453 |
<xsl:when test="@zone and string(@zone)"> |
| 454 |
<xsl:call-template name="reference"> |
| 455 |
<xsl:with-param name="zones" select="normalize-space(@zone)"/> |
| 456 |
<xsl:with-param name="position" select="position()"/> |
| 457 |
<xsl:with-param name="scope" select="$scope"/> |
| 458 |
<xsl:with-param name="role" select="$role"/> |
| 459 |
<xsl:with-param name="type" select="$type"/> |
| 460 |
</xsl:call-template> |
| 461 |
</xsl:when> |
| 462 |
<xsl:otherwise> |
| 463 |
<a> |
| 464 |
<xsl:apply-templates select="." mode="class.attribute"/> |
| 465 |
<xsl:variable name="title"> |
| 466 |
<xsl:choose> |
| 467 |
<xsl:when test="§ion;/titleabbrev and $index.prefer.titleabbrev != 0"> |
| 468 |
<xsl:apply-templates select="§ion;" mode="titleabbrev.markup"/> |
| 469 |
</xsl:when> |
| 470 |
<xsl:otherwise> |
| 471 |
<xsl:apply-templates select="§ion;" mode="title.markup"/> |
| 472 |
</xsl:otherwise> |
| 473 |
</xsl:choose> |
| 474 |
</xsl:variable> |
| 475 |
|
| 476 |
<xsl:attribute name="href"> |
| 477 |
<xsl:call-template name="href.target"> |
| 478 |
<xsl:with-param name="object" select="§ion;"/> |
| 479 |
<xsl:with-param name="context" select="//index[&scope;][1]"/> |
| 480 |
</xsl:call-template> |
| 481 |
</xsl:attribute> |
| 482 |
|
| 483 |
<xsl:value-of select="$title"/> <!-- text only --> |
| 484 |
</a> |
| 485 |
|
| 486 |
<xsl:variable name="id" select="(@id|@xml:id)[1]"/> |
| 487 |
<xsl:if test="key('endofrange', $id)[&scope;]"> |
| 488 |
<xsl:apply-templates select="key('endofrange', $id)[&scope;][last()]" |
| 489 |
mode="reference"> |
| 490 |
<xsl:with-param name="position" select="position()"/> |
| 491 |
<xsl:with-param name="scope" select="$scope"/> |
| 492 |
<xsl:with-param name="role" select="$role"/> |
| 493 |
<xsl:with-param name="type" select="$type"/> |
| 494 |
<xsl:with-param name="separator" select="$range.separator"/> |
| 495 |
</xsl:apply-templates> |
| 496 |
</xsl:if> |
| 497 |
</xsl:otherwise> |
| 498 |
</xsl:choose> |
| 499 |
</xsl:template> |
| 500 |
|
| 501 |
<xsl:template name="reference"> |
| 502 |
<xsl:param name="scope" select="."/> |
| 503 |
<xsl:param name="role" select="''"/> |
| 504 |
<xsl:param name="type" select="''"/> |
| 505 |
<xsl:param name="zones"/> |
| 506 |
|
| 507 |
<xsl:choose> |
| 508 |
<xsl:when test="contains($zones, ' ')"> |
| 509 |
<xsl:variable name="zone" select="substring-before($zones, ' ')"/> |
| 510 |
<xsl:variable name="target" select="key('sections', $zone)"/> |
| 511 |
|
| 512 |
<a> |
| 513 |
<xsl:apply-templates select="." mode="class.attribute"/> |
| 514 |
<xsl:attribute name="href"> |
| 515 |
<xsl:call-template name="href.target"> |
| 516 |
<xsl:with-param name="object" select="$target[1]"/> |
| 517 |
<xsl:with-param name="context" select="//index[&scope;][1]"/> |
| 518 |
</xsl:call-template> |
| 519 |
</xsl:attribute> |
| 520 |
<xsl:apply-templates select="$target[1]" mode="index-title-content"/> |
| 521 |
</a> |
| 522 |
<xsl:text>, </xsl:text> |
| 523 |
<xsl:call-template name="reference"> |
| 524 |
<xsl:with-param name="zones" select="substring-after($zones, ' ')"/> |
| 525 |
<xsl:with-param name="position" select="position()"/> |
| 526 |
<xsl:with-param name="scope" select="$scope"/> |
| 527 |
<xsl:with-param name="role" select="$role"/> |
| 528 |
<xsl:with-param name="type" select="$type"/> |
| 529 |
</xsl:call-template> |
| 530 |
</xsl:when> |
| 531 |
<xsl:otherwise> |
| 532 |
<xsl:variable name="zone" select="$zones"/> |
| 533 |
<xsl:variable name="target" select="key('sections', $zone)"/> |
| 534 |
|
| 535 |
<a> |
| 536 |
<xsl:apply-templates select="." mode="class.attribute"/> |
| 537 |
<xsl:attribute name="href"> |
| 538 |
<xsl:call-template name="href.target"> |
| 539 |
<xsl:with-param name="object" select="$target[1]"/> |
| 540 |
<xsl:with-param name="context" select="//index[&scope;][1]"/> |
| 541 |
</xsl:call-template> |
| 542 |
</xsl:attribute> |
| 543 |
<xsl:apply-templates select="$target[1]" mode="index-title-content"/> |
| 544 |
</a> |
| 545 |
</xsl:otherwise> |
| 546 |
</xsl:choose> |
| 547 |
</xsl:template> |
| 548 |
|
| 549 |
<xsl:template match="indexterm" mode="index-see"> |
| 550 |
<xsl:param name="scope" select="."/> |
| 551 |
<xsl:param name="role" select="''"/> |
| 552 |
<xsl:param name="type" select="''"/> |
| 553 |
|
| 554 |
<xsl:text> (</xsl:text> |
| 555 |
<xsl:call-template name="gentext"> |
| 556 |
<xsl:with-param name="key" select="'see'"/> |
| 557 |
</xsl:call-template> |
| 558 |
<xsl:text> </xsl:text> |
| 559 |
<xsl:value-of select="see"/> |
| 560 |
<xsl:text>)</xsl:text> |
| 561 |
</xsl:template> |
| 562 |
|
| 563 |
<xsl:template match="indexterm" mode="index-seealso"> |
| 564 |
<xsl:param name="scope" select="."/> |
| 565 |
<xsl:param name="role" select="''"/> |
| 566 |
<xsl:param name="type" select="''"/> |
| 567 |
|
| 568 |
<xsl:for-each select="seealso"> |
| 569 |
<xsl:sort select="translate(., &lowercase;, &uppercase;)"/> |
| 570 |
<dt> |
| 571 |
<xsl:text>(</xsl:text> |
| 572 |
<xsl:call-template name="gentext"> |
| 573 |
<xsl:with-param name="key" select="'seealso'"/> |
| 574 |
</xsl:call-template> |
| 575 |
<xsl:text> </xsl:text> |
| 576 |
<xsl:value-of select="."/> |
| 577 |
<xsl:text>)</xsl:text> |
| 578 |
</dt> |
| 579 |
</xsl:for-each> |
| 580 |
</xsl:template> |
| 581 |
|
| 582 |
<xsl:template match="*" mode="index-title-content"> |
| 583 |
<xsl:variable name="title"> |
| 584 |
<xsl:apply-templates select="§ion;" mode="title.markup"/> |
| 585 |
</xsl:variable> |
| 586 |
|
| 587 |
<xsl:value-of select="$title"/> |
| 588 |
</xsl:template> |
| 589 |
|
| 590 |
<xsl:template name="index.separator"> |
| 591 |
<xsl:param name="key" select="''"/> |
| 592 |
<xsl:param name="lang"> |
| 593 |
<xsl:call-template name="l10n.language"/> |
| 594 |
</xsl:param> |
| 595 |
|
| 596 |
<xsl:choose> |
| 597 |
<xsl:when test="$key = 'index.term.separator'"> |
| 598 |
<xsl:choose> |
| 599 |
<!-- Use the override if not blank --> |
| 600 |
<xsl:when test="$index.term.separator != ''"> |
| 601 |
<xsl:copy-of select="$index.term.separator"/> |
| 602 |
</xsl:when> |
| 603 |
<xsl:otherwise> |
| 604 |
<xsl:call-template name="gentext.template"> |
| 605 |
<xsl:with-param name="lang" select="$lang"/> |
| 606 |
<xsl:with-param name="context">index</xsl:with-param> |
| 607 |
<xsl:with-param name="name">term-separator</xsl:with-param> |
| 608 |
</xsl:call-template> |
| 609 |
</xsl:otherwise> |
| 610 |
</xsl:choose> |
| 611 |
</xsl:when> |
| 612 |
<xsl:when test="$key = 'index.number.separator'"> |
| 613 |
<xsl:choose> |
| 614 |
<!-- Use the override if not blank --> |
| 615 |
<xsl:when test="$index.number.separator != ''"> |
| 616 |
<xsl:copy-of select="$index.number.separator"/> |
| 617 |
</xsl:when> |
| 618 |
<xsl:otherwise> |
| 619 |
<xsl:call-template name="gentext.template"> |
| 620 |
<xsl:with-param name="lang" select="$lang"/> |
| 621 |
<xsl:with-param name="context">index</xsl:with-param> |
| 622 |
<xsl:with-param name="name">number-separator</xsl:with-param> |
| 623 |
</xsl:call-template> |
| 624 |
</xsl:otherwise> |
| 625 |
</xsl:choose> |
| 626 |
</xsl:when> |
| 627 |
<xsl:when test="$key = 'index.range.separator'"> |
| 628 |
<xsl:choose> |
| 629 |
<!-- Use the override if not blank --> |
| 630 |
<xsl:when test="$index.range.separator != ''"> |
| 631 |
<xsl:copy-of select="$index.range.separator"/> |
| 632 |
</xsl:when> |
| 633 |
<xsl:otherwise> |
| 634 |
<xsl:call-template name="gentext.template"> |
| 635 |
<xsl:with-param name="lang" select="$lang"/> |
| 636 |
<xsl:with-param name="context">index</xsl:with-param> |
| 637 |
<xsl:with-param name="name">range-separator</xsl:with-param> |
| 638 |
</xsl:call-template> |
| 639 |
</xsl:otherwise> |
| 640 |
</xsl:choose> |
| 641 |
</xsl:when> |
| 642 |
</xsl:choose> |
| 643 |
</xsl:template> |
| 644 |
|
| 645 |
</xsl:stylesheet> |