]> git.lyx.org Git - lyx.git/blob - lib/docbook/xhtml/autoidx-kosek.xsl
Use same find-dialogs as other bind-files also for x?emacs
[lyx.git] / lib / docbook / xhtml / autoidx-kosek.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:i="urn:cz-kosek:functions:index" xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0" xmlns:func="http://exslt.org/functions" xmlns:k="http://www.isogen.com/functions/com.isogen.saxoni18n.Saxoni18nService" xmlns:exslt="http://exslt.org/common" xmlns="http://www.w3.org/1999/xhtml" extension-element-prefixes="func exslt" exclude-result-prefixes="func exslt i l 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 "kosek" method contributed by Jirka Kosek. -->
13
14 <xsl:include href="../common/autoidx-kosek.xsl"/>
15
16 <xsl:template name="generate-kosek-index">
17   <xsl:param name="scope" select="(ancestor::d:book|/)[last()]"/>
18
19   <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
20   <xsl:if test="contains($vendor, 'libxslt')">
21     <xsl:message terminate="yes">
22       <xsl:text>ERROR: the 'kosek' index method does not </xsl:text>
23       <xsl:text>work with the xsltproc XSLT processor.</xsl:text>
24     </xsl:message>
25   </xsl:if>
26
27   <xsl:if test="contains($vendor, 'Saxonica')">
28     <xsl:message terminate="yes">
29       <xsl:text>ERROR: the 'kosek' index method does not </xsl:text>
30       <xsl:text>work with the Saxon 8 XSLT processor.</xsl:text>
31     </xsl:message>
32   </xsl:if>
33
34   <xsl:if test="$exsl.node.set.available = 0">
35     <xsl:message terminate="yes">
36       <xsl:text>ERROR: the 'kosek' index method requires the </xsl:text>
37       <xsl:text>exslt:node-set() function. Use a processor that </xsl:text>
38       <xsl:text>has it, or use a different index method.</xsl:text>
39     </xsl:message>
40   </xsl:if>
41
42   <xsl:if test="not(function-available('i:group-index'))">
43     <xsl:message terminate="yes">
44       <xsl:text>ERROR: the 'kosek' index method requires the
45 </xsl:text>
46       <xsl:text>index extension functions be imported:
47 </xsl:text>
48       <xsl:text>  xsl:import href="common/autoidx-kosek.xsl"</xsl:text>
49     </xsl:message>
50   </xsl:if>
51
52   <xsl:variable name="role">
53     <xsl:if test="$index.on.role != 0">
54       <xsl:value-of select="@role"/>
55     </xsl:if>
56   </xsl:variable>
57
58   <xsl:variable name="type">
59     <xsl:if test="$index.on.type != 0">
60       <xsl:value-of select="@type"/>
61     </xsl:if>
62   </xsl:variable>
63
64   <xsl:variable name="terms" select="//d:indexterm[count(.|key('group-code', i:group-index(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')]"/>
65
66   <div class="index">
67     <xsl:apply-templates select="$terms" mode="index-div-kosek">
68       <xsl:with-param name="scope" select="$scope"/>
69       <xsl:with-param name="role" select="$role"/>
70       <xsl:with-param name="type" select="$type"/>
71       <xsl:sort select="i:group-index(normalize-space(concat(d:primary/@sortas, &#34; &#34;, d:primary)))" data-type="number"/>
72     </xsl:apply-templates>
73   </div>
74 </xsl:template>
75
76 <xsl:template match="d:indexterm" mode="index-div-kosek">
77   <xsl:param name="scope" select="."/>
78   <xsl:param name="role" select="''"/>
79   <xsl:param name="type" select="''"/>
80
81   <xsl:variable name="key" select="i:group-index(normalize-space(concat(d:primary/@sortas, &#34; &#34;, d:primary)))"/>
82
83   <xsl:variable name="lang">
84     <xsl:call-template name="l10n.language"/>
85   </xsl:variable>
86
87   <xsl:if test="key('group-code', $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]">
88     <div class="indexdiv">
89       <h3>
90         <xsl:value-of select="i:group-letter($key)"/>
91       </h3>
92       <dl>
93         <xsl:apply-templates select="key('group-code', $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">
94           <xsl:sort select="normalize-space(concat(d:primary/@sortas, &#34; &#34;, d:primary))" lang="{$lang}"/>
95           <xsl:with-param name="scope" select="$scope"/>
96           <xsl:with-param name="role" select="$role"/>
97           <xsl:with-param name="type" select="$type"/>
98         </xsl:apply-templates>
99       </dl>
100     </div>
101   </xsl:if>
102 </xsl:template>
103
104 </xsl:stylesheet>