Whamcloud - gitweb
LUDOC-120 presentation: build bits for webhelp.
[doc/manual.git] / webhelp / xhtml / index.xsl
1 <?xml version="1.0" encoding="ASCII"?>
2 <!--This file was created automatically by html2xhtml-->
3 <!--from the HTML stylesheets.-->
4 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.w3.org/1999/xhtml" version="1.0">
5
6 <!-- ********************************************************************
7      $Id: index.xsl 9811 2013-09-20 11:04:58Z mzjn $
8      ********************************************************************
9
10      This file is part of the XSL DocBook Stylesheet distribution.
11      See ../README or http://docbook.sf.net/release/xsl/current/ for
12      copyright and other information.
13
14      ******************************************************************** -->
15
16 <!-- ==================================================================== -->
17
18 <xsl:template match="index">
19   <!-- some implementations use completely empty index tags to indicate -->
20   <!-- where an automatically generated index should be inserted. so -->
21   <!-- if the index is completely empty, skip it. Unless generate.index -->
22   <!-- is non-zero, in which case, this is where the automatically -->
23   <!-- generated index should go. -->
24
25   <xsl:call-template name="id.warning"/>
26
27   <xsl:if test="count(*)&gt;0 or $generate.index != '0'">
28     <div>
29       <xsl:apply-templates select="." mode="common.html.attributes"/>
30       <xsl:call-template name="id.attribute">
31         <xsl:with-param name="conditional" select="0"/>
32       </xsl:call-template>
33
34       <xsl:call-template name="index.titlepage"/>
35       <xsl:choose>
36         <xsl:when test="indexdiv">
37           <xsl:apply-templates/>
38         </xsl:when>
39         <xsl:otherwise>
40           <xsl:apply-templates select="*[not(self::indexentry)]"/>
41           <!-- Because it's actually valid for Index to have neither any -->
42           <!-- Indexdivs nor any Indexentries, we need to check and make -->
43           <!-- sure that at least one Indexentry exists, and generate a -->
44           <!-- wrapper dl if there is at least one; otherwise, do nothing. -->
45           <xsl:if test="indexentry">
46             <!-- The indexentry template assumes a parent dl wrapper has -->
47             <!-- been generated; for Indexes that have Indexdivs, the dl -->
48             <!-- wrapper is generated by the indexdiv template; however, -->
49             <!-- for Indexes that lack Indexdivs, if we don't generate a -->
50             <!-- dl here, HTML output will not be valid. -->
51             <dl>
52               <xsl:apply-templates select="indexentry"/>
53             </dl>
54           </xsl:if>
55         </xsl:otherwise>
56       </xsl:choose>
57
58       <xsl:if test="count(indexentry) = 0 and count(indexdiv) = 0">
59         <xsl:call-template name="generate-index">
60           <xsl:with-param name="scope" select="(ancestor::book|/)[last()]"/>
61         </xsl:call-template>
62       </xsl:if>
63
64       <xsl:if test="not(parent::article)">
65         <xsl:call-template name="process.footnotes"/>
66       </xsl:if>
67     </div>
68   </xsl:if>
69 </xsl:template>
70
71 <xsl:template match="setindex">
72   <!-- some implementations use completely empty index tags to indicate -->
73   <!-- where an automatically generated index should be inserted. so -->
74   <!-- if the index is completely empty, skip it. Unless generate.index -->
75   <!-- is non-zero, in which case, this is where the automatically -->
76   <!-- generated index should go. -->
77
78   <xsl:call-template name="id.warning"/>
79
80   <xsl:if test="count(*)&gt;0 or $generate.index != '0'">
81     <div>
82       <xsl:apply-templates select="." mode="common.html.attributes"/>
83       <xsl:call-template name="id.attribute">
84         <xsl:with-param name="conditional" select="0"/>
85       </xsl:call-template>
86
87       <xsl:call-template name="setindex.titlepage"/>
88       <xsl:apply-templates/>
89
90       <xsl:if test="count(indexentry) = 0 and count(indexdiv) = 0">
91         <xsl:call-template name="generate-index">
92           <xsl:with-param name="scope" select="/"/>
93         </xsl:call-template>
94       </xsl:if>
95
96       <xsl:if test="not(parent::article)">
97         <xsl:call-template name="process.footnotes"/>
98       </xsl:if>
99     </div>
100   </xsl:if>
101 </xsl:template>
102
103 <xsl:template match="index/indexinfo"/>
104 <xsl:template match="index/info"/>
105 <xsl:template match="index/title"/>
106 <xsl:template match="index/subtitle"/>
107 <xsl:template match="index/titleabbrev"/>
108
109 <!-- ==================================================================== -->
110
111 <xsl:template match="indexdiv">
112   <xsl:call-template name="id.warning"/>
113
114   <div>
115     <xsl:apply-templates select="." mode="common.html.attributes"/>
116     <xsl:call-template name="id.attribute"/>
117     <xsl:call-template name="anchor"/>
118     <xsl:apply-templates select="*[not(self::indexentry)]"/>
119     <dl>
120       <xsl:apply-templates select="indexentry"/>
121     </dl>
122   </div>
123 </xsl:template>
124
125 <xsl:template match="indexdiv/title">
126   <h3>
127     <xsl:apply-templates select="." mode="common.html.attributes"/>
128     <xsl:apply-templates/>
129   </h3>
130 </xsl:template>
131
132 <xsl:template match="indexdiv/subtitle">
133   <h4>
134     <xsl:apply-templates select="." mode="common.html.attributes"/>
135     <xsl:apply-templates/>
136   </h4>
137 </xsl:template>
138
139 <!-- ==================================================================== -->
140
141 <xsl:template match="indexterm">
142   <!-- this one must have a name, even if it doesn't have an ID -->
143   <xsl:variable name="id">
144     <xsl:call-template name="object.id"/>
145   </xsl:variable>
146
147   <a id="{$id}" class="indexterm"/>
148 </xsl:template>
149
150 <xsl:template match="primary|secondary|tertiary|see|seealso">
151 </xsl:template>
152
153 <!-- ==================================================================== -->
154
155 <xsl:template match="indexentry">
156   <xsl:apply-templates select="primaryie"/>
157 </xsl:template>
158
159 <xsl:template match="primaryie">
160   <dt>
161     <xsl:apply-templates/>
162   </dt>
163   <dd>
164     <xsl:apply-templates select="following-sibling::seeie                                    [not(preceding-sibling::secondaryie)]" mode="indexentry"/>
165     <xsl:apply-templates select="following-sibling::seealsoie                                    [not(preceding-sibling::secondaryie)]" mode="indexentry"/>
166     <xsl:apply-templates select="following-sibling::secondaryie" mode="indexentry"/>
167   </dd>
168 </xsl:template>
169
170 <!-- Handled in mode to convert flat list to structured output -->
171 <xsl:template match="secondaryie">
172 </xsl:template>
173 <xsl:template match="tertiaryie">
174 </xsl:template>
175 <xsl:template match="seeie|seealsoie">
176 </xsl:template>
177
178 <xsl:template match="secondaryie" mode="indexentry">
179   <dl>
180     <dt>
181       <xsl:apply-templates/>
182     </dt>
183     <dd>
184       <!-- select following see* elements up to next secondaryie or tertiary or end -->
185       <xsl:variable name="after.this" select="following-sibling::*"/>
186       <xsl:variable name="next.entry" select="(following-sibling::secondaryie|following-sibling::tertiaryie)[1]"/>
187       <xsl:variable name="before.entry" select="$next.entry/preceding-sibling::*"/>
188       <xsl:variable name="see.intersection" select="$after.this[count(.|$before.entry) = count($before.entry)]                                 [self::seeie or self::seealsoie]"/>
189       <xsl:choose>
190         <xsl:when test="count($see.intersection) != 0">
191           <xsl:apply-templates select="$see.intersection" mode="indexentry"/>
192         </xsl:when>
193         <xsl:when test="count($next.entry) = 0">
194           <xsl:apply-templates select="following-sibling::seeie" mode="indexentry"/>
195           <xsl:apply-templates select="following-sibling::seealsoie" mode="indexentry"/>
196         </xsl:when>
197       </xsl:choose>
198
199       <!-- now process any tertiaryie before the next secondaryie -->
200       <xsl:variable name="before.next.secondary" select="following-sibling::secondaryie[1]/preceding-sibling::*"/>
201       <xsl:variable name="tertiary.intersection" select="$after.this[count(.|$before.next.secondary) =                                   count($before.next.secondary)]                                 [not(self::seeie) and not(self::seealsoie)]"/>
202       <xsl:choose>
203         <xsl:when test="count($tertiary.intersection) != 0">
204           <xsl:apply-templates select="$tertiary.intersection" mode="indexentry"/>
205         </xsl:when>
206         <xsl:when test="not(following-sibling::secondaryie)">
207           <xsl:apply-templates select="following-sibling::tertiaryie" mode="indexentry"/>
208         </xsl:when>
209       </xsl:choose>
210     </dd>
211   </dl>
212 </xsl:template>
213
214 <xsl:template match="tertiaryie" mode="indexentry">
215   <dl>
216     <dt>
217       <xsl:apply-templates/>
218     </dt>
219     <dd>
220       <!-- select following see* elements up to next secondaryie or tertiary or end -->
221       <xsl:variable name="after.this" select="following-sibling::*"/>
222       <xsl:variable name="next.entry" select="(following-sibling::secondaryie|following-sibling::tertiaryie)[1]"/>
223       <xsl:variable name="before.entry" select="$next.entry/preceding-sibling::*"/>
224       <xsl:variable name="see.intersection" select="$after.this[count(.|$before.entry) = count($before.entry)]                                 [self::seeie or self::seealsoie]"/>
225       <xsl:choose>
226         <xsl:when test="count($see.intersection) != 0">
227           <xsl:apply-templates select="$see.intersection" mode="indexentry"/>
228         </xsl:when>
229         <xsl:when test="count($next.entry) = 0">
230           <xsl:apply-templates select="following-sibling::seeie" mode="indexentry"/>
231           <xsl:apply-templates select="following-sibling::seealsoie" mode="indexentry"/>
232         </xsl:when>
233       </xsl:choose>
234     </dd>
235   </dl>
236 </xsl:template>
237
238 <xsl:template match="seeie" mode="indexentry">
239   <dt>
240     <xsl:text>(</xsl:text>
241     <xsl:call-template name="gentext">
242       <xsl:with-param name="key" select="'see'"/>
243     </xsl:call-template>
244     <xsl:text> </xsl:text>
245     <xsl:apply-templates/>
246     <xsl:text>)</xsl:text>
247   </dt>
248 </xsl:template>
249
250 <xsl:template match="seealsoie" mode="indexentry">
251   <div>
252     <xsl:text>(</xsl:text>
253     <xsl:call-template name="gentext">
254       <xsl:with-param name="key" select="'seealso'"/>
255     </xsl:call-template>
256     <xsl:text> </xsl:text>
257     <xsl:apply-templates/>
258     <xsl:text>)</xsl:text>
259   </div>
260 </xsl:template>
261
262 </xsl:stylesheet>