2 <!DOCTYPE xsl:stylesheet [
4 <!ENTITY primary 'normalize-space(concat(primary/@sortas, primary[not(@sortas) or @sortas = ""]))'>
5 <!ENTITY secondary 'normalize-space(concat(secondary/@sortas, secondary[not(@sortas) or @sortas = ""]))'>
6 <!ENTITY tertiary 'normalize-space(concat(tertiary/@sortas, tertiary[not(@sortas) or @sortas = ""]))'>
8 <!-- Documents using the kimber index method must have a lang attribute -->
9 <!-- Only one of these should be present in the entity -->
10 <!ENTITY lang 'concat(/*/@lang, /*/@xml:lang)'>
12 <!ENTITY scope 'count(ancestor::node()|$scope) = count(ancestor::node()) and ($role = @role or $type = @type or (string-length($role) = 0 and string-length($type) = 0))'>
14 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
15 xmlns:k="http://www.isogen.com/functions/com.isogen.saxoni18n.Saxoni18nService"
16 exclude-result-prefixes="k"
19 <!-- ********************************************************************
20 $Id: autoidx-kimber.xsl 6910 2007-06-28 23:23:30Z xmldoc $
21 ********************************************************************
23 This file is part of the XSL DocBook Stylesheet distribution.
24 See ../README or http://docbook.sf.net/release/xsl/current/ for
25 copyright and other information.
27 ******************************************************************** -->
29 <!-- ==================================================================== -->
30 <!-- The "kimber" method contributed by Eliot Kimber of Innodata Isogen. -->
31 <!-- ==================================================================== -->
32 <!-- *** THIS MODULE ONLY WORKS WITH SAXON 6 OR SAXON 8 *** -->
33 <!-- ==================================================================== -->
36 <xsl:include href="../common/autoidx-kimber.xsl"/>
38 <!-- Java sort apparently works only on lang part, not country -->
39 <xsl:param name="sort.lang">
41 <xsl:when test="contains(⟨, '-')">
42 <xsl:value-of select="substring-before(⟨, '-')"/>
44 <xsl:when test="contains(⟨, '_')">
45 <xsl:value-of select="substring-before(⟨, '_')"/>
48 <xsl:value-of select="⟨"/>
53 <xsl:template name="generate-kimber-index">
54 <xsl:param name="scope" select="NOTANODE"/>
56 <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
57 <xsl:if test="not(contains($vendor, 'SAXON '))">
58 <xsl:message terminate="yes">
59 <xsl:text>ERROR: the 'kimber' index method requires the </xsl:text>
60 <xsl:text>Saxon version 6 or 8 XSLT processor.</xsl:text>
64 <xsl:if test="not(function-available('k:getIndexGroupKey'))">
65 <xsl:message terminate="yes">
66 <xsl:text>ERROR: the 'kimber' index method requires the </xsl:text>
67 <xsl:text>Innodata Isogen 
Java extensions for </xsl:text>
68 <xsl:text>internationalized indexes. 
Install those </xsl:text>
69 <xsl:text>extensions, or use a different index method.
</xsl:text>
70 <xsl:text>For more information, see:
</xsl:text>
71 <xsl:text>http://www.innodata-isogen.com/knowledge_center/tools_downloads/i18nsupport</xsl:text>
75 <xsl:variable name="role">
76 <xsl:if test="$index.on.role != 0">
77 <xsl:value-of select="@role"/>
81 <xsl:variable name="type">
82 <xsl:if test="$index.on.type != 0">
83 <xsl:value-of select="@type"/>
87 <xsl:variable name="terms"
88 select="//indexterm[count(.|key('k-group', k:getIndexGroupKey(⟨, &primary;))[&scope;][1]) = 1 and not(@class = 'endofrange')]"/>
90 <xsl:variable name="alphabetical"
91 select="$terms[not(starts-with(
92 k:getIndexGroupKey(⟨, &primary;),
96 <xsl:variable name="others"
97 select="$terms[starts-with(
98 k:getIndexGroupKey(⟨, &primary;),
103 <xsl:if test="$others">
104 <div class="indexdev">
106 <xsl:call-template name="gentext">
107 <xsl:with-param name="key" select="'index symbols'"/>
111 <xsl:apply-templates select="$others"
112 mode="index-symbol-div">
113 <xsl:with-param name="scope" select="$scope"/>
114 <xsl:with-param name="role" select="$role"/>
115 <xsl:with-param name="type" select="$type"/>
116 <xsl:sort lang="{$sort.lang}"
117 select="k:getIndexGroupSortKey(⟨,
118 k:getIndexGroupKey(⟨, &primary;))"/>
119 </xsl:apply-templates>
124 <xsl:apply-templates select="$alphabetical"
125 mode="index-div-kimber">
126 <xsl:with-param name="scope" select="$scope"/>
127 <xsl:with-param name="role" select="$role"/>
128 <xsl:with-param name="type" select="$type"/>
129 <xsl:sort lang="{$sort.lang}"
130 select="k:getIndexGroupSortKey(⟨,
131 k:getIndexGroupKey(⟨, &primary;))"/>
132 </xsl:apply-templates>
137 <xsl:template match="indexterm" mode="index-div-kimber">
138 <xsl:param name="scope" select="."/>
139 <xsl:param name="role" select="''"/>
140 <xsl:param name="type" select="''"/>
142 <xsl:variable name="key"
143 select="k:getIndexGroupKey(⟨, &primary;)"/>
145 <xsl:variable name="label"
146 select="k:getIndexGroupLabel(⟨, $key)"/>
148 <xsl:if test="key('k-group', $label)[&scope;][count(.|key('primary', &primary;)[&scope;][1]) = 1]">
149 <div class="indexdiv">
151 <xsl:value-of select="$label"/>
154 <xsl:apply-templates select="key('k-group', $key)[&scope;]
155 [count(.|key('primary', &primary;)[&scope;]
157 mode="index-primary">
158 <xsl:sort select="&primary;" lang="{$sort.lang}"/>
159 <xsl:with-param name="scope" select="$scope"/>
160 <xsl:with-param name="role" select="$role"/>
161 <xsl:with-param name="type" select="$type"/>
162 </xsl:apply-templates>