| 1 |
<?xml version="1.0"?> |
| 2 |
<!DOCTYPE xsl:stylesheet [ |
| 3 |
|
| 4 |
<!ENTITY primary 'normalize-space(concat(primary/@sortas, primary[not(@sortas) or @sortas = ""]))'> |
| 5 |
<!ENTITY secondary 'normalize-space(concat(secondary/@sortas, secondary[not(@sortas) or @sortas = ""]))'> |
| 6 |
<!ENTITY tertiary 'normalize-space(concat(tertiary/@sortas, tertiary[not(@sortas) or @sortas = ""]))'> |
| 7 |
|
| 8 |
<!ENTITY scope 'count(ancestor::node()|$scope) = count(ancestor::node()) and ($role = @role or $type = @type or (string-length($role) = 0 and string-length($type) = 0))'> |
| 9 |
]> |
| 10 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 11 |
xmlns:i="urn:cz-kosek:functions:index" |
| 12 |
xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" |
| 13 |
xmlns:func="http://exslt.org/functions" |
| 14 |
xmlns:k="http://www.isogen.com/functions/com.isogen.saxoni18n.Saxoni18nService" |
| 15 |
xmlns:exslt="http://exslt.org/common" |
| 16 |
extension-element-prefixes="func exslt" |
| 17 |
exclude-result-prefixes="func exslt i l k" |
| 18 |
version="1.0"> |
| 19 |
|
| 20 |
<!-- ******************************************************************** |
| 21 |
$Id: autoidx-kosek.xsl 6910 2007-06-28 23:23:30Z xmldoc $ |
| 22 |
******************************************************************** |
| 23 |
|
| 24 |
This file is part of the XSL DocBook Stylesheet distribution. |
| 25 |
See ../README or http://docbook.sf.net/release/xsl/current/ for |
| 26 |
copyright and other information. |
| 27 |
|
| 28 |
******************************************************************** --> |
| 29 |
|
| 30 |
<!-- ==================================================================== --> |
| 31 |
<!-- The "kosek" method contributed by Jirka Kosek. --> |
| 32 |
|
| 33 |
<xsl:include href="../common/autoidx-kosek.xsl"/> |
| 34 |
|
| 35 |
<xsl:template name="generate-kosek-index"> |
| 36 |
<xsl:param name="scope" select="(ancestor::book|/)[last()]"/> |
| 37 |
|
| 38 |
<xsl:variable name="vendor" select="system-property('xsl:vendor')"/> |
| 39 |
<xsl:if test="contains($vendor, 'libxslt')"> |
| 40 |
<xsl:message terminate="yes"> |
| 41 |
<xsl:text>ERROR: the 'kosek' index method does not </xsl:text> |
| 42 |
<xsl:text>work with the xsltproc XSLT processor.</xsl:text> |
| 43 |
</xsl:message> |
| 44 |
</xsl:if> |
| 45 |
|
| 46 |
<xsl:if test="contains($vendor, 'Saxonica')"> |
| 47 |
<xsl:message terminate="yes"> |
| 48 |
<xsl:text>ERROR: the 'kosek' index method does not </xsl:text> |
| 49 |
<xsl:text>work with the Saxon 8 XSLT processor.</xsl:text> |
| 50 |
</xsl:message> |
| 51 |
</xsl:if> |
| 52 |
|
| 53 |
<xsl:if test="not(function-available('exslt:node-set') or |
| 54 |
function-available('exslt:nodeSet'))"> |
| 55 |
<xsl:message terminate="yes"> |
| 56 |
<xsl:text>ERROR: the 'kosek' index method requires the </xsl:text> |
| 57 |
<xsl:text>exslt:node-set() function. Use a processor that </xsl:text> |
| 58 |
<xsl:text>has it, or use a different index method.</xsl:text> |
| 59 |
</xsl:message> |
| 60 |
</xsl:if> |
| 61 |
|
| 62 |
<xsl:if test="not(function-available('i:group-index'))"> |
| 63 |
<xsl:message terminate="yes"> |
| 64 |
<xsl:text>ERROR: the 'kosek' index method requires the
</xsl:text> |
| 65 |
<xsl:text>index extension functions be imported:
</xsl:text> |
| 66 |
<xsl:text> xsl:import href="common/autoidx-kosek.xsl"</xsl:text> |
| 67 |
</xsl:message> |
| 68 |
</xsl:if> |
| 69 |
|
| 70 |
<xsl:variable name="role"> |
| 71 |
<xsl:if test="$index.on.role != 0"> |
| 72 |
<xsl:value-of select="@role"/> |
| 73 |
</xsl:if> |
| 74 |
</xsl:variable> |
| 75 |
|
| 76 |
<xsl:variable name="type"> |
| 77 |
<xsl:if test="$index.on.type != 0"> |
| 78 |
<xsl:value-of select="@type"/> |
| 79 |
</xsl:if> |
| 80 |
</xsl:variable> |
| 81 |
|
| 82 |
<xsl:variable name="terms" |
| 83 |
select="//indexterm[count(.|key('group-code', i:group-index(&primary;))[&scope;][1]) = 1 and not(@class = 'endofrange')]"/> |
| 84 |
|
| 85 |
<div class="index"> |
| 86 |
<xsl:apply-templates select="$terms" mode="index-div-kosek"> |
| 87 |
<xsl:with-param name="scope" select="$scope"/> |
| 88 |
<xsl:with-param name="role" select="$role"/> |
| 89 |
<xsl:with-param name="type" select="$type"/> |
| 90 |
<xsl:sort select="i:group-index(&primary;)" data-type="number"/> |
| 91 |
</xsl:apply-templates> |
| 92 |
</div> |
| 93 |
</xsl:template> |
| 94 |
|
| 95 |
<xsl:template match="indexterm" mode="index-div-kosek"> |
| 96 |
<xsl:param name="scope" select="."/> |
| 97 |
<xsl:param name="role" select="''"/> |
| 98 |
<xsl:param name="type" select="''"/> |
| 99 |
|
| 100 |
<xsl:variable name="key" |
| 101 |
select="i:group-index(&primary;)"/> |
| 102 |
|
| 103 |
<xsl:variable name="lang"> |
| 104 |
<xsl:call-template name="l10n.language"/> |
| 105 |
</xsl:variable> |
| 106 |
|
| 107 |
<xsl:if test="key('group-code', $key)[&scope;][count(.|key('primary', &primary;)[&scope;][1]) = 1]"> |
| 108 |
<div class="indexdiv"> |
| 109 |
<h3> |
| 110 |
<xsl:value-of select="i:group-letter($key)"/> |
| 111 |
</h3> |
| 112 |
<dl> |
| 113 |
<xsl:apply-templates select="key('group-code', $key)[&scope;][count(.|key('primary', &primary;)[&scope;][1])=1]" |
| 114 |
mode="index-primary"> |
| 115 |
<xsl:sort select="&primary;" lang="{$lang}"/> |
| 116 |
<xsl:with-param name="scope" select="$scope"/> |
| 117 |
<xsl:with-param name="role" select="$role"/> |
| 118 |
<xsl:with-param name="type" select="$type"/> |
| 119 |
</xsl:apply-templates> |
| 120 |
</dl> |
| 121 |
</div> |
| 122 |
</xsl:if> |
| 123 |
</xsl:template> |
| 124 |
|
| 125 |
</xsl:stylesheet> |