2 <!DOCTYPE xsl:stylesheet [
3 <!ENTITY % common.entities SYSTEM "../common/entities.ent">
6 <!-- Documents using the kimber index method must have a lang attribute -->
7 <!-- Only one of these should be present in the entity -->
8 <!ENTITY lang 'concat(/*/@lang, /*/@xml:lang)'>
11 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
12 xmlns:d="http://docbook.org/ns/docbook"
13 xmlns:fo="http://www.w3.org/1999/XSL/Format"
14 xmlns:k="java:com.isogen.saxoni18n.Saxoni18nService"
15 exclude-result-prefixes="k d"
18 <!-- ********************************************************************
20 This file is part of the DocBook XSL Stylesheet distribution.
21 See ../README or http://cdn.docbook.org/release/xsl for copyright
22 copyright and other information.
24 ******************************************************************** -->
26 <!-- ==================================================================== -->
27 <!-- The "kimber" method contributed by Eliot Kimber of Innodata Isogen. -->
28 <!-- ==================================================================== -->
29 <!-- *** THIS MODULE ONLY WORKS WITH SAXON 6 OR SAXON 8 *** -->
30 <!-- ==================================================================== -->
32 <xsl:include href="../common/autoidx-kimber.xsl"/>
34 <!-- Java sort apparently works only on lang part, not country -->
35 <xsl:param name="sort.lang">
37 <xsl:when test="contains(⟨, '-')">
38 <xsl:value-of select="substring-before(⟨, '-')"/>
40 <xsl:when test="contains(⟨, '_')">
41 <xsl:value-of select="substring-before(⟨, '_')"/>
44 <xsl:value-of select="⟨"/>
49 <xsl:template name="generate-kimber-index">
50 <xsl:param name="scope" select="NOTANODE"/>
52 <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
53 <xsl:if test="not(contains($vendor, 'SAXON '))">
54 <xsl:message terminate="yes">
55 <xsl:text>ERROR: the 'kimber' index method requires the </xsl:text>
56 <xsl:text>Saxon version 6 or 8 XSLT processor.</xsl:text>
60 <xsl:if test="not(function-available('k:getIndexGroupKey'))">
61 <xsl:message terminate="yes">
62 <xsl:text>ERROR: the 'kimber' index method requires the </xsl:text>
63 <xsl:text>Innodata Isogen 
Java extensions for </xsl:text>
64 <xsl:text>internationalized indexes. 
Install those </xsl:text>
65 <xsl:text>extensions, or use a different index method.
</xsl:text>
66 <xsl:text>For more information, see:
</xsl:text>
67 <xsl:text>http://www.innodata-isogen.com/knowledge_center/tools_downloads/i18nsupport</xsl:text>
71 <xsl:variable name="role">
72 <xsl:if test="$index.on.role != 0">
73 <xsl:value-of select="@role"/>
77 <xsl:variable name="type">
78 <xsl:if test="$index.on.type != 0">
79 <xsl:value-of select="@type"/>
83 <xsl:variable name="terms"
84 select="//d:indexterm[count(.|key('k-group',
85 k:getIndexGroupKey(⟨, &primary;))
87 and not(@class = 'endofrange')]"/>
89 <xsl:variable name="alphabetical"
90 select="$terms[not(starts-with(
91 k:getIndexGroupKey(⟨, &primary;),
95 <xsl:variable name="others"
96 select="$terms[starts-with(
97 k:getIndexGroupKey(⟨, &primary;),
102 <xsl:if test="$others">
103 <xsl:call-template name="indexdiv.title">
104 <xsl:with-param name="titlecontent">
105 <xsl:call-template name="gentext">
106 <xsl:with-param name="key" select="'index symbols'"/>
112 <xsl:apply-templates select="$others"
113 mode="index-symbol-div">
114 <xsl:with-param name="scope" select="$scope"/>
115 <xsl:with-param name="role" select="$role"/>
116 <xsl:with-param name="type" select="$type"/>
117 <xsl:sort lang="{$sort.lang}"
118 select="k:getIndexGroupSortKey(⟨,
119 k:getIndexGroupKey(⟨, &primary;))"/>
120 </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="d: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', $key)[&scope;]
149 [count(.|key('primary', &primary;)[&scope;][1]) = 1]">
151 <xsl:call-template name="indexdiv.title">
152 <xsl:with-param name="titlecontent">
153 <xsl:value-of select="$label"/>
157 <xsl:apply-templates select="key('k-group', $key)[&scope;]
158 [count(.|key('primary', &primary;)[&scope;]
160 mode="index-primary">
161 <xsl:sort select="&primary;" lang="{$sort.lang}"/>
162 <xsl:with-param name="scope" select="$scope"/>
163 <xsl:with-param name="role" select="$role"/>
164 <xsl:with-param name="type" select="$type"/>
165 </xsl:apply-templates>