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 = ""]))'>
9 <!-- Documents using the kimber index method must have a lang attribute -->
10 <!-- Only one of these should be present in the entity -->
11 <!ENTITY lang 'concat(/*/@lang, /*/@xml:lang)'>
13 <!ENTITY scope 'count(ancestor::node()|$scope) = count(ancestor::node())
14 and ($role = @role or $type = @type or
15 (string-length($role) = 0 and string-length($type) = 0))'>
17 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
18 xmlns:fo="http://www.w3.org/1999/XSL/Format"
19 xmlns:k="java:com.isogen.saxoni18n.Saxoni18nService"
20 exclude-result-prefixes="k"
23 <!-- ********************************************************************
24 $Id: autoidx-kimber.xsl 6910 2007-06-28 23:23:30Z xmldoc $
25 ********************************************************************
27 This file is part of the DocBook XSL Stylesheet distribution.
28 See ../README or http://docbook.sf.net/ for copyright
29 copyright and other information.
31 ******************************************************************** -->
33 <!-- ==================================================================== -->
34 <!-- The "kimber" method contributed by Eliot Kimber of Innodata Isogen. -->
35 <!-- ==================================================================== -->
36 <!-- *** THIS MODULE ONLY WORKS WITH SAXON 6 OR SAXON 8 *** -->
37 <!-- ==================================================================== -->
39 <xsl:include href="../common/autoidx-kimber.xsl"/>
41 <!-- Java sort apparently works only on lang part, not country -->
42 <xsl:param name="sort.lang">
44 <xsl:when test="contains(⟨, '-')">
45 <xsl:value-of select="substring-before(⟨, '-')"/>
47 <xsl:when test="contains(⟨, '_')">
48 <xsl:value-of select="substring-before(⟨, '_')"/>
51 <xsl:value-of select="⟨"/>
56 <xsl:template name="generate-kimber-index">
57 <xsl:param name="scope" select="NOTANODE"/>
59 <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
60 <xsl:if test="not(contains($vendor, 'SAXON '))">
61 <xsl:message terminate="yes">
62 <xsl:text>ERROR: the 'kimber' index method requires the </xsl:text>
63 <xsl:text>Saxon version 6 or 8 XSLT processor.</xsl:text>
67 <xsl:if test="not(function-available('k:getIndexGroupKey'))">
68 <xsl:message terminate="yes">
69 <xsl:text>ERROR: the 'kimber' index method requires the </xsl:text>
70 <xsl:text>Innodata Isogen 
Java extensions for </xsl:text>
71 <xsl:text>internationalized indexes. 
Install those </xsl:text>
72 <xsl:text>extensions, or use a different index method.
</xsl:text>
73 <xsl:text>For more information, see:
</xsl:text>
74 <xsl:text>http://www.innodata-isogen.com/knowledge_center/tools_downloads/i18nsupport</xsl:text>
78 <xsl:variable name="role">
79 <xsl:if test="$index.on.role != 0">
80 <xsl:value-of select="@role"/>
84 <xsl:variable name="type">
85 <xsl:if test="$index.on.type != 0">
86 <xsl:value-of select="@type"/>
90 <xsl:variable name="terms"
91 select="//indexterm[count(.|key('k-group',
92 k:getIndexGroupKey(⟨, &primary;))
94 and not(@class = 'endofrange')]"/>
96 <xsl:variable name="alphabetical"
97 select="$terms[not(starts-with(
98 k:getIndexGroupKey(⟨, &primary;),
102 <xsl:variable name="others"
103 select="$terms[starts-with(
104 k:getIndexGroupKey(⟨, &primary;),
109 <xsl:if test="$others">
110 <xsl:call-template name="indexdiv.title">
111 <xsl:with-param name="titlecontent">
112 <xsl:call-template name="gentext">
113 <xsl:with-param name="key" select="'index symbols'"/>
119 <xsl:apply-templates select="$others"
120 mode="index-symbol-div">
121 <xsl:with-param name="scope" select="$scope"/>
122 <xsl:with-param name="role" select="$role"/>
123 <xsl:with-param name="type" select="$type"/>
124 <xsl:sort lang="{$sort.lang}"
125 select="k:getIndexGroupSortKey(⟨,
126 k:getIndexGroupKey(⟨, &primary;))"/>
127 </xsl:apply-templates>
131 <xsl:apply-templates select="$alphabetical"
132 mode="index-div-kimber">
133 <xsl:with-param name="scope" select="$scope"/>
134 <xsl:with-param name="role" select="$role"/>
135 <xsl:with-param name="type" select="$type"/>
136 <xsl:sort lang="{$sort.lang}"
137 select="k:getIndexGroupSortKey(⟨,
138 k:getIndexGroupKey(⟨, &primary;))"/>
139 </xsl:apply-templates>
144 <xsl:template match="indexterm" mode="index-div-kimber">
145 <xsl:param name="scope" select="."/>
146 <xsl:param name="role" select="''"/>
147 <xsl:param name="type" select="''"/>
149 <xsl:variable name="key"
150 select="k:getIndexGroupKey(⟨, &primary;)"/>
152 <xsl:variable name="label"
153 select="k:getIndexGroupLabel(⟨, $key)"/>
155 <xsl:if test="key('k-group', $key)[&scope;]
156 [count(.|key('primary', &primary;)[&scope;][1]) = 1]">
158 <xsl:call-template name="indexdiv.title">
159 <xsl:with-param name="titlecontent">
160 <xsl:value-of select="$label"/>
164 <xsl:apply-templates select="key('k-group', $key)[&scope;]
165 [count(.|key('primary', &primary;)[&scope;]
167 mode="index-primary">
168 <xsl:sort select="&primary;" lang="{$sort.lang}"/>
169 <xsl:with-param name="scope" select="$scope"/>
170 <xsl:with-param name="role" select="$role"/>
171 <xsl:with-param name="type" select="$type"/>
172 </xsl:apply-templates>