| 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 6910 2007-06-28 23:23:30Z xmldoc $ |
| 7 |
******************************************************************** |
| 8 |
|
| 9 |
This file is part of the XSL DocBook Stylesheet distribution. |
| 10 |
See ../README or http://docbook.sf.net/release/xsl/current/ for |
| 11 |
copyright 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> |
| 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"/> |
| 32 |
</xsl:attribute> |
| 33 |
</xsl:if> |
| 34 |
|
| 35 |
<xsl:call-template name="index.titlepage"/> |
| 36 |
<xsl:choose> |
| 37 |
<xsl:when test="indexdiv"> |
| 38 |
<xsl:apply-templates/> |
| 39 |
</xsl:when> |
| 40 |
<xsl:otherwise> |
| 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. --> |
| 52 |
<dl> |
| 53 |
<xsl:apply-templates select="indexentry"/> |
| 54 |
</dl> |
| 55 |
</xsl:if> |
| 56 |
</xsl:otherwise> |
| 57 |
</xsl:choose> |
| 58 |
|
| 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()]"/> |
| 62 |
</xsl:call-template> |
| 63 |
</xsl:if> |
| 64 |
|
| 65 |
<xsl:if test="not(parent::article)"> |
| 66 |
<xsl:call-template name="process.footnotes"/> |
| 67 |
</xsl:if> |
| 68 |
</div> |
| 69 |
</xsl:if> |
| 70 |
</xsl:template> |
| 71 |
|
| 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. --> |
| 78 |
|
| 79 |
<xsl:call-template name="id.warning"/> |
| 80 |
|
| 81 |
<xsl:if test="count(*)>0 or $generate.index != '0'"> |
| 82 |
<div> |
| 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"/> |
| 87 |
</xsl:attribute> |
| 88 |
</xsl:if> |
| 89 |
|
| 90 |
<xsl:call-template name="setindex.titlepage"/> |
| 91 |
<xsl:apply-templates/> |
| 92 |
|
| 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="/"/> |
| 96 |
</xsl:call-template> |
| 97 |
</xsl:if> |
| 98 |
|
| 99 |
<xsl:if test="not(parent::article)"> |
| 100 |
<xsl:call-template name="process.footnotes"/> |
| 101 |
</xsl:if> |
| 102 |
</div> |
| 103 |
</xsl:if> |
| 104 |
</xsl:template> |
| 105 |
|
| 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> |
| 111 |
|
| 112 |
<!-- ==================================================================== --> |
| 113 |
|
| 114 |
<xsl:template match="indexdiv"> |
| 115 |
<xsl:call-template name="id.warning"/> |
| 116 |
|
| 117 |
<div> |
| 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"/> |
| 122 |
</xsl:attribute> |
| 123 |
</xsl:if> |
| 124 |
|
| 125 |
<xsl:call-template name="anchor"/> |
| 126 |
<xsl:apply-templates select="*[not(self::indexentry)]"/> |
| 127 |
<dl> |
| 128 |
<xsl:apply-templates select="indexentry"/> |
| 129 |
</dl> |
| 130 |
</div> |
| 131 |
</xsl:template> |
| 132 |
|
| 133 |
<xsl:template match="indexdiv/title"> |
| 134 |
<h3> |
| 135 |
<xsl:apply-templates select="." mode="class.attribute"/> |
| 136 |
<xsl:apply-templates/> |
| 137 |
</h3> |
| 138 |
</xsl:template> |
| 139 |
|
| 140 |
<!-- ==================================================================== --> |
| 141 |
|
| 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"/> |
| 146 |
</xsl:variable> |
| 147 |
|
| 148 |
<a class="indexterm" name="{$id}"/> |
| 149 |
</xsl:template> |
| 150 |
|
| 151 |
<xsl:template match="primary|secondary|tertiary|see|seealso"> |
| 152 |
</xsl:template> |
| 153 |
|
| 154 |
<!-- ==================================================================== --> |
| 155 |
|
| 156 |
<xsl:template match="indexentry"> |
| 157 |
<xsl:apply-templates select="primaryie"/> |
| 158 |
</xsl:template> |
| 159 |
|
| 160 |
<xsl:template match="primaryie"> |
| 161 |
<dt> |
| 162 |
<xsl:apply-templates/> |
| 163 |
</dt> |
| 164 |
<xsl:choose> |
| 165 |
<xsl:when test="following-sibling::secondaryie"> |
| 166 |
<dd> |
| 167 |
<dl> |
| 168 |
<xsl:apply-templates select="following-sibling::secondaryie"/> |
| 169 |
</dl> |
| 170 |
</dd> |
| 171 |
</xsl:when> |
| 172 |
<xsl:when test="following-sibling::seeie |
| 173 |
|following-sibling::seealsoie"> |
| 174 |
<dd> |
| 175 |
<dl> |
| 176 |
<xsl:apply-templates select="following-sibling::seeie |
| 177 |
|following-sibling::seealsoie"/> |
| 178 |
</dl> |
| 179 |
</dd> |
| 180 |
</xsl:when> |
| 181 |
</xsl:choose> |
| 182 |
</xsl:template> |
| 183 |
|
| 184 |
<xsl:template match="secondaryie"> |
| 185 |
<dt> |
| 186 |
<xsl:apply-templates/> |
| 187 |
</dt> |
| 188 |
<xsl:choose> |
| 189 |
<xsl:when test="following-sibling::tertiaryie"> |
| 190 |
<dd> |
| 191 |
<dl> |
| 192 |
<xsl:apply-templates select="following-sibling::tertiaryie"/> |
| 193 |
</dl> |
| 194 |
</dd> |
| 195 |
</xsl:when> |
| 196 |
<xsl:when test="following-sibling::seeie |
| 197 |
|following-sibling::seealsoie"> |
| 198 |
<dd> |
| 199 |
<dl> |
| 200 |
<xsl:apply-templates select="following-sibling::seeie |
| 201 |
|following-sibling::seealsoie"/> |
| 202 |
</dl> |
| 203 |
</dd> |
| 204 |
</xsl:when> |
| 205 |
</xsl:choose> |
| 206 |
</xsl:template> |
| 207 |
|
| 208 |
<xsl:template match="tertiaryie"> |
| 209 |
<dt> |
| 210 |
<xsl:apply-templates/> |
| 211 |
</dt> |
| 212 |
<xsl:if test="following-sibling::seeie |
| 213 |
|following-sibling::seealsoie"> |
| 214 |
<dd> |
| 215 |
<dl> |
| 216 |
<xsl:apply-templates select="following-sibling::seeie |
| 217 |
|following-sibling::seealsoie"/> |
| 218 |
</dl> |
| 219 |
</dd> |
| 220 |
</xsl:if> |
| 221 |
</xsl:template> |
| 222 |
|
| 223 |
<xsl:template match="seeie|seealsoie"> |
| 224 |
<dt> |
| 225 |
<xsl:apply-templates/> |
| 226 |
</dt> |
| 227 |
</xsl:template> |
| 228 |
|
| 229 |
</xsl:stylesheet> |