2 <!DOCTYPE xsl:stylesheet [
3 <!ENTITY primary 'normalize-space(concat(primary/@sortas, primary[not(@sortas)]))'>
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 6910 2007-06-28 23:23:30Z xmldoc $
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:variable name="l10n.letters"
52 select="($l10n.xml/l:i18n/l:l10n[@language=$lang]/l:letters)[1]"/>
55 <xsl:when test="count($local.l10n.letters) > 0">
56 <xsl:copy-of select="$local.l10n.letters"/>
58 <xsl:when test="count($l10n.letters) > 0">
59 <xsl:copy-of select="$l10n.letters"/>
63 <xsl:text>No "</xsl:text>
64 <xsl:value-of select="$lang"/>
65 <xsl:text>" localization of index grouping letters exists</xsl:text>
67 <xsl:when test="$lang = 'en'">
68 <xsl:text>.</xsl:text>
71 <xsl:text>; using "en".</xsl:text>
76 <xsl:copy-of select="($l10n.xml/l:i18n/l:l10n[@language='en']/l:letters)[1]"/>
81 <xsl:variable name="letters" select="exslt:node-set($letters-rtf)/*"/>
83 <xsl:variable name="long-letter-index" select="$letters/l:l[. = substring($term,1,2)]/@i"/>
84 <xsl:variable name="short-letter-index" select="$letters/l:l[. = substring($term,1,1)]/@i"/>
85 <xsl:variable name="letter-index">
87 <xsl:when test="$long-letter-index">
88 <xsl:value-of select="$long-letter-index"/>
90 <xsl:when test="$short-letter-index">
91 <xsl:value-of select="$short-letter-index"/>
93 <xsl:otherwise>0</xsl:otherwise>
96 <func:result select="number($letter-index)"/>
99 <!-- Return index group letter for given group code -->
100 <func:function name="i:group-letter">
101 <xsl:param name="index"/>
103 <xsl:variable name="letters-rtf">
104 <xsl:variable name="lang">
105 <xsl:call-template name="l10n.language"/>
108 <xsl:variable name="local.l10n.letters"
109 select="($local.l10n.xml//l:i18n/l:l10n[@language=$lang]/l:letters)[1]"/>
111 <xsl:variable name="l10n.letters"
112 select="($l10n.xml/l:i18n/l:l10n[@language=$lang]/l:letters)[1]"/>
115 <xsl:when test="count($local.l10n.letters) > 0">
116 <xsl:copy-of select="$local.l10n.letters"/>
118 <xsl:when test="count($l10n.letters) > 0">
119 <xsl:copy-of select="$l10n.letters"/>
123 <xsl:text>No "</xsl:text>
124 <xsl:value-of select="$lang"/>
125 <xsl:text>" localization of index grouping letters exists</xsl:text>
127 <xsl:when test="$lang = 'en'">
128 <xsl:text>.</xsl:text>
131 <xsl:text>; using "en".</xsl:text>
136 <xsl:copy-of select="($l10n.xml/l:i18n/l:l10n[@language='en']/l:letters)[1]"/>
141 <xsl:variable name="letters" select="exslt:node-set($letters-rtf)/*"/>
143 <func:result select="$letters/l:l[@i=$index][1]"/>
146 <xsl:key name="group-code"
148 use="i:group-index(&primary;)"/>