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 8421 2009-05-04 07:49:49Z bobstayton $
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:if test="$generate.id.attributes != 0">
31 <xsl:attribute name="id">
32 <xsl:call-template name="object.id"/>
36 <xsl:call-template name="index.titlepage"/>
38 <xsl:when test="indexdiv">
39 <xsl:apply-templates/>
42 <xsl:apply-templates select="*[not(self::indexentry)]"/>
43 <!-- Because it's actually valid for Index to have neither any -->
44 <!-- Indexdivs nor any Indexentries, we need to check and make -->
45 <!-- sure that at least one Indexentry exists, and generate a -->
46 <!-- wrapper dl if there is at least one; otherwise, do nothing. -->
47 <xsl:if test="indexentry">
48 <!-- The indexentry template assumes a parent dl wrapper has -->
49 <!-- been generated; for Indexes that have Indexdivs, the dl -->
50 <!-- wrapper is generated by the indexdiv template; however, -->
51 <!-- for Indexes that lack Indexdivs, if we don't generate a -->
52 <!-- dl here, HTML output will not be valid. -->
54 <xsl:apply-templates select="indexentry"/>
60 <xsl:if test="count(indexentry) = 0 and count(indexdiv) = 0">
61 <xsl:call-template name="generate-index">
62 <xsl:with-param name="scope" select="(ancestor::book|/)[last()]"/>
66 <xsl:if test="not(parent::article)">
67 <xsl:call-template name="process.footnotes"/>
73 <xsl:template match="setindex">
74 <!-- some implementations use completely empty index tags to indicate -->
75 <!-- where an automatically generated index should be inserted. so -->
76 <!-- if the index is completely empty, skip it. Unless generate.index -->
77 <!-- is non-zero, in which case, this is where the automatically -->
78 <!-- generated index should go. -->
80 <xsl:call-template name="id.warning"/>
82 <xsl:if test="count(*)>0 or $generate.index != '0'">
84 <xsl:apply-templates select="." mode="common.html.attributes"/>
85 <xsl:if test="$generate.id.attributes != 0">
86 <xsl:attribute name="id">
87 <xsl:call-template name="object.id"/>
91 <xsl:call-template name="setindex.titlepage"/>
92 <xsl:apply-templates/>
94 <xsl:if test="count(indexentry) = 0 and count(indexdiv) = 0">
95 <xsl:call-template name="generate-index">
96 <xsl:with-param name="scope" select="/"/>
100 <xsl:if test="not(parent::article)">
101 <xsl:call-template name="process.footnotes"/>
107 <xsl:template match="index/indexinfo"/>
108 <xsl:template match="index/info"/>
109 <xsl:template match="index/title"/>
110 <xsl:template match="index/subtitle"/>
111 <xsl:template match="index/titleabbrev"/>
113 <!-- ==================================================================== -->
115 <xsl:template match="indexdiv">
116 <xsl:call-template name="id.warning"/>
119 <xsl:apply-templates select="." mode="common.html.attributes"/>
120 <xsl:if test="$generate.id.attributes != 0">
121 <xsl:attribute name="id">
122 <xsl:call-template name="object.id"/>
126 <xsl:call-template name="anchor"/>
127 <xsl:apply-templates select="*[not(self::indexentry)]"/>
129 <xsl:apply-templates select="indexentry"/>
134 <xsl:template match="indexdiv/title">
136 <xsl:apply-templates select="." mode="common.html.attributes"/>
137 <xsl:apply-templates/>
141 <!-- ==================================================================== -->
143 <xsl:template match="indexterm">
144 <!-- this one must have a name, even if it doesn't have an ID -->
145 <xsl:variable name="id">
146 <xsl:call-template name="object.id"/>
149 <a id="{$id}" class="indexterm"/>
152 <xsl:template match="primary|secondary|tertiary|see|seealso">
155 <!-- ==================================================================== -->
157 <xsl:template match="indexentry">
158 <xsl:apply-templates select="primaryie"/>
161 <xsl:template match="primaryie">
163 <xsl:apply-templates/>
166 <xsl:apply-templates select="following-sibling::seeie [not(preceding-sibling::secondaryie)]" mode="indexentry"/>
167 <xsl:apply-templates select="following-sibling::seealsoie [not(preceding-sibling::secondaryie)]" mode="indexentry"/>
168 <xsl:apply-templates select="following-sibling::secondaryie" mode="indexentry"/>
172 <!-- Handled in mode to convert flat list to structured output -->
173 <xsl:template match="secondaryie">
175 <xsl:template match="tertiaryie">
177 <xsl:template match="seeie|seealsoie">
180 <xsl:template match="secondaryie" mode="indexentry">
183 <xsl:apply-templates/>
186 <!-- select following see* elements up to next secondaryie or tertiary or end -->
187 <xsl:variable name="after.this" select="following-sibling::*"/>
188 <xsl:variable name="next.entry" select="(following-sibling::secondaryie|following-sibling::tertiaryie)[1]"/>
189 <xsl:variable name="before.entry" select="$next.entry/preceding-sibling::*"/>
190 <xsl:variable name="see.intersection" select="$after.this[count(.|$before.entry) = count($before.entry)] [self::seeie or self::seealsoie]"/>
192 <xsl:when test="count($see.intersection) != 0">
193 <xsl:apply-templates select="$see.intersection" mode="indexentry"/>
195 <xsl:when test="count($next.entry) = 0">
196 <xsl:apply-templates select="following-sibling::seeie" mode="indexentry"/>
197 <xsl:apply-templates select="following-sibling::seealsoie" mode="indexentry"/>
201 <!-- now process any tertiaryie before the next secondaryie -->
202 <xsl:variable name="before.next.secondary" select="following-sibling::secondaryie[1]/preceding-sibling::*"/>
203 <xsl:variable name="tertiary.intersection" select="$after.this[count(.|$before.next.secondary) = count($before.next.secondary)] [not(self::seeie) and not(self::seealsoie)]"/>
205 <xsl:when test="count($tertiary.intersection) != 0">
206 <xsl:apply-templates select="$tertiary.intersection" mode="indexentry"/>
208 <xsl:when test="not(following-sibling::secondaryie)">
209 <xsl:apply-templates select="following-sibling::tertiaryie" mode="indexentry"/>
216 <xsl:template match="tertiaryie" mode="indexentry">
219 <xsl:apply-templates/>
222 <!-- select following see* elements up to next secondaryie or tertiary or end -->
223 <xsl:variable name="after.this" select="following-sibling::*"/>
224 <xsl:variable name="next.entry" select="(following-sibling::secondaryie|following-sibling::tertiaryie)[1]"/>
225 <xsl:variable name="before.entry" select="$next.entry/preceding-sibling::*"/>
226 <xsl:variable name="see.intersection" select="$after.this[count(.|$before.entry) = count($before.entry)] [self::seeie or self::seealsoie]"/>
228 <xsl:when test="count($see.intersection) != 0">
229 <xsl:apply-templates select="$see.intersection" mode="indexentry"/>
231 <xsl:when test="count($next.entry) = 0">
232 <xsl:apply-templates select="following-sibling::seeie" mode="indexentry"/>
233 <xsl:apply-templates select="following-sibling::seealsoie" mode="indexentry"/>
240 <xsl:template match="seeie" mode="indexentry">
242 <xsl:text>(</xsl:text>
243 <xsl:call-template name="gentext">
244 <xsl:with-param name="key" select="'see'"/>
246 <xsl:text> </xsl:text>
247 <xsl:apply-templates/>
248 <xsl:text>)</xsl:text>
252 <xsl:template match="seealsoie" mode="indexentry">
254 <xsl:text>(</xsl:text>
255 <xsl:call-template name="gentext">
256 <xsl:with-param name="key" select="'seealso'"/>
258 <xsl:text> </xsl:text>
259 <xsl:apply-templates/>
260 <xsl:text>)</xsl:text>