This commit was manufactured by cvs2svn to create branch 'SAMBA_3_0'.(This used to...
[ira/wip.git] / docs / docbook / xslt / db2latex / index.mod.xsl
1 <?xml version='1.0'?>
2 <!--############################################################################# 
3 |       $Id: index.mod.xsl,v 1.1.2.1 2003/05/01 14:06:14 jelmer Exp $
4 |- #############################################################################
5 |       $Author: jelmer $
6 |                                                                                                               
7 |   PURPOSE:
8 + ############################################################################## -->
9 <xsl:stylesheet 
10     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
11     xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
12     exclude-result-prefixes="doc" version='1.0'>
13
14
15
16     <!--############################################################################# -->
17     <!-- DOCUMENTATION                                                                -->
18     <doc:reference id="index" xmlns="">
19         <referenceinfo>
20             <releaseinfo role="meta">
21                 $Id: index.mod.xsl,v 1.1.2.1 2003/05/01 14:06:14 jelmer Exp $
22             </releaseinfo>
23         <authorgroup>
24             <author> <firstname>Ramon</firstname> <surname>Casellas</surname> </author>
25             <author> <firstname>James</firstname> <surname>Devenish</surname> </author>
26         </authorgroup>
27             <copyright>
28                 <year>2000</year> <year>2001</year> <year>2002</year> <year>2003</year>
29                 <holder>Ramon Casellas</holder>
30             </copyright>
31         </referenceinfo>
32
33         <title>Index <filename>index.mod.xsl</filename></title>
34         <partintro>
35             <section><title>Introduction</title>
36                 <para></para>
37             </section>
38         </partintro>
39     </doc:reference>
40
41
42 <!-- This parameter is for enabeling or disabling of indexterms -->
43 <xsl:param name="latex.generate.indexterm">1</xsl:param>
44
45 <!-- Our key for ranges -->
46 <xsl:key name="indexterm-range" match="indexterm[@class='startofrange']" use="@id"/>
47
48
49
50
51 <!-- ############################################################### -->
52 <!-- Index                                                           -->
53 <!--                                                                 -->
54 <!-- ############################################################### -->
55 <xsl:template match="index|setindex">
56         <xsl:call-template name="label.id"/>
57         <xsl:text>\printindex&#10;</xsl:text>
58 </xsl:template>
59
60 <xsl:template match="index/title"></xsl:template>
61 <xsl:template match="index/subtitle"></xsl:template>
62 <xsl:template match="index/titleabbrev"></xsl:template>
63
64 <xsl:template match="index/title" mode="component.title.mode">
65         <xsl:call-template name="label.id"> <xsl:with-param name="object" select=".."/> </xsl:call-template>
66 </xsl:template>
67
68 <xsl:template match="index/subtitle" mode="component.title.mode"/>
69
70
71 <!-- ############################################################### -->
72 <!-- IndexDiv                                                        -->
73 <!--                                                                 -->
74 <!-- ############################################################### -->
75 <xsl:template match="indexdiv">
76         <xsl:apply-templates/>
77 </xsl:template>
78
79 <xsl:template match="indexdiv/title">
80         <xsl:call-template name="label.id"> <xsl:with-param name="object" select=".."/> </xsl:call-template>
81 </xsl:template>
82
83
84 <!-- INDEX TERM CONTENT MODEL
85 IndexTerm ::=
86 (Primary,
87 ((Secondary,
88 ((Tertiary,
89 (See|SeeAlso+)?)|
90 See|SeeAlso+)?)|
91 See|SeeAlso+)?)
92 -->
93 <!-- ############################################################### -->
94 <!-- IndexDiv                                                        -->
95 <!--                                                                 -->
96 <!-- ############################################################### -->
97 <xsl:template match="indexterm">
98 <xsl:if test="$latex.generate.indexterm != 0">
99 <!--
100                 <xsl:text>\index{</xsl:text>
101                 <xsl:call-template name="normalize-scape">
102                         <xsl:with-param name="string" select="normalize-space(./primary)"/>
103                 </xsl:call-template>
104                 <xsl:if test="./secondary">
105                         <xsl:text>!</xsl:text>
106                         <xsl:call-template name="normalize-scape">
107                                 <xsl:with-param name="string" select="normalize-space(./secondary)"/>
108                         </xsl:call-template>
109                 </xsl:if>
110                 <xsl:if test="./tertiary">
111                         <xsl:text>!</xsl:text>
112                         <xsl:call-template name="normalize-scape">
113                                 <xsl:with-param name="string" select="normalize-space(./tertiary)"/>
114                         </xsl:call-template>
115                 </xsl:if>
116                 <xsl:if test="./see">
117                         <xsl:text>|see{</xsl:text>
118                         <xsl:call-template name="normalize-scape">
119                                 <xsl:with-param name="string" select="normalize-space(./see)"/>
120                         </xsl:call-template>
121                         <xsl:text>}</xsl:text>
122                 </xsl:if>
123                 <xsl:if test="./seealso">
124                         <xsl:text>|see{</xsl:text>
125                         <xsl:call-template name="normalize-scape">
126                                 <xsl:with-param name="string" select="normalize-space(./seealso)"/>
127                         </xsl:call-template>
128                         <xsl:text>}</xsl:text>
129                 </xsl:if>
130                 <xsl:text>}</xsl:text>
131 -->
132         <xsl:variable name="idxterm">
133                 <xsl:apply-templates mode="indexterm"/>
134         </xsl:variable>
135
136         <xsl:if test="@class and @zone">
137                 <xsl:message terminate="yes">Error: Only one attribut (@class or @zone) is in indexterm possible!</xsl:message>
138         </xsl:if>
139
140         <xsl:choose>
141                 <xsl:when test="@class='startofrange'">
142                         <xsl:text>\index{</xsl:text>
143                                 <xsl:value-of select="normalize-space($idxterm)"/>
144                         <xsl:text>|(}</xsl:text>
145                 </xsl:when>
146                 <xsl:when test="@class='endofrange'">
147                         <xsl:choose>
148                                 <xsl:when test="count(key('indexterm-range',@startref)) = 0">
149                                         <xsl:message terminate="yes"><xsl:text>Error: No indexterm with </xsl:text>
150                                         <xsl:text>id='</xsl:text><xsl:value-of select="@startref"/>
151                                         <xsl:text>' found!</xsl:text>
152                                         <xsl:text>  Check your attributs id/startref in your indexterms!</xsl:text>
153                                         </xsl:message>
154                                 </xsl:when>
155                                 <xsl:otherwise>
156                                         <xsl:variable name="thekey" select="key('indexterm-range',@startref)"/>
157                                         <xsl:text>\index{</xsl:text>
158                                         <xsl:apply-templates select="$thekey/*"  mode="indexterm"/>
159                                         <xsl:text>|)}</xsl:text>
160                                 </xsl:otherwise>
161                         </xsl:choose>
162                 </xsl:when>
163                 <xsl:otherwise>
164                         <xsl:text>\index{</xsl:text>
165                         <xsl:message terminate="no"><xsl:text>Simple case:</xsl:text></xsl:message>
166                                 <xsl:value-of select="normalize-space($idxterm)"/>
167                         <xsl:text>}</xsl:text>
168                 </xsl:otherwise>
169         </xsl:choose>
170 </xsl:if>
171 </xsl:template>
172
173
174 <!-- ================================================ -->
175 <xsl:template match="*" mode="indexterm">
176     <xsl:message>WARNING: Element '<xsl:value-of select="local-name()"/>' in indexterm not supported!</xsl:message>
177 </xsl:template>
178
179
180
181 <!-- ================================================ -->
182 <xsl:template match="primary" mode="indexterm">
183 <xsl:apply-templates mode="indexterm"/>
184 </xsl:template>
185
186 <xsl:template match="secondary" mode="indexterm">
187 <xsl:text>!</xsl:text>
188 <xsl:apply-templates mode="indexterm"/>
189 </xsl:template>
190
191 <xsl:template match="tertiary" mode="indexterm">
192 <xsl:text>!</xsl:text>
193 <xsl:apply-templates mode="indexterm"/>
194 </xsl:template>
195
196 <xsl:template match="see|seealso" mode="indexterm">
197 <xsl:text>|see{</xsl:text>
198 <xsl:apply-templates mode="indexterm"/>
199 <xsl:text>} </xsl:text>
200 </xsl:template>
201
202
203 <!-- ================================================ -->
204 <!-- A simple example of what can be in an primary,   -->
205 <!-- secondary or tertiary.                           -->
206 <!-- ================================================ -->
207 <xsl:template match="acronym" mode="indexterm">
208 <xsl:apply-templates mode="indexterm"/>
209 </xsl:template>
210
211
212 <xsl:template match="primary|secondary|tertiary|see|seealso"/>
213 <xsl:template match="indexentry"/>
214 <xsl:template match="primaryie|secondaryie|tertiaryie|seeie|seealsoie"/>
215
216 </xsl:stylesheet>