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:fo="http://www.w3.org/1999/XSL/Format"
|
---|
8 | xmlns:rx="http://www.renderx.com/XSL/Extensions"
|
---|
9 | xmlns:axf="http://www.antennahouse.com/names/XSL/Extensions"
|
---|
10 | xmlns:i="urn:cz-kosek:functions:index"
|
---|
11 | xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0"
|
---|
12 | xmlns:func="http://exslt.org/functions"
|
---|
13 | xmlns:exslt="http://exslt.org/common"
|
---|
14 | extension-element-prefixes="func exslt"
|
---|
15 | exclude-result-prefixes="func exslt i l"
|
---|
16 | version="1.0">
|
---|
17 |
|
---|
18 | <!-- ********************************************************************
|
---|
19 | $Id: autoidx-kosek.xsl 8725 2010-07-15 08:08:04Z kosek $
|
---|
20 | ********************************************************************
|
---|
21 |
|
---|
22 | This file is part of the DocBook XSL Stylesheet distribution.
|
---|
23 | See ../README or http://docbook.sf.net/ for copyright
|
---|
24 | copyright and other information.
|
---|
25 |
|
---|
26 | ******************************************************************** -->
|
---|
27 |
|
---|
28 | <!-- ==================================================================== -->
|
---|
29 | <!-- The "kosek" method contributed by Jirka Kosek. -->
|
---|
30 |
|
---|
31 | <xsl:include href="../common/autoidx-kosek.xsl"/>
|
---|
32 |
|
---|
33 | <xsl:template name="generate-kosek-index">
|
---|
34 | <xsl:param name="scope" select="NOTANODE"/>
|
---|
35 |
|
---|
36 | <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
|
---|
37 | <xsl:if test="contains($vendor, 'libxslt')">
|
---|
38 | <xsl:message terminate="yes">
|
---|
39 | <xsl:text>ERROR: the 'kosek' index method does not </xsl:text>
|
---|
40 | <xsl:text>work with the xsltproc XSLT processor.</xsl:text>
|
---|
41 | </xsl:message>
|
---|
42 | </xsl:if>
|
---|
43 |
|
---|
44 | <xsl:if test="contains($vendor, 'Saxonica')">
|
---|
45 | <xsl:message terminate="yes">
|
---|
46 | <xsl:text>ERROR: the 'kosek' index method does not </xsl:text>
|
---|
47 | <xsl:text>work with the Saxon 8 XSLT processor.</xsl:text>
|
---|
48 | </xsl:message>
|
---|
49 | </xsl:if>
|
---|
50 |
|
---|
51 |
|
---|
52 | <xsl:if test="$exsl.node.set.available = 0">
|
---|
53 | <xsl:message terminate="yes">
|
---|
54 | <xsl:text>ERROR: the 'kosek' index method requires the </xsl:text>
|
---|
55 | <xsl:text>exslt:node-set() function. Use a processor that </xsl:text>
|
---|
56 | <xsl:text>has it, or use a different index method.</xsl:text>
|
---|
57 | </xsl:message>
|
---|
58 | </xsl:if>
|
---|
59 |
|
---|
60 | <xsl:if test="not(function-available('i:group-index'))">
|
---|
61 | <xsl:message terminate="yes">
|
---|
62 | <xsl:text>ERROR: the 'kosek' index method requires the
</xsl:text>
|
---|
63 | <xsl:text>index extension functions be imported:
</xsl:text>
|
---|
64 | <xsl:text> xsl:import href="common/autoidx-kosek.xsl"</xsl:text>
|
---|
65 | </xsl:message>
|
---|
66 | </xsl:if>
|
---|
67 |
|
---|
68 | <xsl:variable name="role">
|
---|
69 | <xsl:if test="$index.on.role != 0">
|
---|
70 | <xsl:value-of select="@role"/>
|
---|
71 | </xsl:if>
|
---|
72 | </xsl:variable>
|
---|
73 |
|
---|
74 | <xsl:variable name="type">
|
---|
75 | <xsl:if test="$index.on.type != 0">
|
---|
76 | <xsl:value-of select="@type"/>
|
---|
77 | </xsl:if>
|
---|
78 | </xsl:variable>
|
---|
79 |
|
---|
80 | <xsl:variable name="terms"
|
---|
81 | select="//indexterm[count(.|key('group-code',
|
---|
82 | i:group-index(&primary;))
|
---|
83 | [&scope;][1]) = 1
|
---|
84 | and not(@class = 'endofrange')]"/>
|
---|
85 | <fo:block>
|
---|
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 | </fo:block>
|
---|
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;]
|
---|
108 | [count(.|key('primary', &primary;)[&scope;][1]) = 1]">
|
---|
109 | <fo:block>
|
---|
110 | <xsl:call-template name="indexdiv.title">
|
---|
111 | <xsl:with-param name="titlecontent">
|
---|
112 | <xsl:choose>
|
---|
113 | <xsl:when test="$key = 0">
|
---|
114 | <xsl:call-template name="gentext">
|
---|
115 | <xsl:with-param name="key" select="'index symbols'"/>
|
---|
116 | </xsl:call-template>
|
---|
117 | </xsl:when>
|
---|
118 | <xsl:otherwise>
|
---|
119 | <xsl:value-of select="i:group-letter($key)"/>
|
---|
120 | </xsl:otherwise>
|
---|
121 | </xsl:choose>
|
---|
122 | </xsl:with-param>
|
---|
123 | </xsl:call-template>
|
---|
124 | <fo:block>
|
---|
125 | <xsl:apply-templates select="key('group-code', $key)[&scope;]
|
---|
126 | [count(.|key('primary', &primary;)
|
---|
127 | [&scope;][1])=1]"
|
---|
128 | mode="index-primary">
|
---|
129 | <xsl:sort select="&primary;" lang="{$lang}"/>
|
---|
130 | <xsl:with-param name="scope" select="$scope"/>
|
---|
131 | <xsl:with-param name="role" select="$role"/>
|
---|
132 | <xsl:with-param name="type" select="$type"/>
|
---|
133 | </xsl:apply-templates>
|
---|
134 | </fo:block>
|
---|
135 | </fo:block>
|
---|
136 | </xsl:if>
|
---|
137 | </xsl:template>
|
---|
138 |
|
---|
139 | </xsl:stylesheet>
|
---|