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:fo="http://www.w3.org/1999/XSL/Format"
13 xmlns:k="java:com.isogen.saxoni18n.Saxoni18nService"
14 exclude-result-prefixes="k"
17 <!-- ********************************************************************
18 $Id: autoidx-kimber.xsl 8729 2010-07-15 16:43:56Z bobstayton $
19 ********************************************************************
21 This file is part of the DocBook XSL Stylesheet distribution.
22 See ../README or http://docbook.sf.net/ for copyright
23 copyright and other information.
25 ******************************************************************** -->
27 <!-- ==================================================================== -->
28 <!-- The "kimber" method contributed by Eliot Kimber of Innodata Isogen. -->
29 <!-- ==================================================================== -->
30 <!-- *** THIS MODULE ONLY WORKS WITH SAXON 6 OR SAXON 8 *** -->
31 <!-- ==================================================================== -->
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',
86 k:getIndexGroupKey(⟨, &primary;))
88 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 <xsl:call-template name="indexdiv.title">
105 <xsl:with-param name="titlecontent">
106 <xsl:call-template name="gentext">
107 <xsl:with-param name="key" select="'index symbols'"/>
113 <xsl:apply-templates select="$others"
114 mode="index-symbol-div">
115 <xsl:with-param name="scope" select="$scope"/>
116 <xsl:with-param name="role" select="$role"/>
117 <xsl:with-param name="type" select="$type"/>
118 <xsl:sort lang="{$sort.lang}"
119 select="k:getIndexGroupSortKey(⟨,
120 k:getIndexGroupKey(⟨, &primary;))"/>
121 </xsl:apply-templates>
125 <xsl:apply-templates select="$alphabetical"
126 mode="index-div-kimber">
127 <xsl:with-param name="scope" select="$scope"/>
128 <xsl:with-param name="role" select="$role"/>
129 <xsl:with-param name="type" select="$type"/>
130 <xsl:sort lang="{$sort.lang}"
131 select="k:getIndexGroupSortKey(⟨,
132 k:getIndexGroupKey(⟨, &primary;))"/>
133 </xsl:apply-templates>
138 <xsl:template match="indexterm" mode="index-div-kimber">
139 <xsl:param name="scope" select="."/>
140 <xsl:param name="role" select="''"/>
141 <xsl:param name="type" select="''"/>
143 <xsl:variable name="key"
144 select="k:getIndexGroupKey(⟨, &primary;)"/>
146 <xsl:variable name="label"
147 select="k:getIndexGroupLabel(⟨, $key)"/>
149 <xsl:if test="key('k-group', $key)[&scope;]
150 [count(.|key('primary', &primary;)[&scope;][1]) = 1]">
152 <xsl:call-template name="indexdiv.title">
153 <xsl:with-param name="titlecontent">
154 <xsl:value-of select="$label"/>
158 <xsl:apply-templates select="key('k-group', $key)[&scope;]
159 [count(.|key('primary', &primary;)[&scope;]
161 mode="index-primary">
162 <xsl:sort select="&primary;" lang="{$sort.lang}"/>
163 <xsl:with-param name="scope" select="$scope"/>
164 <xsl:with-param name="role" select="$role"/>
165 <xsl:with-param name="type" select="$type"/>
166 </xsl:apply-templates>