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 -->
12 <!ENTITY scope 'count(ancestor::node()|$scope) = count(ancestor::node())
13 and ($role = @role or $type = @type or
14 (string-length($role) = 0 and string-length($type) = 0))'>
16 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
17 xmlns:fo="http://www.w3.org/1999/XSL/Format"
18 xmlns:rx="http://www.renderx.com/XSL/Extensions"
19 xmlns:axf="http://www.antennahouse.com/names/XSL/Extensions"
20 xmlns:i="urn:cz-kosek:functions:index"
21 xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0"
22 xmlns:func="http://exslt.org/functions"
23 xmlns:exslt="http://exslt.org/common"
24 extension-element-prefixes="func exslt"
25 exclude-result-prefixes="func exslt i l"
28 <!-- ********************************************************************
29 $Id: autoidx-kosek.xsl 8399 2009-04-08 07:37:42Z bobstayton $
30 ********************************************************************
32 This file is part of the DocBook XSL Stylesheet distribution.
33 See ../README or http://docbook.sf.net/ for copyright
34 copyright and other information.
36 ******************************************************************** -->
38 <!-- ==================================================================== -->
39 <!-- The "kosek" method contributed by Jirka Kosek. -->
41 <xsl:include href="../common/autoidx-kosek.xsl"/>
43 <xsl:template name="generate-kosek-index">
44 <xsl:param name="scope" select="NOTANODE"/>
46 <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
47 <xsl:if test="contains($vendor, 'libxslt')">
48 <xsl:message terminate="yes">
49 <xsl:text>ERROR: the 'kosek' index method does not </xsl:text>
50 <xsl:text>work with the xsltproc XSLT processor.</xsl:text>
54 <xsl:if test="contains($vendor, 'Saxonica')">
55 <xsl:message terminate="yes">
56 <xsl:text>ERROR: the 'kosek' index method does not </xsl:text>
57 <xsl:text>work with the Saxon 8 XSLT processor.</xsl:text>
62 <xsl:if test="$exsl.node.set.available = 0">
63 <xsl:message terminate="yes">
64 <xsl:text>ERROR: the 'kosek' index method requires the </xsl:text>
65 <xsl:text>exslt:node-set() function. Use a processor that </xsl:text>
66 <xsl:text>has it, or use a different index method.</xsl:text>
70 <xsl:if test="not(function-available('i:group-index'))">
71 <xsl:message terminate="yes">
72 <xsl:text>ERROR: the 'kosek' index method requires the
</xsl:text>
73 <xsl:text>index extension functions be imported:
</xsl:text>
74 <xsl:text> xsl:import href="common/autoidx-kosek.xsl"</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('group-code',
92 i:group-index(&primary;))
94 and not(@class = 'endofrange')]"/>
96 <xsl:apply-templates select="$terms" mode="index-div-kosek">
97 <xsl:with-param name="scope" select="$scope"/>
98 <xsl:with-param name="role" select="$role"/>
99 <xsl:with-param name="type" select="$type"/>
100 <xsl:sort select="i:group-index(&primary;)" data-type="number"/>
101 </xsl:apply-templates>
105 <xsl:template match="indexterm" mode="index-div-kosek">
106 <xsl:param name="scope" select="."/>
107 <xsl:param name="role" select="''"/>
108 <xsl:param name="type" select="''"/>
110 <xsl:variable name="key"
111 select="i:group-index(&primary;)"/>
113 <xsl:variable name="lang">
114 <xsl:call-template name="l10n.language"/>
117 <xsl:if test="key('group-code', $key)[&scope;]
118 [count(.|key('primary', &primary;)[&scope;][1]) = 1]">
120 <xsl:call-template name="indexdiv.title">
121 <xsl:with-param name="titlecontent">
123 <xsl:when test="$key = 0">
124 <xsl:call-template name="gentext">
125 <xsl:with-param name="key" select="'index symbols'"/>
129 <xsl:value-of select="i:group-letter($key)"/>
135 <xsl:apply-templates select="key('group-code', $key)[&scope;]
136 [count(.|key('primary', &primary;)
138 mode="index-primary">
139 <xsl:sort select="&primary;" lang="{$lang}"/>
140 <xsl:with-param name="scope" select="$scope"/>
141 <xsl:with-param name="role" select="$role"/>
142 <xsl:with-param name="type" select="$type"/>
143 </xsl:apply-templates>