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 = ""]))'>
8 <!ENTITY scope 'count(ancestor::node()|$scope) = count(ancestor::node()) and ($role = @role or $type = @type or (string-length($role) = 0 and string-length($type) = 0))'>
10 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
11 xmlns:i="urn:cz-kosek:functions:index"
12 xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0"
13 xmlns:func="http://exslt.org/functions"
14 xmlns:k="http://www.isogen.com/functions/com.isogen.saxoni18n.Saxoni18nService"
15 xmlns:exslt="http://exslt.org/common"
16 extension-element-prefixes="func exslt"
17 exclude-result-prefixes="func exslt i l k"
20 <!-- ********************************************************************
21 $Id: autoidx-kosek.xsl 8399 2009-04-08 07:37:42Z bobstayton $
22 ********************************************************************
24 This file is part of the XSL DocBook Stylesheet distribution.
25 See ../README or http://docbook.sf.net/release/xsl/current/ for
26 copyright and other information.
28 ******************************************************************** -->
30 <!-- ==================================================================== -->
31 <!-- The "kosek" method contributed by Jirka Kosek. -->
33 <xsl:include href="../common/autoidx-kosek.xsl"/>
35 <xsl:template name="generate-kosek-index">
36 <xsl:param name="scope" select="(ancestor::book|/)[last()]"/>
38 <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
39 <xsl:if test="contains($vendor, 'libxslt')">
40 <xsl:message terminate="yes">
41 <xsl:text>ERROR: the 'kosek' index method does not </xsl:text>
42 <xsl:text>work with the xsltproc XSLT processor.</xsl:text>
46 <xsl:if test="contains($vendor, 'Saxonica')">
47 <xsl:message terminate="yes">
48 <xsl:text>ERROR: the 'kosek' index method does not </xsl:text>
49 <xsl:text>work with the Saxon 8 XSLT processor.</xsl:text>
53 <xsl:if test="$exsl.node.set.available = 0">
54 <xsl:message terminate="yes">
55 <xsl:text>ERROR: the 'kosek' index method requires the </xsl:text>
56 <xsl:text>exslt:node-set() function. Use a processor that </xsl:text>
57 <xsl:text>has it, or use a different index method.</xsl:text>
61 <xsl:if test="not(function-available('i:group-index'))">
62 <xsl:message terminate="yes">
63 <xsl:text>ERROR: the 'kosek' index method requires the
</xsl:text>
64 <xsl:text>index extension functions be imported:
</xsl:text>
65 <xsl:text> xsl:import href="common/autoidx-kosek.xsl"</xsl:text>
69 <xsl:variable name="role">
70 <xsl:if test="$index.on.role != 0">
71 <xsl:value-of select="@role"/>
75 <xsl:variable name="type">
76 <xsl:if test="$index.on.type != 0">
77 <xsl:value-of select="@type"/>
81 <xsl:variable name="terms"
82 select="//indexterm[count(.|key('group-code', i:group-index(&primary;))[&scope;][1]) = 1 and not(@class = 'endofrange')]"/>
85 <xsl:apply-templates select="$terms" mode="index-div-kosek">
86 <xsl:with-param name="scope" select="$scope"/>
87 <xsl:with-param name="role" select="$role"/>
88 <xsl:with-param name="type" select="$type"/>
89 <xsl:sort select="i:group-index(&primary;)" data-type="number"/>
90 </xsl:apply-templates>
94 <xsl:template match="indexterm" mode="index-div-kosek">
95 <xsl:param name="scope" select="."/>
96 <xsl:param name="role" select="''"/>
97 <xsl:param name="type" select="''"/>
99 <xsl:variable name="key"
100 select="i:group-index(&primary;)"/>
102 <xsl:variable name="lang">
103 <xsl:call-template name="l10n.language"/>
106 <xsl:if test="key('group-code', $key)[&scope;][count(.|key('primary', &primary;)[&scope;][1]) = 1]">
107 <div class="indexdiv">
109 <xsl:value-of select="i:group-letter($key)"/>
112 <xsl:apply-templates select="key('group-code', $key)[&scope;][count(.|key('primary', &primary;)[&scope;][1])=1]"
113 mode="index-primary">
114 <xsl:sort select="&primary;" lang="{$lang}"/>
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:apply-templates>