| 1 |
<?xml version="1.0"?> |
| 2 |
<!DOCTYPE xsl:stylesheet [ |
| 3 |
<!ENTITY % common.entities SYSTEM "../common/entities.ent"> |
| 4 |
%common.entities; |
| 5 |
]> |
| 6 |
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" |
| 7 |
xmlns:d="http://docbook.org/ns/docbook" |
| 8 |
xmlns:fo="http://www.w3.org/1999/XSL/Format" |
| 9 |
xmlns:rx="http://www.renderx.com/XSL/Extensions" |
| 10 |
xmlns:axf="http://www.antennahouse.com/names/XSL/Extensions" |
| 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:exslt="http://exslt.org/common" |
| 15 |
extension-element-prefixes="func exslt" |
| 16 |
exclude-result-prefixes="func exslt i l d" |
| 17 |
version="1.0"> |
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
<xsl:include href="../common/autoidx-kosek.xsl"/> |
| 31 |
|
| 32 |
<xsl:template name="generate-kosek-index"> |
| 33 |
<xsl:param name="scope" select="NOTANODE"/> |
| 34 |
|
| 35 |
<xsl:variable name="vendor" select="system-property('xsl:vendor')"/> |
| 36 |
<xsl:if test="contains($vendor, 'libxslt')"> |
| 37 |
<xsl:message terminate="yes"> |
| 38 |
<xsl:text>ERROR: the 'kosek' index method does not </xsl:text> |
| 39 |
<xsl:text>work with the xsltproc XSLT processor.</xsl:text> |
| 40 |
</xsl:message> |
| 41 |
</xsl:if> |
| 42 |
|
| 43 |
<xsl:if test="contains($vendor, 'Saxonica')"> |
| 44 |
<xsl:message terminate="yes"> |
| 45 |
<xsl:text>ERROR: the 'kosek' index method does not </xsl:text> |
| 46 |
<xsl:text>work with the Saxon 8 XSLT processor.</xsl:text> |
| 47 |
</xsl:message> |
| 48 |
</xsl:if> |
| 49 |
|
| 50 |
|
| 51 |
<xsl:if test="$exsl.node.set.available = 0"> |
| 52 |
<xsl:message terminate="yes"> |
| 53 |
<xsl:text>ERROR: the 'kosek' index method requires the </xsl:text> |
| 54 |
<xsl:text>exslt:node-set() function. Use a processor that </xsl:text> |
| 55 |
<xsl:text>has it, or use a different index method.</xsl:text> |
| 56 |
</xsl:message> |
| 57 |
</xsl:if> |
| 58 |
|
| 59 |
<xsl:if test="not(function-available('i:group-index'))"> |
| 60 |
<xsl:message terminate="yes"> |
| 61 |
<xsl:text>ERROR: the 'kosek' index method requires the
</xsl:text> |
| 62 |
<xsl:text>index extension functions be imported:
</xsl:text> |
| 63 |
<xsl:text> xsl:import href="common/autoidx-kosek.xsl"</xsl:text> |
| 64 |
</xsl:message> |
| 65 |
</xsl:if> |
| 66 |
|
| 67 |
<xsl:variable name="role"> |
| 68 |
<xsl:if test="$index.on.role != 0"> |
| 69 |
<xsl:value-of select="@role"/> |
| 70 |
</xsl:if> |
| 71 |
</xsl:variable> |
| 72 |
|
| 73 |
<xsl:variable name="type"> |
| 74 |
<xsl:if test="$index.on.type != 0"> |
| 75 |
<xsl:value-of select="@type"/> |
| 76 |
</xsl:if> |
| 77 |
</xsl:variable> |
| 78 |
|
| 79 |
<xsl:variable name="terms" |
| 80 |
select="//d:indexterm[count(.|key('group-code', |
| 81 |
i:group-index(&primary;)) |
| 82 |
[&scope;][1]) = 1 |
| 83 |
and not(@class = 'endofrange')]"/> |
| 84 |
<fo:block> |
| 85 |
<xsl:apply-templates select="$terms" mode="index-div-kosek"> |
| 86 |
<xsl:with-param name="scope" select="$scope"/> |
| 87 |
<xsl:with-param name="role" select="$role"/> |
| 88 |
<xsl:with-param name="type" select="$type"/> |
| 89 |
<xsl:sort select="i:group-index(&primary;)" data-type="number"/> |
| 90 |
</xsl:apply-templates> |
| 91 |
</fo:block> |
| 92 |
</xsl:template> |
| 93 |
|
| 94 |
<xsl:template match="d:indexterm" mode="index-div-kosek"> |
| 95 |
<xsl:param name="scope" select="."/> |
| 96 |
<xsl:param name="role" select="''"/> |
| 97 |
<xsl:param name="type" select="''"/> |
| 98 |
|
| 99 |
<xsl:variable name="key" |
| 100 |
select="i:group-index(&primary;)"/> |
| 101 |
|
| 102 |
<xsl:variable name="lang"> |
| 103 |
<xsl:call-template name="l10n.language"/> |
| 104 |
</xsl:variable> |
| 105 |
|
| 106 |
<xsl:if test="key('group-code', $key)[&scope;] |
| 107 |
[count(.|key('primary', &primary;)[&scope;][1]) = 1]"> |
| 108 |
<fo:block> |
| 109 |
<xsl:call-template name="indexdiv.title"> |
| 110 |
<xsl:with-param name="titlecontent"> |
| 111 |
<xsl:choose> |
| 112 |
<xsl:when test="$key = 0"> |
| 113 |
<xsl:call-template name="gentext"> |
| 114 |
<xsl:with-param name="key" select="'index symbols'"/> |
| 115 |
</xsl:call-template> |
| 116 |
</xsl:when> |
| 117 |
<xsl:otherwise> |
| 118 |
<xsl:value-of select="i:group-letter($key)"/> |
| 119 |
</xsl:otherwise> |
| 120 |
</xsl:choose> |
| 121 |
</xsl:with-param> |
| 122 |
</xsl:call-template> |
| 123 |
<fo:block> |
| 124 |
<xsl:apply-templates select="key('group-code', $key)[&scope;] |
| 125 |
[count(.|key('primary', &primary;) |
| 126 |
[&scope;][1])=1]" |
| 127 |
mode="index-primary"> |
| 128 |
<xsl:sort select="&primary;" lang="{$lang}"/> |
| 129 |
<xsl:with-param name="scope" select="$scope"/> |
| 130 |
<xsl:with-param name="role" select="$role"/> |
| 131 |
<xsl:with-param name="type" select="$type"/> |
| 132 |
</xsl:apply-templates> |
| 133 |
</fo:block> |
| 134 |
</fo:block> |
| 135 |
</xsl:if> |
| 136 |
</xsl:template> |
| 137 |
|
| 138 |
</xsl:stylesheet> |