2 <!DOCTYPE xsl:stylesheet [
3 <!ENTITY % common.entities SYSTEM "entities.ent">
6 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
8 xmlns:func="http://exslt.org/functions"
9 xmlns:exslt="http://exslt.org/common"
10 xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0"
11 xmlns:fo="http://www.w3.org/1999/XSL/Format"
12 extension-element-prefixes="func exslt"
13 exclude-result-prefixes="func exslt i l"
14 xmlns:i="urn:cz-kosek:functions:index">
16 <!-- ********************************************************************
17 $Id: autoidx-kosek.xsl 8759 2010-07-20 21:46:07Z kosek $
18 ********************************************************************
20 This file is part of the DocBook XSL Stylesheet distribution.
21 See ../README or http://docbook.sf.net/ for copyright
22 copyright and other information.
24 ******************************************************************** -->
26 <xsl:param name="kosek.imported">
27 <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
29 <xsl:when test="contains($vendor, 'libxslt')">
30 <xsl:message terminate="yes">
31 <xsl:text>ERROR: the 'kosek' index method does not </xsl:text>
32 <xsl:text>work with the xsltproc XSLT processor.</xsl:text>
35 <xsl:otherwise>1</xsl:otherwise>
39 <!-- Returns index group code for given term -->
40 <func:function name="i:group-index">
41 <xsl:param name="term"/>
43 <xsl:variable name="letters-rtf">
44 <xsl:variable name="lang">
45 <xsl:call-template name="l10n.language"/>
48 <xsl:variable name="local.l10n.letters"
49 select="($local.l10n.xml//l:i18n/l:l10n[@language=$lang]/l:letters)[1]"/>
51 <xsl:for-each select="$l10n.xml">
52 <xsl:variable name="l10n.letters"
53 select="document(key('l10n-lang', $lang)/@href)/l:l10n/l:letters[1]"/>
56 <xsl:when test="count($local.l10n.letters) > 0">
57 <xsl:copy-of select="$local.l10n.letters"/>
59 <xsl:when test="count($l10n.letters) > 0">
60 <xsl:copy-of select="$l10n.letters"/>
64 <xsl:text>No "</xsl:text>
65 <xsl:value-of select="$lang"/>
66 <xsl:text>" localization of index grouping letters exists</xsl:text>
68 <xsl:when test="$lang = 'en'">
69 <xsl:text>.</xsl:text>
72 <xsl:text>; using "en".</xsl:text>
77 <xsl:copy-of select="document(key('l10n-lang', 'en'))/l:l10n/l:letters[1]"/>
83 <xsl:variable name="letters" select="exslt:node-set($letters-rtf)/*"/>
85 <xsl:variable name="long-letter-index" select="$letters/l:l[. = substring($term,1,2)]/@i"/>
86 <xsl:variable name="short-letter-index" select="$letters/l:l[. = substring($term,1,1)]/@i"/>
87 <xsl:variable name="letter-index">
89 <xsl:when test="$long-letter-index">
90 <xsl:value-of select="$long-letter-index"/>
92 <xsl:when test="$short-letter-index">
93 <xsl:value-of select="$short-letter-index"/>
95 <xsl:otherwise>0</xsl:otherwise>
98 <func:result select="number($letter-index)"/>
101 <!-- Return index group letter for given group code -->
102 <func:function name="i:group-letter">
103 <xsl:param name="index"/>
105 <xsl:variable name="letters-rtf">
106 <xsl:variable name="lang">
107 <xsl:call-template name="l10n.language"/>
110 <xsl:variable name="local.l10n.letters"
111 select="($local.l10n.xml//l:i18n/l:l10n[@language=$lang]/l:letters)[1]"/>
113 <xsl:for-each select="$l10n.xml">
114 <xsl:variable name="l10n.letters"
115 select="document(key('l10n-lang', $lang)/@href)/l:l10n/l:letters[1]"/>
118 <xsl:when test="count($local.l10n.letters) > 0">
119 <xsl:copy-of select="$local.l10n.letters"/>
121 <xsl:when test="count($l10n.letters) > 0">
122 <xsl:copy-of select="$l10n.letters"/>
126 <xsl:text>No "</xsl:text>
127 <xsl:value-of select="$lang"/>
128 <xsl:text>" localization of index grouping letters exists</xsl:text>
130 <xsl:when test="$lang = 'en'">
131 <xsl:text>.</xsl:text>
134 <xsl:text>; using "en".</xsl:text>
139 <xsl:copy-of select="document(key('l10n-lang', 'en')/@href)/l:l10n/l:letters[1]"/>
145 <xsl:variable name="letters" select="exslt:node-set($letters-rtf)/*"/>
147 <func:result select="$letters/l:l[@i=$index][1]"/>
150 <xsl:key name="group-code"
152 use="i:group-index(&primary;)"/>