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:i="urn:cz-kosek:functions:index" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:func="http://exslt.org/functions" xmlns:k="http://www.isogen.com/functions/com.isogen.saxoni18n.Saxoni18nService" xmlns:exslt="http://exslt.org/common" xmlns="http://www.w3.org/1999/xhtml" extension-element-prefixes="func exslt" exclude-result-prefixes="func exslt i l 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 "kosek" method contributed by Jirka Kosek. -->
14 <xsl:include href="../common/autoidx-kosek.xsl"/>
16 <xsl:template name="generate-kosek-index">
17 <xsl:param name="scope" select="(ancestor::d:book|/)[last()]"/>
19 <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
20 <xsl:if test="contains($vendor, 'libxslt')">
21 <xsl:message terminate="yes">
22 <xsl:text>ERROR: the 'kosek' index method does not </xsl:text>
23 <xsl:text>work with the xsltproc XSLT processor.</xsl:text>
27 <xsl:if test="contains($vendor, 'Saxonica')">
28 <xsl:message terminate="yes">
29 <xsl:text>ERROR: the 'kosek' index method does not </xsl:text>
30 <xsl:text>work with the Saxon 8 XSLT processor.</xsl:text>
34 <xsl:if test="$exsl.node.set.available = 0">
35 <xsl:message terminate="yes">
36 <xsl:text>ERROR: the 'kosek' index method requires the </xsl:text>
37 <xsl:text>exslt:node-set() function. Use a processor that </xsl:text>
38 <xsl:text>has it, or use a different index method.</xsl:text>
42 <xsl:if test="not(function-available('i:group-index'))">
43 <xsl:message terminate="yes">
44 <xsl:text>ERROR: the 'kosek' index method requires the
46 <xsl:text>index extension functions be imported:
48 <xsl:text> xsl:import href="common/autoidx-kosek.xsl"</xsl:text>
52 <xsl:variable name="role">
53 <xsl:if test="$index.on.role != 0">
54 <xsl:value-of select="@role"/>
58 <xsl:variable name="type">
59 <xsl:if test="$index.on.type != 0">
60 <xsl:value-of select="@type"/>
64 <xsl:variable name="terms" select="//d:indexterm[count(.|key('group-code', i:group-index(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')]"/>
67 <xsl:apply-templates select="$terms" mode="index-div-kosek">
68 <xsl:with-param name="scope" select="$scope"/>
69 <xsl:with-param name="role" select="$role"/>
70 <xsl:with-param name="type" select="$type"/>
71 <xsl:sort select="i:group-index(normalize-space(concat(d:primary/@sortas, " ", d:primary)))" data-type="number"/>
72 </xsl:apply-templates>
76 <xsl:template match="d:indexterm" mode="index-div-kosek">
77 <xsl:param name="scope" select="."/>
78 <xsl:param name="role" select="''"/>
79 <xsl:param name="type" select="''"/>
81 <xsl:variable name="key" select="i:group-index(normalize-space(concat(d:primary/@sortas, " ", d:primary)))"/>
83 <xsl:variable name="lang">
84 <xsl:call-template name="l10n.language"/>
87 <xsl:if test="key('group-code', $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]">
88 <div class="indexdiv">
90 <xsl:value-of select="i:group-letter($key)"/>
93 <xsl:apply-templates select="key('group-code', $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">
94 <xsl:sort select="normalize-space(concat(d:primary/@sortas, " ", d:primary))" lang="{$lang}"/>
95 <xsl:with-param name="scope" select="$scope"/>
96 <xsl:with-param name="role" select="$role"/>
97 <xsl:with-param name="type" select="$type"/>
98 </xsl:apply-templates>