2 <!DOCTYPE xsl:stylesheet [
3 <!ENTITY % common.entities SYSTEM "../common/entities.ent">
6 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
7 xmlns:i="urn:cz-kosek:functions:index"
8 xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0"
9 xmlns:func="http://exslt.org/functions"
10 xmlns:k="http://www.isogen.com/functions/com.isogen.saxoni18n.Saxoni18nService"
11 xmlns:exslt="http://exslt.org/common"
12 extension-element-prefixes="func exslt"
13 exclude-result-prefixes="func exslt i l k"
16 <!-- ********************************************************************
17 $Id: autoidx-kosek.xsl 8725 2010-07-15 08:08:04Z kosek $
18 ********************************************************************
20 This file is part of the XSL DocBook Stylesheet distribution.
21 See ../README or http://docbook.sf.net/release/xsl/current/ for
22 copyright and other information.
24 ******************************************************************** -->
26 <!-- ==================================================================== -->
27 <!-- The "kosek" method contributed by Jirka Kosek. -->
29 <xsl:include href="../common/autoidx-kosek.xsl"/>
31 <xsl:template name="generate-kosek-index">
32 <xsl:param name="scope" select="(ancestor::book|/)[last()]"/>
34 <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
35 <xsl:if test="contains($vendor, 'libxslt')">
36 <xsl:message terminate="yes">
37 <xsl:text>ERROR: the 'kosek' index method does not </xsl:text>
38 <xsl:text>work with the xsltproc XSLT processor.</xsl:text>
42 <xsl:if test="contains($vendor, 'Saxonica')">
43 <xsl:message terminate="yes">
44 <xsl:text>ERROR: the 'kosek' index method does not </xsl:text>
45 <xsl:text>work with the Saxon 8 XSLT processor.</xsl:text>
49 <xsl:if test="$exsl.node.set.available = 0">
50 <xsl:message terminate="yes">
51 <xsl:text>ERROR: the 'kosek' index method requires the </xsl:text>
52 <xsl:text>exslt:node-set() function. Use a processor that </xsl:text>
53 <xsl:text>has it, or use a different index method.</xsl:text>
57 <xsl:if test="not(function-available('i:group-index'))">
58 <xsl:message terminate="yes">
59 <xsl:text>ERROR: the 'kosek' index method requires the
</xsl:text>
60 <xsl:text>index extension functions be imported:
</xsl:text>
61 <xsl:text> xsl:import href="common/autoidx-kosek.xsl"</xsl:text>
65 <xsl:variable name="role">
66 <xsl:if test="$index.on.role != 0">
67 <xsl:value-of select="@role"/>
71 <xsl:variable name="type">
72 <xsl:if test="$index.on.type != 0">
73 <xsl:value-of select="@type"/>
77 <xsl:variable name="terms"
78 select="//indexterm[count(.|key('group-code', i:group-index(&primary;))[&scope;][1]) = 1 and not(@class = 'endofrange')]"/>
81 <xsl:apply-templates select="$terms" mode="index-div-kosek">
82 <xsl:with-param name="scope" select="$scope"/>
83 <xsl:with-param name="role" select="$role"/>
84 <xsl:with-param name="type" select="$type"/>
85 <xsl:sort select="i:group-index(&primary;)" data-type="number"/>
86 </xsl:apply-templates>
90 <xsl:template match="indexterm" mode="index-div-kosek">
91 <xsl:param name="scope" select="."/>
92 <xsl:param name="role" select="''"/>
93 <xsl:param name="type" select="''"/>
95 <xsl:variable name="key"
96 select="i:group-index(&primary;)"/>
98 <xsl:variable name="lang">
99 <xsl:call-template name="l10n.language"/>
102 <xsl:if test="key('group-code', $key)[&scope;][count(.|key('primary', &primary;)[&scope;][1]) = 1]">
103 <div class="indexdiv">
105 <xsl:value-of select="i:group-letter($key)"/>
108 <xsl:apply-templates select="key('group-code', $key)[&scope;][count(.|key('primary', &primary;)[&scope;][1])=1]"
109 mode="index-primary">
110 <xsl:sort select="&primary;" lang="{$lang}"/>
111 <xsl:with-param name="scope" select="$scope"/>
112 <xsl:with-param name="role" select="$role"/>
113 <xsl:with-param name="type" select="$type"/>
114 </xsl:apply-templates>