]> git.evergreen-ils.org Git - working/Evergreen.git/blob - stylesheets/styleguide/docbook-xsl-1.75.2/html/autoidx-kimber.xsl
stylesheet changes.
[working/Evergreen.git] / stylesheets / styleguide / docbook-xsl-1.75.2 / html / autoidx-kimber.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 <!-- Documents using the kimber index method must have a lang attribute -->
9 <!-- Only one of these should be present in the entity -->
10 <!ENTITY lang 'concat(/*/@lang, /*/@xml:lang)'>
11
12 <!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))'>
13 ]>
14 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
15                 xmlns:k="http://www.isogen.com/functions/com.isogen.saxoni18n.Saxoni18nService"
16                 exclude-result-prefixes="k"
17                 version="1.0">
18
19 <!-- ********************************************************************
20      $Id: autoidx-kimber.xsl 6910 2007-06-28 23:23:30Z xmldoc $
21      ********************************************************************
22
23      This file is part of the XSL DocBook Stylesheet distribution.
24      See ../README or http://docbook.sf.net/release/xsl/current/ for
25      copyright and other information.
26
27      ******************************************************************** -->
28
29 <!-- ==================================================================== -->
30 <!-- The "kimber" method contributed by Eliot Kimber of Innodata Isogen.  -->
31 <!-- ==================================================================== -->
32 <!--   *** THIS MODULE ONLY WORKS WITH SAXON 6 OR SAXON 8 ***             -->
33 <!-- ==================================================================== -->
34
35
36 <xsl:include href="../common/autoidx-kimber.xsl"/>
37
38 <!-- Java sort apparently works only on lang part, not country -->
39 <xsl:param name="sort.lang">
40   <xsl:choose>
41     <xsl:when test="contains(&lang;, '-')">
42       <xsl:value-of select="substring-before(&lang;, '-')"/>
43     </xsl:when>
44     <xsl:when test="contains(&lang;, '_')">
45       <xsl:value-of select="substring-before(&lang;, '_')"/>
46     </xsl:when>
47     <xsl:otherwise>
48       <xsl:value-of select="&lang;"/>
49     </xsl:otherwise>
50   </xsl:choose>
51 </xsl:param>
52
53 <xsl:template name="generate-kimber-index">
54   <xsl:param name="scope" select="NOTANODE"/>
55
56   <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
57   <xsl:if test="not(contains($vendor, 'SAXON '))">
58     <xsl:message terminate="yes">
59       <xsl:text>ERROR: the 'kimber' index method requires the </xsl:text>
60       <xsl:text>Saxon version 6 or 8 XSLT processor.</xsl:text>
61     </xsl:message>
62   </xsl:if>
63
64   <xsl:if test="not(function-available('k:getIndexGroupKey'))">
65     <xsl:message terminate="yes">
66       <xsl:text>ERROR: the 'kimber' index method requires the </xsl:text>
67       <xsl:text>Innodata Isogen &#x0A;Java extensions for </xsl:text>
68       <xsl:text>internationalized indexes. &#x0A;Install those </xsl:text>
69       <xsl:text>extensions, or use a different index method.&#x0A;</xsl:text>
70       <xsl:text>For more information, see:&#x0A;</xsl:text>
71       <xsl:text>http://www.innodata-isogen.com/knowledge_center/tools_downloads/i18nsupport</xsl:text>
72     </xsl:message>
73   </xsl:if>
74
75   <xsl:variable name="role">
76     <xsl:if test="$index.on.role != 0">
77       <xsl:value-of select="@role"/>
78     </xsl:if>
79   </xsl:variable>
80
81   <xsl:variable name="type">
82     <xsl:if test="$index.on.type != 0">
83       <xsl:value-of select="@type"/>
84     </xsl:if>
85   </xsl:variable>
86
87   <xsl:variable name="terms"
88                 select="//indexterm[count(.|key('k-group', k:getIndexGroupKey(&lang;, &primary;))[&scope;][1]) = 1 and not(@class = 'endofrange')]"/>
89
90   <xsl:variable name="alphabetical"
91                 select="$terms[not(starts-with(
92                 k:getIndexGroupKey(&lang;, &primary;),
93                 '#NUMERIC'
94                 ))]"/>
95
96   <xsl:variable name="others"
97                 select="$terms[starts-with(
98                 k:getIndexGroupKey(&lang;, &primary;),
99                 '#NUMERIC'
100                 )]"/>
101
102   <div class="index">
103     <xsl:if test="$others">
104       <div class="indexdev">
105         <h3>
106           <xsl:call-template name="gentext">
107             <xsl:with-param name="key" select="'index symbols'"/>
108           </xsl:call-template>
109         </h3>
110         <dl>
111           <xsl:apply-templates select="$others"
112                                mode="index-symbol-div">
113             <xsl:with-param name="scope" select="$scope"/>
114             <xsl:with-param name="role" select="$role"/>
115             <xsl:with-param name="type" select="$type"/>
116             <xsl:sort lang="{$sort.lang}"
117                 select="k:getIndexGroupSortKey(&lang;,
118                         k:getIndexGroupKey(&lang;, &primary;))"/>
119           </xsl:apply-templates>
120         </dl>
121       </div>
122     </xsl:if>
123
124     <xsl:apply-templates select="$alphabetical"
125                          mode="index-div-kimber">
126       <xsl:with-param name="scope" select="$scope"/>
127       <xsl:with-param name="role" select="$role"/>
128       <xsl:with-param name="type" select="$type"/>
129       <xsl:sort lang="{$sort.lang}"
130              select="k:getIndexGroupSortKey(&lang;,
131                      k:getIndexGroupKey(&lang;, &primary;))"/>
132     </xsl:apply-templates>
133   </div>
134
135 </xsl:template>
136
137 <xsl:template match="indexterm" mode="index-div-kimber">
138   <xsl:param name="scope" select="."/>
139   <xsl:param name="role" select="''"/>
140   <xsl:param name="type" select="''"/>
141
142   <xsl:variable name="key"
143           select="k:getIndexGroupKey(&lang;, &primary;)"/>
144
145   <xsl:variable name="label"
146           select="k:getIndexGroupLabel(&lang;, $key)"/>
147
148   <xsl:if test="key('k-group', $label)[&scope;][count(.|key('primary', &primary;)[&scope;][1]) = 1]">
149     <div class="indexdiv">
150       <h3>
151         <xsl:value-of select="$label"/>
152       </h3>
153       <dl>
154         <xsl:apply-templates select="key('k-group', $key)[&scope;]
155                             [count(.|key('primary', &primary;)[&scope;]
156                             [1])=1]"
157                              mode="index-primary">
158           <xsl:sort select="&primary;" lang="{$sort.lang}"/>
159           <xsl:with-param name="scope" select="$scope"/>
160           <xsl:with-param name="role" select="$role"/>
161           <xsl:with-param name="type" select="$type"/>
162         </xsl:apply-templates>
163       </dl>
164     </div>
165   </xsl:if>
166 </xsl:template>
167
168 </xsl:stylesheet>