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 9297 2012-04-22 03:56:16Z bobstayton $
|
---|
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(*)>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(*)>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 | <!-- ==================================================================== -->
|
---|
133 |
|
---|
134 | <xsl:template match="indexterm">
|
---|
135 | <!-- this one must have a name, even if it doesn't have an ID -->
|
---|
136 | <xsl:variable name="id">
|
---|
137 | <xsl:call-template name="object.id"/>
|
---|
138 | </xsl:variable>
|
---|
139 |
|
---|
140 | <a id="{$id}" class="indexterm"/>
|
---|
141 | </xsl:template>
|
---|
142 |
|
---|
143 | <xsl:template match="primary|secondary|tertiary|see|seealso">
|
---|
144 | </xsl:template>
|
---|
145 |
|
---|
146 | <!-- ==================================================================== -->
|
---|
147 |
|
---|
148 | <xsl:template match="indexentry">
|
---|
149 | <xsl:apply-templates select="primaryie"/>
|
---|
150 | </xsl:template>
|
---|
151 |
|
---|
152 | <xsl:template match="primaryie">
|
---|
153 | <dt>
|
---|
154 | <xsl:apply-templates/>
|
---|
155 | </dt>
|
---|
156 | <dd>
|
---|
157 | <xsl:apply-templates select="following-sibling::seeie [not(preceding-sibling::secondaryie)]" mode="indexentry"/>
|
---|
158 | <xsl:apply-templates select="following-sibling::seealsoie [not(preceding-sibling::secondaryie)]" mode="indexentry"/>
|
---|
159 | <xsl:apply-templates select="following-sibling::secondaryie" mode="indexentry"/>
|
---|
160 | </dd>
|
---|
161 | </xsl:template>
|
---|
162 |
|
---|
163 | <!-- Handled in mode to convert flat list to structured output -->
|
---|
164 | <xsl:template match="secondaryie">
|
---|
165 | </xsl:template>
|
---|
166 | <xsl:template match="tertiaryie">
|
---|
167 | </xsl:template>
|
---|
168 | <xsl:template match="seeie|seealsoie">
|
---|
169 | </xsl:template>
|
---|
170 |
|
---|
171 | <xsl:template match="secondaryie" mode="indexentry">
|
---|
172 | <dl>
|
---|
173 | <dt>
|
---|
174 | <xsl:apply-templates/>
|
---|
175 | </dt>
|
---|
176 | <dd>
|
---|
177 | <!-- select following see* elements up to next secondaryie or tertiary or end -->
|
---|
178 | <xsl:variable name="after.this" select="following-sibling::*"/>
|
---|
179 | <xsl:variable name="next.entry" select="(following-sibling::secondaryie|following-sibling::tertiaryie)[1]"/>
|
---|
180 | <xsl:variable name="before.entry" select="$next.entry/preceding-sibling::*"/>
|
---|
181 | <xsl:variable name="see.intersection" select="$after.this[count(.|$before.entry) = count($before.entry)] [self::seeie or self::seealsoie]"/>
|
---|
182 | <xsl:choose>
|
---|
183 | <xsl:when test="count($see.intersection) != 0">
|
---|
184 | <xsl:apply-templates select="$see.intersection" mode="indexentry"/>
|
---|
185 | </xsl:when>
|
---|
186 | <xsl:when test="count($next.entry) = 0">
|
---|
187 | <xsl:apply-templates select="following-sibling::seeie" mode="indexentry"/>
|
---|
188 | <xsl:apply-templates select="following-sibling::seealsoie" mode="indexentry"/>
|
---|
189 | </xsl:when>
|
---|
190 | </xsl:choose>
|
---|
191 |
|
---|
192 | <!-- now process any tertiaryie before the next secondaryie -->
|
---|
193 | <xsl:variable name="before.next.secondary" select="following-sibling::secondaryie[1]/preceding-sibling::*"/>
|
---|
194 | <xsl:variable name="tertiary.intersection" select="$after.this[count(.|$before.next.secondary) = count($before.next.secondary)] [not(self::seeie) and not(self::seealsoie)]"/>
|
---|
195 | <xsl:choose>
|
---|
196 | <xsl:when test="count($tertiary.intersection) != 0">
|
---|
197 | <xsl:apply-templates select="$tertiary.intersection" mode="indexentry"/>
|
---|
198 | </xsl:when>
|
---|
199 | <xsl:when test="not(following-sibling::secondaryie)">
|
---|
200 | <xsl:apply-templates select="following-sibling::tertiaryie" mode="indexentry"/>
|
---|
201 | </xsl:when>
|
---|
202 | </xsl:choose>
|
---|
203 | </dd>
|
---|
204 | </dl>
|
---|
205 | </xsl:template>
|
---|
206 |
|
---|
207 | <xsl:template match="tertiaryie" mode="indexentry">
|
---|
208 | <dl>
|
---|
209 | <dt>
|
---|
210 | <xsl:apply-templates/>
|
---|
211 | </dt>
|
---|
212 | <dd>
|
---|
213 | <!-- select following see* elements up to next secondaryie or tertiary or end -->
|
---|
214 | <xsl:variable name="after.this" select="following-sibling::*"/>
|
---|
215 | <xsl:variable name="next.entry" select="(following-sibling::secondaryie|following-sibling::tertiaryie)[1]"/>
|
---|
216 | <xsl:variable name="before.entry" select="$next.entry/preceding-sibling::*"/>
|
---|
217 | <xsl:variable name="see.intersection" select="$after.this[count(.|$before.entry) = count($before.entry)] [self::seeie or self::seealsoie]"/>
|
---|
218 | <xsl:choose>
|
---|
219 | <xsl:when test="count($see.intersection) != 0">
|
---|
220 | <xsl:apply-templates select="$see.intersection" mode="indexentry"/>
|
---|
221 | </xsl:when>
|
---|
222 | <xsl:when test="count($next.entry) = 0">
|
---|
223 | <xsl:apply-templates select="following-sibling::seeie" mode="indexentry"/>
|
---|
224 | <xsl:apply-templates select="following-sibling::seealsoie" mode="indexentry"/>
|
---|
225 | </xsl:when>
|
---|
226 | </xsl:choose>
|
---|
227 | </dd>
|
---|
228 | </dl>
|
---|
229 | </xsl:template>
|
---|
230 |
|
---|
231 | <xsl:template match="seeie" mode="indexentry">
|
---|
232 | <dt>
|
---|
233 | <xsl:text>(</xsl:text>
|
---|
234 | <xsl:call-template name="gentext">
|
---|
235 | <xsl:with-param name="key" select="'see'"/>
|
---|
236 | </xsl:call-template>
|
---|
237 | <xsl:text> </xsl:text>
|
---|
238 | <xsl:apply-templates/>
|
---|
239 | <xsl:text>)</xsl:text>
|
---|
240 | </dt>
|
---|
241 | </xsl:template>
|
---|
242 |
|
---|
243 | <xsl:template match="seealsoie" mode="indexentry">
|
---|
244 | <div>
|
---|
245 | <xsl:text>(</xsl:text>
|
---|
246 | <xsl:call-template name="gentext">
|
---|
247 | <xsl:with-param name="key" select="'seealso'"/>
|
---|
248 | </xsl:call-template>
|
---|
249 | <xsl:text> </xsl:text>
|
---|
250 | <xsl:apply-templates/>
|
---|
251 | <xsl:text>)</xsl:text>
|
---|
252 | </div>
|
---|
253 | </xsl:template>
|
---|
254 |
|
---|
255 | </xsl:stylesheet>
|
---|