]> git.evergreen-ils.org Git - working/Evergreen.git/blob - stylesheets/evergreen_docbook_files/docbook-xsl-1.75.2/fo/autoidx-kosek.xsl
Add stylesheets for our evergreen docbook site.
[working/Evergreen.git] / stylesheets / evergreen_docbook_files / docbook-xsl-1.75.2 / fo / 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 sep '" "'>
9 <!-- Documents using the kimber index method must have a lang attribute -->
10 <!-- Only one of these should be present in the entity -->
11
12 <!ENTITY scope 'count(ancestor::node()|$scope) = count(ancestor::node())
13                 and ($role = @role or $type = @type or
14                 (string-length($role) = 0 and string-length($type) = 0))'>
15 ]>
16 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
17                 xmlns:fo="http://www.w3.org/1999/XSL/Format"
18                 xmlns:rx="http://www.renderx.com/XSL/Extensions"
19                 xmlns:axf="http://www.antennahouse.com/names/XSL/Extensions"
20                 xmlns:i="urn:cz-kosek:functions:index"
21                 xmlns:l="http://docbook.sourceforge.net/xmlns/l10n/1.0"
22                 xmlns:func="http://exslt.org/functions"
23                 xmlns:exslt="http://exslt.org/common"
24                 extension-element-prefixes="func exslt"
25                 exclude-result-prefixes="func exslt i l"
26                 version="1.0">
27
28 <!-- ********************************************************************
29      $Id: autoidx-kosek.xsl 8399 2009-04-08 07:37:42Z bobstayton $
30      ********************************************************************
31
32      This file is part of the DocBook XSL Stylesheet distribution.
33      See ../README or http://docbook.sf.net/ for copyright
34      copyright and other information.
35
36      ******************************************************************** -->
37
38 <!-- ==================================================================== -->
39 <!-- The "kosek" method contributed by Jirka Kosek. -->
40
41 <xsl:include href="../common/autoidx-kosek.xsl"/>
42
43 <xsl:template name="generate-kosek-index">
44   <xsl:param name="scope" select="NOTANODE"/>
45
46   <xsl:variable name="vendor" select="system-property('xsl:vendor')"/>
47   <xsl:if test="contains($vendor, 'libxslt')">
48     <xsl:message terminate="yes">
49       <xsl:text>ERROR: the 'kosek' index method does not </xsl:text>
50       <xsl:text>work with the xsltproc XSLT processor.</xsl:text>
51     </xsl:message>
52   </xsl:if>
53
54   <xsl:if test="contains($vendor, 'Saxonica')">
55     <xsl:message terminate="yes">
56       <xsl:text>ERROR: the 'kosek' index method does not </xsl:text>
57       <xsl:text>work with the Saxon 8 XSLT processor.</xsl:text>
58     </xsl:message>
59   </xsl:if>
60
61
62   <xsl:if test="$exsl.node.set.available = 0">
63     <xsl:message terminate="yes">
64       <xsl:text>ERROR: the 'kosek' index method requires the </xsl:text>
65       <xsl:text>exslt:node-set() function. Use a processor that </xsl:text>
66       <xsl:text>has it, or use a different index method.</xsl:text>
67     </xsl:message>
68   </xsl:if>
69
70   <xsl:if test="not(function-available('i:group-index'))">
71     <xsl:message terminate="yes">
72       <xsl:text>ERROR: the 'kosek' index method requires the&#xA;</xsl:text>
73       <xsl:text>index extension functions be imported:&#xA;</xsl:text>
74       <xsl:text>  xsl:import href="common/autoidx-kosek.xsl"</xsl:text>
75     </xsl:message>
76   </xsl:if>
77
78   <xsl:variable name="role">
79     <xsl:if test="$index.on.role != 0">
80       <xsl:value-of select="@role"/>
81     </xsl:if>
82   </xsl:variable>
83
84   <xsl:variable name="type">
85     <xsl:if test="$index.on.type != 0">
86       <xsl:value-of select="@type"/>
87     </xsl:if>
88   </xsl:variable>
89
90   <xsl:variable name="terms"
91                 select="//indexterm[count(.|key('group-code',
92                                           i:group-index(&primary;))
93                                           [&scope;][1]) = 1
94                                 and not(@class = 'endofrange')]"/>
95   <fo:block>
96     <xsl:apply-templates select="$terms" mode="index-div-kosek">
97       <xsl:with-param name="scope" select="$scope"/>
98       <xsl:with-param name="role" select="$role"/>
99       <xsl:with-param name="type" select="$type"/>
100       <xsl:sort select="i:group-index(&primary;)" data-type="number"/>
101     </xsl:apply-templates>
102   </fo:block>
103 </xsl:template>
104
105 <xsl:template match="indexterm" mode="index-div-kosek">
106   <xsl:param name="scope" select="."/>
107   <xsl:param name="role" select="''"/>
108   <xsl:param name="type" select="''"/>
109
110   <xsl:variable name="key"
111                 select="i:group-index(&primary;)"/>
112
113   <xsl:variable name="lang">
114     <xsl:call-template name="l10n.language"/>
115   </xsl:variable>
116
117   <xsl:if test="key('group-code', $key)[&scope;]
118                 [count(.|key('primary', &primary;)[&scope;][1]) = 1]">
119     <fo:block>
120       <xsl:call-template name="indexdiv.title">
121         <xsl:with-param name="titlecontent">
122           <xsl:choose>
123             <xsl:when test="$key = 0">
124               <xsl:call-template name="gentext">
125                 <xsl:with-param name="key" select="'index symbols'"/>
126               </xsl:call-template>
127             </xsl:when>
128             <xsl:otherwise>
129               <xsl:value-of select="i:group-letter($key)"/>
130             </xsl:otherwise>
131           </xsl:choose>
132         </xsl:with-param>
133       </xsl:call-template>
134       <fo:block>
135         <xsl:apply-templates select="key('group-code', $key)[&scope;]
136                                      [count(.|key('primary', &primary;)
137                                      [&scope;][1])=1]"
138                              mode="index-primary">
139           <xsl:sort select="&primary;" lang="{$lang}"/>
140           <xsl:with-param name="scope" select="$scope"/>
141           <xsl:with-param name="role" select="$role"/>
142           <xsl:with-param name="type" select="$type"/>
143         </xsl:apply-templates>
144       </fo:block>
145     </fo:block>
146   </xsl:if>
147 </xsl:template>
148
149 </xsl:stylesheet>