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">
6 <!-- ********************************************************************
7 $Id: index.xsl 9811 2013-09-20 11:04:58Z mzjn $
8 ********************************************************************
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.
14 ******************************************************************** -->
16 <!-- ==================================================================== -->
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. -->
25 <xsl:call-template name="id.warning"/>
27 <xsl:if test="count(*)>0 or $generate.index != '0'">
29 <xsl:apply-templates select="." mode="common.html.attributes"/>
30 <xsl:call-template name="id.attribute">
31 <xsl:with-param name="conditional" select="0"/>
34 <xsl:call-template name="index.titlepage"/>
36 <xsl:when test="indexdiv">
37 <xsl:apply-templates/>
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. -->
52 <xsl:apply-templates select="indexentry"/>
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()]"/>
64 <xsl:if test="not(parent::article)">
65 <xsl:call-template name="process.footnotes"/>
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. -->
78 <xsl:call-template name="id.warning"/>
80 <xsl:if test="count(*)>0 or $generate.index != '0'">
82 <xsl:apply-templates select="." mode="common.html.attributes"/>
83 <xsl:call-template name="id.attribute">
84 <xsl:with-param name="conditional" select="0"/>
87 <xsl:call-template name="setindex.titlepage"/>
88 <xsl:apply-templates/>
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="/"/>
96 <xsl:if test="not(parent::article)">
97 <xsl:call-template name="process.footnotes"/>
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"/>
109 <!-- ==================================================================== -->
111 <xsl:template match="indexdiv">
112 <xsl:call-template name="id.warning"/>
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)]"/>
120 <xsl:apply-templates select="indexentry"/>
125 <xsl:template match="indexdiv/title">
127 <xsl:apply-templates select="." mode="common.html.attributes"/>
128 <xsl:apply-templates/>
132 <xsl:template match="indexdiv/subtitle">
134 <xsl:apply-templates select="." mode="common.html.attributes"/>
135 <xsl:apply-templates/>
139 <!-- ==================================================================== -->
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"/>
147 <a id="{$id}" class="indexterm"/>
150 <xsl:template match="primary|secondary|tertiary|see|seealso">
153 <!-- ==================================================================== -->
155 <xsl:template match="indexentry">
156 <xsl:apply-templates select="primaryie"/>
159 <xsl:template match="primaryie">
161 <xsl:apply-templates/>
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"/>
170 <!-- Handled in mode to convert flat list to structured output -->
171 <xsl:template match="secondaryie">
173 <xsl:template match="tertiaryie">
175 <xsl:template match="seeie|seealsoie">
178 <xsl:template match="secondaryie" mode="indexentry">
181 <xsl:apply-templates/>
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]"/>
190 <xsl:when test="count($see.intersection) != 0">
191 <xsl:apply-templates select="$see.intersection" mode="indexentry"/>
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"/>
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)]"/>
203 <xsl:when test="count($tertiary.intersection) != 0">
204 <xsl:apply-templates select="$tertiary.intersection" mode="indexentry"/>
206 <xsl:when test="not(following-sibling::secondaryie)">
207 <xsl:apply-templates select="following-sibling::tertiaryie" mode="indexentry"/>
214 <xsl:template match="tertiaryie" mode="indexentry">
217 <xsl:apply-templates/>
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]"/>
226 <xsl:when test="count($see.intersection) != 0">
227 <xsl:apply-templates select="$see.intersection" mode="indexentry"/>
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"/>
238 <xsl:template match="seeie" mode="indexentry">
240 <xsl:text>(</xsl:text>
241 <xsl:call-template name="gentext">
242 <xsl:with-param name="key" select="'see'"/>
244 <xsl:text> </xsl:text>
245 <xsl:apply-templates/>
246 <xsl:text>)</xsl:text>
250 <xsl:template match="seealsoie" mode="indexentry">
252 <xsl:text>(</xsl:text>
253 <xsl:call-template name="gentext">
254 <xsl:with-param name="key" select="'seealso'"/>
256 <xsl:text> </xsl:text>
257 <xsl:apply-templates/>
258 <xsl:text>)</xsl:text>