1<?xml version='1.0'?> 2<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 3 version='1.0'> 4 5<!-- ******************************************************************** 6 $Id: index.xsl,v 1.16 2005/10/28 12:35:15 nwalsh Exp $ 7 ******************************************************************** 8 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. 12 13 ******************************************************************** --> 14 15<!-- ==================================================================== --> 16 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. --> 23 24 <xsl:call-template name="id.warning"/> 25 26 <xsl:if test="count(*)>0 or $generate.index != '0'"> 27 <div class="{name(.)}"> 28 <xsl:if test="$generate.id.attributes != 0"> 29 <xsl:attribute name="id"> 30 <xsl:call-template name="object.id"/> 31 </xsl:attribute> 32 </xsl:if> 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 class="{name(.)}"> 82 <xsl:if test="$generate.id.attributes != 0"> 83 <xsl:attribute name="id"> 84 <xsl:call-template name="object.id"/> 85 </xsl:attribute> 86 </xsl:if> 87 88 <xsl:call-template name="setindex.titlepage"/> 89 <xsl:apply-templates/> 90 91 <xsl:if test="count(indexentry) = 0 and count(indexdiv) = 0"> 92 <xsl:call-template name="generate-index"> 93 <xsl:with-param name="scope" select="/"/> 94 </xsl:call-template> 95 </xsl:if> 96 97 <xsl:if test="not(parent::article)"> 98 <xsl:call-template name="process.footnotes"/> 99 </xsl:if> 100 </div> 101 </xsl:if> 102</xsl:template> 103 104<xsl:template match="index/title"></xsl:template> 105<xsl:template match="index/subtitle"></xsl:template> 106<xsl:template match="index/titleabbrev"></xsl:template> 107 108<!-- ==================================================================== --> 109 110<xsl:template match="indexdiv"> 111 <xsl:call-template name="id.warning"/> 112 113 <div class="{name(.)}"> 114 <xsl:if test="$generate.id.attributes != 0"> 115 <xsl:attribute name="id"> 116 <xsl:call-template name="object.id"/> 117 </xsl:attribute> 118 </xsl:if> 119 120 <xsl:call-template name="anchor"/> 121 <xsl:apply-templates select="*[not(self::indexentry)]"/> 122 <dl> 123 <xsl:apply-templates select="indexentry"/> 124 </dl> 125 </div> 126</xsl:template> 127 128<xsl:template match="indexdiv/title"> 129 <h3 class="{name(.)}"> 130 <xsl:apply-templates/> 131 </h3> 132</xsl:template> 133 134<!-- ==================================================================== --> 135 136<xsl:template match="indexterm"> 137 <!-- this one must have a name, even if it doesn't have an ID --> 138 <xsl:variable name="id"> 139 <xsl:call-template name="object.id"/> 140 </xsl:variable> 141 142 <a class="indexterm" name="{$id}"/> 143</xsl:template> 144 145<xsl:template match="primary|secondary|tertiary|see|seealso"> 146</xsl:template> 147 148<!-- ==================================================================== --> 149 150<xsl:template match="indexentry"> 151 <xsl:apply-templates select="primaryie"/> 152</xsl:template> 153 154<xsl:template match="primaryie"> 155 <dt> 156 <xsl:apply-templates/> 157 </dt> 158 <xsl:choose> 159 <xsl:when test="following-sibling::secondaryie"> 160 <dd> 161 <dl> 162 <xsl:apply-templates select="following-sibling::secondaryie"/> 163 </dl> 164 </dd> 165 </xsl:when> 166 <xsl:when test="following-sibling::seeie 167 |following-sibling::seealsoie"> 168 <dd> 169 <dl> 170 <xsl:apply-templates select="following-sibling::seeie 171 |following-sibling::seealsoie"/> 172 </dl> 173 </dd> 174 </xsl:when> 175 </xsl:choose> 176</xsl:template> 177 178<xsl:template match="secondaryie"> 179 <dt> 180 <xsl:apply-templates/> 181 </dt> 182 <xsl:choose> 183 <xsl:when test="following-sibling::tertiaryie"> 184 <dd> 185 <dl> 186 <xsl:apply-templates select="following-sibling::tertiaryie"/> 187 </dl> 188 </dd> 189 </xsl:when> 190 <xsl:when test="following-sibling::seeie 191 |following-sibling::seealsoie"> 192 <dd> 193 <dl> 194 <xsl:apply-templates select="following-sibling::seeie 195 |following-sibling::seealsoie"/> 196 </dl> 197 </dd> 198 </xsl:when> 199 </xsl:choose> 200</xsl:template> 201 202<xsl:template match="tertiaryie"> 203 <dt> 204 <xsl:apply-templates/> 205 </dt> 206 <xsl:if test="following-sibling::seeie 207 |following-sibling::seealsoie"> 208 <dd> 209 <dl> 210 <xsl:apply-templates select="following-sibling::seeie 211 |following-sibling::seealsoie"/> 212 </dl> 213 </dd> 214 </xsl:if> 215</xsl:template> 216 217<xsl:template match="seeie|seealsoie"> 218 <dt> 219 <xsl:apply-templates/> 220 </dt> 221</xsl:template> 222 223</xsl:stylesheet> 224