| 1 |
<?xml version="1.0"?> |
| 2 |
<!DOCTYPE xsl:stylesheet [ |
| 3 |
<!ENTITY primary 'normalize-space(concat(primary/@sortas, primary[not(@sortas)]))'> |
| 4 |
|
| 5 |
]> |
| 6 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 7 |
version="1.0" |
| 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"> |
| 15 |
|
| 16 |
<!-- ******************************************************************** |
| 17 |
$Id: autoidx-kosek.xsl 6910 2007-06-28 23:23:30Z xmldoc $ |
| 18 |
******************************************************************** |
| 19 |
|
| 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. |
| 23 |
|
| 24 |
******************************************************************** --> |
| 25 |
|
| 26 |
<xsl:param name="kosek.imported"> |
| 27 |
<xsl:variable name="vendor" select="system-property('xsl:vendor')"/> |
| 28 |
<xsl:choose> |
| 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> |
| 33 |
</xsl:message> |
| 34 |
</xsl:when> |
| 35 |
<xsl:otherwise>1</xsl:otherwise> |
| 36 |
</xsl:choose> |
| 37 |
</xsl:param> |
| 38 |
|
| 39 |
<!-- Returns index group code for given term --> |
| 40 |
<func:function name="i:group-index"> |
| 41 |
<xsl:param name="term"/> |
| 42 |
|
| 43 |
<xsl:variable name="letters-rtf"> |
| 44 |
<xsl:variable name="lang"> |
| 45 |
<xsl:call-template name="l10n.language"/> |
| 46 |
</xsl:variable> |
| 47 |
|
| 48 |
<xsl:variable name="local.l10n.letters" |
| 49 |
select="($local.l10n.xml//l:i18n/l:l10n[@language=$lang]/l:letters)[1]"/> |
| 50 |
|
| 51 |
<xsl:variable name="l10n.letters" |
| 52 |
select="($l10n.xml/l:i18n/l:l10n[@language=$lang]/l:letters)[1]"/> |
| 53 |
|
| 54 |
<xsl:choose> |
| 55 |
<xsl:when test="count($local.l10n.letters) > 0"> |
| 56 |
<xsl:copy-of select="$local.l10n.letters"/> |
| 57 |
</xsl:when> |
| 58 |
<xsl:when test="count($l10n.letters) > 0"> |
| 59 |
<xsl:copy-of select="$l10n.letters"/> |
| 60 |
</xsl:when> |
| 61 |
<xsl:otherwise> |
| 62 |
<xsl:message> |
| 63 |
<xsl:text>No "</xsl:text> |
| 64 |
<xsl:value-of select="$lang"/> |
| 65 |
<xsl:text>" localization of index grouping letters exists</xsl:text> |
| 66 |
<xsl:choose> |
| 67 |
<xsl:when test="$lang = 'en'"> |
| 68 |
<xsl:text>.</xsl:text> |
| 69 |
</xsl:when> |
| 70 |
<xsl:otherwise> |
| 71 |
<xsl:text>; using "en".</xsl:text> |
| 72 |
</xsl:otherwise> |
| 73 |
</xsl:choose> |
| 74 |
</xsl:message> |
| 75 |
|
| 76 |
<xsl:copy-of select="($l10n.xml/l:i18n/l:l10n[@language='en']/l:letters)[1]"/> |
| 77 |
</xsl:otherwise> |
| 78 |
</xsl:choose> |
| 79 |
</xsl:variable> |
| 80 |
|
| 81 |
<xsl:variable name="letters" select="exslt:node-set($letters-rtf)/*"/> |
| 82 |
|
| 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"> |
| 86 |
<xsl:choose> |
| 87 |
<xsl:when test="$long-letter-index"> |
| 88 |
<xsl:value-of select="$long-letter-index"/> |
| 89 |
</xsl:when> |
| 90 |
<xsl:when test="$short-letter-index"> |
| 91 |
<xsl:value-of select="$short-letter-index"/> |
| 92 |
</xsl:when> |
| 93 |
<xsl:otherwise>0</xsl:otherwise> |
| 94 |
</xsl:choose> |
| 95 |
</xsl:variable> |
| 96 |
<func:result select="number($letter-index)"/> |
| 97 |
</func:function> |
| 98 |
|
| 99 |
<!-- Return index group letter for given group code --> |
| 100 |
<func:function name="i:group-letter"> |
| 101 |
<xsl:param name="index"/> |
| 102 |
|
| 103 |
<xsl:variable name="letters-rtf"> |
| 104 |
<xsl:variable name="lang"> |
| 105 |
<xsl:call-template name="l10n.language"/> |
| 106 |
</xsl:variable> |
| 107 |
|
| 108 |
<xsl:variable name="local.l10n.letters" |
| 109 |
select="($local.l10n.xml//l:i18n/l:l10n[@language=$lang]/l:letters)[1]"/> |
| 110 |
|
| 111 |
<xsl:variable name="l10n.letters" |
| 112 |
select="($l10n.xml/l:i18n/l:l10n[@language=$lang]/l:letters)[1]"/> |
| 113 |
|
| 114 |
<xsl:choose> |
| 115 |
<xsl:when test="count($local.l10n.letters) > 0"> |
| 116 |
<xsl:copy-of select="$local.l10n.letters"/> |
| 117 |
</xsl:when> |
| 118 |
<xsl:when test="count($l10n.letters) > 0"> |
| 119 |
<xsl:copy-of select="$l10n.letters"/> |
| 120 |
</xsl:when> |
| 121 |
<xsl:otherwise> |
| 122 |
<xsl:message> |
| 123 |
<xsl:text>No "</xsl:text> |
| 124 |
<xsl:value-of select="$lang"/> |
| 125 |
<xsl:text>" localization of index grouping letters exists</xsl:text> |
| 126 |
<xsl:choose> |
| 127 |
<xsl:when test="$lang = 'en'"> |
| 128 |
<xsl:text>.</xsl:text> |
| 129 |
</xsl:when> |
| 130 |
<xsl:otherwise> |
| 131 |
<xsl:text>; using "en".</xsl:text> |
| 132 |
</xsl:otherwise> |
| 133 |
</xsl:choose> |
| 134 |
</xsl:message> |
| 135 |
|
| 136 |
<xsl:copy-of select="($l10n.xml/l:i18n/l:l10n[@language='en']/l:letters)[1]"/> |
| 137 |
</xsl:otherwise> |
| 138 |
</xsl:choose> |
| 139 |
</xsl:variable> |
| 140 |
|
| 141 |
<xsl:variable name="letters" select="exslt:node-set($letters-rtf)/*"/> |
| 142 |
|
| 143 |
<func:result select="$letters/l:l[@i=$index][1]"/> |
| 144 |
</func:function> |
| 145 |
|
| 146 |
<xsl:key name="group-code" |
| 147 |
match="indexterm" |
| 148 |
use="i:group-index(&primary;)"/> |
| 149 |
|
| 150 |
</xsl:stylesheet> |