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:k="http://www.isogen.com/functions/com.isogen.saxoni18n.Saxoni18nService"
13 exclude-result-prefixes="k"
16 <!-- ********************************************************************
17 $Id: autoidx-kimber.xsl 8729 2010-07-15 16:43:56Z bobstayton $
18 ********************************************************************
20 This file is part of the XSL DocBook Stylesheet distribution.
21 See ../README or http://docbook.sf.net/release/xsl/current/ for
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 <!-- ==================================================================== -->
33 <xsl:include href="../common/autoidx-kimber.xsl"/>
35 <!-- Java sort apparently works only on lang part, not country -->
36 <xsl:param name="sort.lang">
38 <xsl:when test="contains(⟨, '-')">
39 <xsl:value-of select="substring-before(⟨, '-')"/>
41 <xsl:when test="contains(⟨, '_')">
42 <xsl:value-of select="substring-before(⟨, '_')"/>
45 <xsl:value-of select="⟨"/>
50 <xsl:template name="generate-kimber-index">
51 <xsl:param name="scope" select="NOTANODE"/>
53 <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
54 <xsl:if test="not(contains($vendor, 'SAXON '))">
55 <xsl:message terminate="yes">
56 <xsl:text>ERROR: the 'kimber' index method requires the </xsl:text>
57 <xsl:text>Saxon version 6 or 8 XSLT processor.</xsl:text>
61 <xsl:if test="not(function-available('k:getIndexGroupKey'))">
62 <xsl:message terminate="yes">
63 <xsl:text>ERROR: the 'kimber' index method requires the </xsl:text>
64 <xsl:text>Innodata Isogen 
Java extensions for </xsl:text>
65 <xsl:text>internationalized indexes. 
Install those </xsl:text>
66 <xsl:text>extensions, or use a different index method.
</xsl:text>
67 <xsl:text>For more information, see:
</xsl:text>
68 <xsl:text>http://www.innodata-isogen.com/knowledge_center/tools_downloads/i18nsupport</xsl:text>
72 <xsl:variable name="role">
73 <xsl:if test="$index.on.role != 0">
74 <xsl:value-of select="@role"/>
78 <xsl:variable name="type">
79 <xsl:if test="$index.on.type != 0">
80 <xsl:value-of select="@type"/>
84 <xsl:variable name="terms"
85 select="//indexterm[count(.|key('k-group', k:getIndexGroupKey(⟨, &primary;))[&scope;][1]) = 1 and not(@class = 'endofrange')]"/>
87 <xsl:variable name="alphabetical"
88 select="$terms[not(starts-with(
89 k:getIndexGroupKey(⟨, &primary;),
93 <xsl:variable name="others"
94 select="$terms[starts-with(
95 k:getIndexGroupKey(⟨, &primary;),
100 <xsl:if test="$others">
101 <div class="indexdev">
103 <xsl:call-template name="gentext">
104 <xsl:with-param name="key" select="'index symbols'"/>
108 <xsl:apply-templates select="$others"
109 mode="index-symbol-div">
110 <xsl:with-param name="scope" select="$scope"/>
111 <xsl:with-param name="role" select="$role"/>
112 <xsl:with-param name="type" select="$type"/>
113 <xsl:sort lang="{$sort.lang}"
114 select="k:getIndexGroupSortKey(⟨,
115 k:getIndexGroupKey(⟨, &primary;))"/>
116 </xsl:apply-templates>
121 <xsl:apply-templates select="$alphabetical"
122 mode="index-div-kimber">
123 <xsl:with-param name="scope" select="$scope"/>
124 <xsl:with-param name="role" select="$role"/>
125 <xsl:with-param name="type" select="$type"/>
126 <xsl:sort lang="{$sort.lang}"
127 select="k:getIndexGroupSortKey(⟨,
128 k:getIndexGroupKey(⟨, &primary;))"/>
129 </xsl:apply-templates>
134 <xsl:template match="indexterm" mode="index-div-kimber">
135 <xsl:param name="scope" select="."/>
136 <xsl:param name="role" select="''"/>
137 <xsl:param name="type" select="''"/>
139 <xsl:variable name="key"
140 select="k:getIndexGroupKey(⟨, &primary;)"/>
142 <xsl:variable name="label"
143 select="k:getIndexGroupLabel(⟨, $key)"/>
145 <xsl:if test="key('k-group', $label)[&scope;][count(.|key('primary', &primary;)[&scope;][1]) = 1]">
146 <div class="indexdiv">
148 <xsl:value-of select="$label"/>
151 <xsl:apply-templates select="key('k-group', $key)[&scope;]
152 [count(.|key('primary', &primary;)[&scope;]
154 mode="index-primary">
155 <xsl:sort select="&primary;" lang="{$sort.lang}"/>
156 <xsl:with-param name="scope" select="$scope"/>
157 <xsl:with-param name="role" select="$role"/>
158 <xsl:with-param name="type" select="$type"/>
159 </xsl:apply-templates>