2 <xsl:stylesheet xmlns:
xsl=
"http://www.w3.org/1999/XSL/Transform"
5 <!-- ********************************************************************
6 $Id: index.xsl,v 1.1 2007/03/10 05:15:13 scott Exp $
7 ********************************************************************
9 This file is part of the XSL DocBook Stylesheet distribution.
10 See ../README or http://nwalsh.com/docbook/xsl/ for copyright
11 and other information.
13 ******************************************************************** -->
15 <!-- ==================================================================== -->
17 <xsl:template match=
"index">
18 <!-- some implementations use completely empty index tags to indicate -->
19 <!-- where an automatically generated index should be inserted. so -->
20 <!-- if the index is completely empty, skip it. Unless generate.index -->
21 <!-- is non-zero, in which case, this is where the automatically -->
22 <!-- generated index should go. -->
24 <xsl:call-template name=
"id.warning"/>
26 <xsl:if test=
"count(*)>0 or $generate.index != '0'">
28 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
29 <xsl:if test=
"$generate.id.attributes != 0">
30 <xsl:attribute name=
"id">
31 <xsl:call-template name=
"object.id"/>
35 <xsl:call-template name=
"index.titlepage"/>
37 <xsl:when test=
"indexdiv">
38 <xsl:apply-templates/>
41 <xsl:apply-templates select=
"*[not(self::indexentry)]"/>
42 <!-- Because it's actually valid for Index to have neither any -->
43 <!-- Indexdivs nor any Indexentries, we need to check and make -->
44 <!-- sure that at least one Indexentry exists, and generate a -->
45 <!-- wrapper dl if there is at least one; otherwise, do nothing. -->
46 <xsl:if test=
"indexentry">
47 <!-- The indexentry template assumes a parent dl wrapper has -->
48 <!-- been generated; for Indexes that have Indexdivs, the dl -->
49 <!-- wrapper is generated by the indexdiv template; however, -->
50 <!-- for Indexes that lack Indexdivs, if we don't generate a -->
51 <!-- dl here, HTML output will not be valid. -->
53 <xsl:apply-templates select=
"indexentry"/>
59 <xsl:if test=
"count(indexentry) = 0 and count(indexdiv) = 0">
60 <xsl:call-template name=
"generate-index">
61 <xsl:with-param name=
"scope" select=
"(ancestor::book|/)[last()]"/>
65 <xsl:if test=
"not(parent::article)">
66 <xsl:call-template name=
"process.footnotes"/>
72 <xsl:template match=
"setindex">
73 <!-- some implementations use completely empty index tags to indicate -->
74 <!-- where an automatically generated index should be inserted. so -->
75 <!-- if the index is completely empty, skip it. Unless generate.index -->
76 <!-- is non-zero, in which case, this is where the automatically -->
77 <!-- generated index should go. -->
79 <xsl:call-template name=
"id.warning"/>
81 <xsl:if test=
"count(*)>0 or $generate.index != '0'">
83 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
84 <xsl:if test=
"$generate.id.attributes != 0">
85 <xsl:attribute name=
"id">
86 <xsl:call-template name=
"object.id"/>
90 <xsl:call-template name=
"setindex.titlepage"/>
91 <xsl:apply-templates/>
93 <xsl:if test=
"count(indexentry) = 0 and count(indexdiv) = 0">
94 <xsl:call-template name=
"generate-index">
95 <xsl:with-param name=
"scope" select=
"/"/>
99 <xsl:if test=
"not(parent::article)">
100 <xsl:call-template name=
"process.footnotes"/>
106 <xsl:template match=
"index/indexinfo"></xsl:template>
107 <xsl:template match=
"index/info"></xsl:template>
108 <xsl:template match=
"index/title"></xsl:template>
109 <xsl:template match=
"index/subtitle"></xsl:template>
110 <xsl:template match=
"index/titleabbrev"></xsl:template>
112 <!-- ==================================================================== -->
114 <xsl:template match=
"indexdiv">
115 <xsl:call-template name=
"id.warning"/>
118 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
119 <xsl:if test=
"$generate.id.attributes != 0">
120 <xsl:attribute name=
"id">
121 <xsl:call-template name=
"object.id"/>
125 <xsl:call-template name=
"anchor"/>
126 <xsl:apply-templates select=
"*[not(self::indexentry)]"/>
128 <xsl:apply-templates select=
"indexentry"/>
133 <xsl:template match=
"indexdiv/title">
135 <xsl:apply-templates select=
"." mode=
"class.attribute"/>
136 <xsl:apply-templates/>
140 <!-- ==================================================================== -->
142 <xsl:template match=
"indexterm">
143 <!-- this one must have a name, even if it doesn't have an ID -->
144 <xsl:variable name=
"id">
145 <xsl:call-template name=
"object.id"/>
148 <a class=
"indexterm" name=
"{$id}"/>
151 <xsl:template match=
"primary|secondary|tertiary|see|seealso">
154 <!-- ==================================================================== -->
156 <xsl:template match=
"indexentry">
157 <xsl:apply-templates select=
"primaryie"/>
160 <xsl:template match=
"primaryie">
162 <xsl:apply-templates/>
165 <xsl:when test=
"following-sibling::secondaryie">
168 <xsl:apply-templates select=
"following-sibling::secondaryie"/>
172 <xsl:when test=
"following-sibling::seeie
173 |following-sibling::seealsoie">
176 <xsl:apply-templates select=
"following-sibling::seeie
177 |following-sibling::seealsoie"/>
184 <xsl:template match=
"secondaryie">
186 <xsl:apply-templates/>
189 <xsl:when test=
"following-sibling::tertiaryie">
192 <xsl:apply-templates select=
"following-sibling::tertiaryie"/>
196 <xsl:when test=
"following-sibling::seeie
197 |following-sibling::seealsoie">
200 <xsl:apply-templates select=
"following-sibling::seeie
201 |following-sibling::seealsoie"/>
208 <xsl:template match=
"tertiaryie">
210 <xsl:apply-templates/>
212 <xsl:if test=
"following-sibling::seeie
213 |following-sibling::seealsoie">
216 <xsl:apply-templates select=
"following-sibling::seeie
217 |following-sibling::seealsoie"/>
223 <xsl:template match=
"seeie|seealsoie">
225 <xsl:apply-templates/>