1 <?xml version="1.0" encoding="ASCII"?><!--This file was created automatically by html2xhtml--><!--from the HTML stylesheets.--><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:d="http://docbook.org/ns/docbook" xmlns:k="http://www.isogen.com/functions/com.isogen.saxoni18n.Saxoni18nService" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="k d" version="1.0">
3 <!-- ********************************************************************
5 This file is part of the XSL DocBook Stylesheet distribution.
6 See ../README or http://cdn.docbook.org/release/xsl/current/ for
7 copyright and other information.
9 ******************************************************************** -->
11 <!-- ==================================================================== -->
12 <!-- The "kimber" method contributed by Eliot Kimber of Innodata Isogen. -->
13 <!-- ==================================================================== -->
14 <!-- *** THIS MODULE ONLY WORKS WITH SAXON 6 OR SAXON 8 *** -->
15 <!-- ==================================================================== -->
18 <xsl:include href="../common/autoidx-kimber.xsl"/>
20 <!-- Java sort apparently works only on lang part, not country -->
21 <xsl:param name="sort.lang">
23 <xsl:when test="contains(concat(/*/@lang, /*/@xml:lang), '-')">
24 <xsl:value-of select="substring-before(concat(/*/@lang, /*/@xml:lang), '-')"/>
26 <xsl:when test="contains(concat(/*/@lang, /*/@xml:lang), '_')">
27 <xsl:value-of select="substring-before(concat(/*/@lang, /*/@xml:lang), '_')"/>
30 <xsl:value-of select="concat(/*/@lang, /*/@xml:lang)"/>
35 <xsl:template name="generate-kimber-index">
36 <xsl:param name="scope" select="NOTANODE"/>
38 <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
39 <xsl:if test="not(contains($vendor, 'SAXON '))">
40 <xsl:message terminate="yes">
41 <xsl:text>ERROR: the 'kimber' index method requires the </xsl:text>
42 <xsl:text>Saxon version 6 or 8 XSLT processor.</xsl:text>
46 <xsl:if test="not(function-available('k:getIndexGroupKey'))">
47 <xsl:message terminate="yes">
48 <xsl:text>ERROR: the 'kimber' index method requires the </xsl:text>
49 <xsl:text>Innodata Isogen
50 Java extensions for </xsl:text>
51 <xsl:text>internationalized indexes.
52 Install those </xsl:text>
53 <xsl:text>extensions, or use a different index method.
55 <xsl:text>For more information, see:
57 <xsl:text>http://www.innodata-isogen.com/knowledge_center/tools_downloads/i18nsupport</xsl:text>
61 <xsl:variable name="role">
62 <xsl:if test="$index.on.role != 0">
63 <xsl:value-of select="@role"/>
67 <xsl:variable name="type">
68 <xsl:if test="$index.on.type != 0">
69 <xsl:value-of select="@type"/>
73 <xsl:variable name="terms" select="//d:indexterm[count(.|key('k-group', k:getIndexGroupKey(concat(/*/@lang, /*/@xml:lang), normalize-space(concat(d:primary/@sortas, " ", d:primary))))[count(ancestor::node()|$scope) = count(ancestor::node()) and ($role = @role or $type = @type or (string-length($role) = 0 and string-length($type) = 0))][1]) = 1 and not(@class = 'endofrange')]"/>
75 <xsl:variable name="alphabetical" select="$terms[not(starts-with( k:getIndexGroupKey(concat(/*/@lang, /*/@xml:lang), normalize-space(concat(d:primary/@sortas, " ", d:primary))), '#NUMERIC' ))]"/>
77 <xsl:variable name="others" select="$terms[starts-with( k:getIndexGroupKey(concat(/*/@lang, /*/@xml:lang), normalize-space(concat(d:primary/@sortas, " ", d:primary))), '#NUMERIC' )]"/>
80 <xsl:if test="$others">
81 <div class="indexdev">
83 <xsl:call-template name="gentext">
84 <xsl:with-param name="key" select="'index symbols'"/>
88 <xsl:apply-templates select="$others" mode="index-symbol-div">
89 <xsl:with-param name="scope" select="$scope"/>
90 <xsl:with-param name="role" select="$role"/>
91 <xsl:with-param name="type" select="$type"/>
92 <xsl:sort lang="{$sort.lang}" select="k:getIndexGroupSortKey(concat(/*/@lang, /*/@xml:lang), k:getIndexGroupKey(concat(/*/@lang, /*/@xml:lang), normalize-space(concat(d:primary/@sortas, " ", d:primary))))"/>
93 </xsl:apply-templates>
98 <xsl:apply-templates select="$alphabetical" mode="index-div-kimber">
99 <xsl:with-param name="scope" select="$scope"/>
100 <xsl:with-param name="role" select="$role"/>
101 <xsl:with-param name="type" select="$type"/>
102 <xsl:sort lang="{$sort.lang}" select="k:getIndexGroupSortKey(concat(/*/@lang, /*/@xml:lang), k:getIndexGroupKey(concat(/*/@lang, /*/@xml:lang), normalize-space(concat(d:primary/@sortas, " ", d:primary))))"/>
103 </xsl:apply-templates>
108 <xsl:template match="d:indexterm" mode="index-div-kimber">
109 <xsl:param name="scope" select="."/>
110 <xsl:param name="role" select="''"/>
111 <xsl:param name="type" select="''"/>
113 <xsl:variable name="key" select="k:getIndexGroupKey(concat(/*/@lang, /*/@xml:lang), normalize-space(concat(d:primary/@sortas, " ", d:primary)))"/>
115 <xsl:variable name="label" select="k:getIndexGroupLabel(concat(/*/@lang, /*/@xml:lang), $key)"/>
117 <xsl:if test="key('k-group', $label)[count(ancestor::node()|$scope) = count(ancestor::node()) and ($role = @role or $type = @type or (string-length($role) = 0 and string-length($type) = 0))][count(.|key('primary', normalize-space(concat(d:primary/@sortas, " ", d:primary)))[count(ancestor::node()|$scope) = count(ancestor::node()) and ($role = @role or $type = @type or (string-length($role) = 0 and string-length($type) = 0))][1]) = 1]">
118 <div class="indexdiv">
120 <xsl:value-of select="$label"/>
123 <xsl:apply-templates select="key('k-group', $key)[count(ancestor::node()|$scope) = count(ancestor::node()) and ($role = @role or $type = @type or (string-length($role) = 0 and string-length($type) = 0))] [count(.|key('primary', normalize-space(concat(d:primary/@sortas, " ", d:primary)))[count(ancestor::node()|$scope) = count(ancestor::node()) and ($role = @role or $type = @type or (string-length($role) = 0 and string-length($type) = 0))] [1])=1]" mode="index-primary">
124 <xsl:sort select="normalize-space(concat(d:primary/@sortas, " ", d:primary))" lang="{$sort.lang}"/>
125 <xsl:with-param name="scope" select="$scope"/>
126 <xsl:with-param name="role" select="$role"/>
127 <xsl:with-param name="type" select="$type"/>
128 </xsl:apply-templates>