]> git.lyx.org Git - lyx.git/blob - lib/docbook/xhtml/autoidx-kimber.xsl
Use same find-dialogs as other bind-files also for x?emacs
[lyx.git] / lib / docbook / xhtml / autoidx-kimber.xsl
1 <?xml version="1.0" encoding="ASCII"?><!--This file was created automatically by html2xhtml--><!--from the HTML stylesheets.--><xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:d="http://docbook.org/ns/docbook" xmlns:k="http://www.isogen.com/functions/com.isogen.saxoni18n.Saxoni18nService" xmlns="http://www.w3.org/1999/xhtml" exclude-result-prefixes="k d" version="1.0">
2
3 <!-- ********************************************************************
4
5      This file is part of the XSL DocBook Stylesheet distribution.
6      See ../README or http://cdn.docbook.org/release/xsl/current/ for
7      copyright and other information.
8
9      ******************************************************************** -->
10
11 <!-- ==================================================================== -->
12 <!-- The "kimber" method contributed by Eliot Kimber of Innodata Isogen.  -->
13 <!-- ==================================================================== -->
14 <!--   *** THIS MODULE ONLY WORKS WITH SAXON 6 OR SAXON 8 ***             -->
15 <!-- ==================================================================== -->
16
17
18 <xsl:include href="../common/autoidx-kimber.xsl"/>
19
20 <!-- Java sort apparently works only on lang part, not country -->
21 <xsl:param name="sort.lang">
22   <xsl:choose>
23     <xsl:when test="contains(concat(/*/@lang, /*/@xml:lang), '-')">
24       <xsl:value-of select="substring-before(concat(/*/@lang, /*/@xml:lang), '-')"/>
25     </xsl:when>
26     <xsl:when test="contains(concat(/*/@lang, /*/@xml:lang), '_')">
27       <xsl:value-of select="substring-before(concat(/*/@lang, /*/@xml:lang), '_')"/>
28     </xsl:when>
29     <xsl:otherwise>
30       <xsl:value-of select="concat(/*/@lang, /*/@xml:lang)"/>
31     </xsl:otherwise>
32   </xsl:choose>
33 </xsl:param>
34
35 <xsl:template name="generate-kimber-index">
36   <xsl:param name="scope" select="NOTANODE"/>
37
38   <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
39   <xsl:if test="not(contains($vendor, 'SAXON '))">
40     <xsl:message terminate="yes">
41       <xsl:text>ERROR: the 'kimber' index method requires the </xsl:text>
42       <xsl:text>Saxon version 6 or 8 XSLT processor.</xsl:text>
43     </xsl:message>
44   </xsl:if>
45
46   <xsl:if test="not(function-available('k:getIndexGroupKey'))">
47     <xsl:message terminate="yes">
48       <xsl:text>ERROR: the 'kimber' index method requires the </xsl:text>
49       <xsl:text>Innodata Isogen 
50 Java extensions for </xsl:text>
51       <xsl:text>internationalized indexes. 
52 Install those </xsl:text>
53       <xsl:text>extensions, or use a different index method.
54 </xsl:text>
55       <xsl:text>For more information, see:
56 </xsl:text>
57       <xsl:text>http://www.innodata-isogen.com/knowledge_center/tools_downloads/i18nsupport</xsl:text>
58     </xsl:message>
59   </xsl:if>
60
61   <xsl:variable name="role">
62     <xsl:if test="$index.on.role != 0">
63       <xsl:value-of select="@role"/>
64     </xsl:if>
65   </xsl:variable>
66
67   <xsl:variable name="type">
68     <xsl:if test="$index.on.type != 0">
69       <xsl:value-of select="@type"/>
70     </xsl:if>
71   </xsl:variable>
72
73   <xsl:variable name="terms" select="//d:indexterm[count(.|key('k-group', k:getIndexGroupKey(concat(/*/@lang, /*/@xml:lang), normalize-space(concat(d:primary/@sortas, &#34; &#34;, d:primary))))[count(ancestor::node()|$scope) = count(ancestor::node()) and ($role = @role or $type = @type or (string-length($role) = 0 and string-length($type) = 0))][1]) = 1 and not(@class = 'endofrange')]"/>
74
75   <xsl:variable name="alphabetical" select="$terms[not(starts-with(                 k:getIndexGroupKey(concat(/*/@lang, /*/@xml:lang), normalize-space(concat(d:primary/@sortas, &#34; &#34;, d:primary))),                 '#NUMERIC'                 ))]"/>
76
77   <xsl:variable name="others" select="$terms[starts-with(                 k:getIndexGroupKey(concat(/*/@lang, /*/@xml:lang), normalize-space(concat(d:primary/@sortas, &#34; &#34;, d:primary))),                 '#NUMERIC'                 )]"/>
78
79   <div class="index">
80     <xsl:if test="$others">
81       <div class="indexdev">
82         <h3>
83           <xsl:call-template name="gentext">
84             <xsl:with-param name="key" select="'index symbols'"/>
85           </xsl:call-template>
86         </h3>
87         <dl>
88           <xsl:apply-templates select="$others" mode="index-symbol-div">
89             <xsl:with-param name="scope" select="$scope"/>
90             <xsl:with-param name="role" select="$role"/>
91             <xsl:with-param name="type" select="$type"/>
92             <xsl:sort lang="{$sort.lang}" select="k:getIndexGroupSortKey(concat(/*/@lang, /*/@xml:lang),                         k:getIndexGroupKey(concat(/*/@lang, /*/@xml:lang), normalize-space(concat(d:primary/@sortas, &#34; &#34;, d:primary))))"/>
93           </xsl:apply-templates>
94         </dl>
95       </div>
96     </xsl:if>
97
98     <xsl:apply-templates select="$alphabetical" mode="index-div-kimber">
99       <xsl:with-param name="scope" select="$scope"/>
100       <xsl:with-param name="role" select="$role"/>
101       <xsl:with-param name="type" select="$type"/>
102       <xsl:sort lang="{$sort.lang}" select="k:getIndexGroupSortKey(concat(/*/@lang, /*/@xml:lang),                      k:getIndexGroupKey(concat(/*/@lang, /*/@xml:lang), normalize-space(concat(d:primary/@sortas, &#34; &#34;, d:primary))))"/>
103     </xsl:apply-templates>
104   </div>
105
106 </xsl:template>
107
108 <xsl:template match="d:indexterm" mode="index-div-kimber">
109   <xsl:param name="scope" select="."/>
110   <xsl:param name="role" select="''"/>
111   <xsl:param name="type" select="''"/>
112
113   <xsl:variable name="key" select="k:getIndexGroupKey(concat(/*/@lang, /*/@xml:lang), normalize-space(concat(d:primary/@sortas, &#34; &#34;, d:primary)))"/>
114
115   <xsl:variable name="label" select="k:getIndexGroupLabel(concat(/*/@lang, /*/@xml:lang), $key)"/>
116
117   <xsl:if test="key('k-group', $label)[count(ancestor::node()|$scope) = count(ancestor::node()) and ($role = @role or $type = @type or (string-length($role) = 0 and string-length($type) = 0))][count(.|key('primary', normalize-space(concat(d:primary/@sortas, &#34; &#34;, d:primary)))[count(ancestor::node()|$scope) = count(ancestor::node()) and ($role = @role or $type = @type or (string-length($role) = 0 and string-length($type) = 0))][1]) = 1]">
118     <div class="indexdiv">
119       <h3>
120         <xsl:value-of select="$label"/>
121       </h3>
122       <dl>
123         <xsl:apply-templates select="key('k-group', $key)[count(ancestor::node()|$scope) = count(ancestor::node()) and ($role = @role or $type = @type or (string-length($role) = 0 and string-length($type) = 0))]                             [count(.|key('primary', normalize-space(concat(d:primary/@sortas, &#34; &#34;, d:primary)))[count(ancestor::node()|$scope) = count(ancestor::node()) and ($role = @role or $type = @type or (string-length($role) = 0 and string-length($type) = 0))]                             [1])=1]" mode="index-primary">
124           <xsl:sort select="normalize-space(concat(d:primary/@sortas, &#34; &#34;, d:primary))" lang="{$sort.lang}"/>
125           <xsl:with-param name="scope" select="$scope"/>
126           <xsl:with-param name="role" select="$role"/>
127           <xsl:with-param name="type" select="$type"/>
128         </xsl:apply-templates>
129       </dl>
130     </div>
131   </xsl:if>
132 </xsl:template>
133
134 </xsl:stylesheet>