]> git.evergreen-ils.org Git - working/Evergreen.git/blob - stylesheets/evergreen_docbook_files/docbook-xsl-1.75.2/html/autoidx-kosek.xsl
Add stylesheets for our evergreen docbook site.
[working/Evergreen.git] / stylesheets / evergreen_docbook_files / docbook-xsl-1.75.2 / html / autoidx-kosek.xsl
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 8399 2009-04-08 07:37:42Z bobstayton $
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="$exsl.node.set.available = 0">
54     <xsl:message terminate="yes">
55       <xsl:text>ERROR: the 'kosek' index method requires the </xsl:text>
56       <xsl:text>exslt:node-set() function. Use a processor that </xsl:text>
57       <xsl:text>has it, or use a different index method.</xsl:text>
58     </xsl:message>
59   </xsl:if>
60
61   <xsl:if test="not(function-available('i:group-index'))">
62     <xsl:message terminate="yes">
63       <xsl:text>ERROR: the 'kosek' index method requires the&#xA;</xsl:text>
64       <xsl:text>index extension functions be imported:&#xA;</xsl:text>
65       <xsl:text>  xsl:import href="common/autoidx-kosek.xsl"</xsl:text>
66     </xsl:message>
67   </xsl:if>
68
69   <xsl:variable name="role">
70     <xsl:if test="$index.on.role != 0">
71       <xsl:value-of select="@role"/>
72     </xsl:if>
73   </xsl:variable>
74
75   <xsl:variable name="type">
76     <xsl:if test="$index.on.type != 0">
77       <xsl:value-of select="@type"/>
78     </xsl:if>
79   </xsl:variable>
80
81   <xsl:variable name="terms"
82                 select="//indexterm[count(.|key('group-code', i:group-index(&primary;))[&scope;][1]) = 1 and not(@class = 'endofrange')]"/>
83
84   <div class="index">
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   </div>
92 </xsl:template>
93
94 <xsl:template match="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;][count(.|key('primary', &primary;)[&scope;][1]) = 1]">
107     <div class="indexdiv">
108       <h3>
109         <xsl:value-of select="i:group-letter($key)"/>
110       </h3>
111       <dl>
112         <xsl:apply-templates select="key('group-code', $key)[&scope;][count(.|key('primary', &primary;)[&scope;][1])=1]"
113                              mode="index-primary">
114           <xsl:sort select="&primary;" lang="{$lang}"/>
115           <xsl:with-param name="scope" select="$scope"/>
116           <xsl:with-param name="role" select="$role"/>
117           <xsl:with-param name="type" select="$type"/>
118         </xsl:apply-templates>
119       </dl>
120     </div>
121   </xsl:if>
122 </xsl:template>
123
124 </xsl:stylesheet>