[15c7d39] | 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 9297 2012-04-22 03:56:16Z bobstayton $
|
---|
| 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="common.html.attributes"/>
|
---|
| 29 | <xsl:call-template name="id.attribute">
|
---|
| 30 | <xsl:with-param name="conditional" select="0"/>
|
---|
| 31 | </xsl:call-template>
|
---|
| 32 |
|
---|
| 33 | <xsl:call-template name="index.titlepage"/>
|
---|
| 34 | <xsl:choose>
|
---|
| 35 | <xsl:when test="indexdiv">
|
---|
| 36 | <xsl:apply-templates/>
|
---|
| 37 | </xsl:when>
|
---|
| 38 | <xsl:otherwise>
|
---|
| 39 | <xsl:apply-templates select="*[not(self::indexentry)]"/>
|
---|
| 40 | <!-- Because it's actually valid for Index to have neither any -->
|
---|
| 41 | <!-- Indexdivs nor any Indexentries, we need to check and make -->
|
---|
| 42 | <!-- sure that at least one Indexentry exists, and generate a -->
|
---|
| 43 | <!-- wrapper dl if there is at least one; otherwise, do nothing. -->
|
---|
| 44 | <xsl:if test="indexentry">
|
---|
| 45 | <!-- The indexentry template assumes a parent dl wrapper has -->
|
---|
| 46 | <!-- been generated; for Indexes that have Indexdivs, the dl -->
|
---|
| 47 | <!-- wrapper is generated by the indexdiv template; however, -->
|
---|
| 48 | <!-- for Indexes that lack Indexdivs, if we don't generate a -->
|
---|
| 49 | <!-- dl here, HTML output will not be valid. -->
|
---|
| 50 | <dl>
|
---|
| 51 | <xsl:apply-templates select="indexentry"/>
|
---|
| 52 | </dl>
|
---|
| 53 | </xsl:if>
|
---|
| 54 | </xsl:otherwise>
|
---|
| 55 | </xsl:choose>
|
---|
| 56 |
|
---|
| 57 | <xsl:if test="count(indexentry) = 0 and count(indexdiv) = 0">
|
---|
| 58 | <xsl:call-template name="generate-index">
|
---|
| 59 | <xsl:with-param name="scope" select="(ancestor::book|/)[last()]"/>
|
---|
| 60 | </xsl:call-template>
|
---|
| 61 | </xsl:if>
|
---|
| 62 |
|
---|
| 63 | <xsl:if test="not(parent::article)">
|
---|
| 64 | <xsl:call-template name="process.footnotes"/>
|
---|
| 65 | </xsl:if>
|
---|
| 66 | </div>
|
---|
| 67 | </xsl:if>
|
---|
| 68 | </xsl:template>
|
---|
| 69 |
|
---|
| 70 | <xsl:template match="setindex">
|
---|
| 71 | <!-- some implementations use completely empty index tags to indicate -->
|
---|
| 72 | <!-- where an automatically generated index should be inserted. so -->
|
---|
| 73 | <!-- if the index is completely empty, skip it. Unless generate.index -->
|
---|
| 74 | <!-- is non-zero, in which case, this is where the automatically -->
|
---|
| 75 | <!-- generated index should go. -->
|
---|
| 76 |
|
---|
| 77 | <xsl:call-template name="id.warning"/>
|
---|
| 78 |
|
---|
| 79 | <xsl:if test="count(*)>0 or $generate.index != '0'">
|
---|
| 80 | <div>
|
---|
| 81 | <xsl:apply-templates select="." mode="common.html.attributes"/>
|
---|
| 82 | <xsl:call-template name="id.attribute">
|
---|
| 83 | <xsl:with-param name="conditional" select="0"/>
|
---|
| 84 | </xsl:call-template>
|
---|
| 85 |
|
---|
| 86 | <xsl:call-template name="setindex.titlepage"/>
|
---|
| 87 | <xsl:apply-templates/>
|
---|
| 88 |
|
---|
| 89 | <xsl:if test="count(indexentry) = 0 and count(indexdiv) = 0">
|
---|
| 90 | <xsl:call-template name="generate-index">
|
---|
| 91 | <xsl:with-param name="scope" select="/"/>
|
---|
| 92 | </xsl:call-template>
|
---|
| 93 | </xsl:if>
|
---|
| 94 |
|
---|
| 95 | <xsl:if test="not(parent::article)">
|
---|
| 96 | <xsl:call-template name="process.footnotes"/>
|
---|
| 97 | </xsl:if>
|
---|
| 98 | </div>
|
---|
| 99 | </xsl:if>
|
---|
| 100 | </xsl:template>
|
---|
| 101 |
|
---|
| 102 | <xsl:template match="index/indexinfo"></xsl:template>
|
---|
| 103 | <xsl:template match="index/info"></xsl:template>
|
---|
| 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>
|
---|
| 114 | <xsl:apply-templates select="." mode="common.html.attributes"/>
|
---|
| 115 | <xsl:call-template name="id.attribute"/>
|
---|
| 116 | <xsl:call-template name="anchor"/>
|
---|
| 117 | <xsl:apply-templates select="*[not(self::indexentry)]"/>
|
---|
| 118 | <dl>
|
---|
| 119 | <xsl:apply-templates select="indexentry"/>
|
---|
| 120 | </dl>
|
---|
| 121 | </div>
|
---|
| 122 | </xsl:template>
|
---|
| 123 |
|
---|
| 124 | <xsl:template match="indexdiv/title">
|
---|
| 125 | <h3>
|
---|
| 126 | <xsl:apply-templates select="." mode="common.html.attributes"/>
|
---|
| 127 | <xsl:apply-templates/>
|
---|
| 128 | </h3>
|
---|
| 129 | </xsl:template>
|
---|
| 130 |
|
---|
| 131 | <!-- ==================================================================== -->
|
---|
| 132 |
|
---|
| 133 | <xsl:template match="indexterm">
|
---|
| 134 | <!-- this one must have a name, even if it doesn't have an ID -->
|
---|
| 135 | <xsl:variable name="id">
|
---|
| 136 | <xsl:call-template name="object.id"/>
|
---|
| 137 | </xsl:variable>
|
---|
| 138 |
|
---|
| 139 | <a class="indexterm" name="{$id}"/>
|
---|
| 140 | </xsl:template>
|
---|
| 141 |
|
---|
| 142 | <xsl:template match="primary|secondary|tertiary|see|seealso">
|
---|
| 143 | </xsl:template>
|
---|
| 144 |
|
---|
| 145 | <!-- ==================================================================== -->
|
---|
| 146 |
|
---|
| 147 | <xsl:template match="indexentry">
|
---|
| 148 | <xsl:apply-templates select="primaryie"/>
|
---|
| 149 | </xsl:template>
|
---|
| 150 |
|
---|
| 151 | <xsl:template match="primaryie">
|
---|
| 152 | <dt>
|
---|
| 153 | <xsl:apply-templates/>
|
---|
| 154 | </dt>
|
---|
| 155 | <dd>
|
---|
| 156 | <xsl:apply-templates select="following-sibling::seeie
|
---|
| 157 | [not(preceding-sibling::secondaryie)]"
|
---|
| 158 | mode="indexentry"/>
|
---|
| 159 | <xsl:apply-templates select="following-sibling::seealsoie
|
---|
| 160 | [not(preceding-sibling::secondaryie)]"
|
---|
| 161 | mode="indexentry"/>
|
---|
| 162 | <xsl:apply-templates select="following-sibling::secondaryie"
|
---|
| 163 | mode="indexentry"/>
|
---|
| 164 | </dd>
|
---|
| 165 | </xsl:template>
|
---|
| 166 |
|
---|
| 167 | <!-- Handled in mode to convert flat list to structured output -->
|
---|
| 168 | <xsl:template match="secondaryie">
|
---|
| 169 | </xsl:template>
|
---|
| 170 | <xsl:template match="tertiaryie">
|
---|
| 171 | </xsl:template>
|
---|
| 172 | <xsl:template match="seeie|seealsoie">
|
---|
| 173 | </xsl:template>
|
---|
| 174 |
|
---|
| 175 | <xsl:template match="secondaryie" mode="indexentry">
|
---|
| 176 | <dl>
|
---|
| 177 | <dt>
|
---|
| 178 | <xsl:apply-templates/>
|
---|
| 179 | </dt>
|
---|
| 180 | <dd>
|
---|
| 181 | <!-- select following see* elements up to next secondaryie or tertiary or end -->
|
---|
| 182 | <xsl:variable name="after.this"
|
---|
| 183 | select="following-sibling::*"/>
|
---|
| 184 | <xsl:variable name="next.entry"
|
---|
| 185 | select="(following-sibling::secondaryie|following-sibling::tertiaryie)[1]"/>
|
---|
| 186 | <xsl:variable name="before.entry"
|
---|
| 187 | select="$next.entry/preceding-sibling::*"/>
|
---|
| 188 | <xsl:variable name="see.intersection"
|
---|
| 189 | select="$after.this[count(.|$before.entry) = count($before.entry)]
|
---|
| 190 | [self::seeie or self::seealsoie]"/>
|
---|
| 191 | <xsl:choose>
|
---|
| 192 | <xsl:when test="count($see.intersection) != 0">
|
---|
| 193 | <xsl:apply-templates select="$see.intersection" mode="indexentry"/>
|
---|
| 194 | </xsl:when>
|
---|
| 195 | <xsl:when test="count($next.entry) = 0">
|
---|
| 196 | <xsl:apply-templates select="following-sibling::seeie"
|
---|
| 197 | mode="indexentry"/>
|
---|
| 198 | <xsl:apply-templates select="following-sibling::seealsoie"
|
---|
| 199 | mode="indexentry"/>
|
---|
| 200 | </xsl:when>
|
---|
| 201 | </xsl:choose>
|
---|
| 202 |
|
---|
| 203 | <!-- now process any tertiaryie before the next secondaryie -->
|
---|
| 204 | <xsl:variable name="before.next.secondary"
|
---|
| 205 | select="following-sibling::secondaryie[1]/preceding-sibling::*"/>
|
---|
| 206 | <xsl:variable name="tertiary.intersection"
|
---|
| 207 | select="$after.this[count(.|$before.next.secondary) =
|
---|
| 208 | count($before.next.secondary)]
|
---|
| 209 | [not(self::seeie) and not(self::seealsoie)]"/>
|
---|
| 210 | <xsl:choose>
|
---|
| 211 | <xsl:when test="count($tertiary.intersection) != 0">
|
---|
| 212 | <xsl:apply-templates select="$tertiary.intersection"
|
---|
| 213 | mode="indexentry"/>
|
---|
| 214 | </xsl:when>
|
---|
| 215 | <xsl:when test="not(following-sibling::secondaryie)">
|
---|
| 216 | <xsl:apply-templates select="following-sibling::tertiaryie"
|
---|
| 217 | mode="indexentry"/>
|
---|
| 218 | </xsl:when>
|
---|
| 219 | </xsl:choose>
|
---|
| 220 | </dd>
|
---|
| 221 | </dl>
|
---|
| 222 | </xsl:template>
|
---|
| 223 |
|
---|
| 224 | <xsl:template match="tertiaryie" mode="indexentry">
|
---|
| 225 | <dl>
|
---|
| 226 | <dt>
|
---|
| 227 | <xsl:apply-templates/>
|
---|
| 228 | </dt>
|
---|
| 229 | <dd>
|
---|
| 230 | <!-- select following see* elements up to next secondaryie or tertiary or end -->
|
---|
| 231 | <xsl:variable name="after.this"
|
---|
| 232 | select="following-sibling::*"/>
|
---|
| 233 | <xsl:variable name="next.entry"
|
---|
| 234 | select="(following-sibling::secondaryie|following-sibling::tertiaryie)[1]"/>
|
---|
| 235 | <xsl:variable name="before.entry"
|
---|
| 236 | select="$next.entry/preceding-sibling::*"/>
|
---|
| 237 | <xsl:variable name="see.intersection"
|
---|
| 238 | select="$after.this[count(.|$before.entry) = count($before.entry)]
|
---|
| 239 | [self::seeie or self::seealsoie]"/>
|
---|
| 240 | <xsl:choose>
|
---|
| 241 | <xsl:when test="count($see.intersection) != 0">
|
---|
| 242 | <xsl:apply-templates select="$see.intersection" mode="indexentry"/>
|
---|
| 243 | </xsl:when>
|
---|
| 244 | <xsl:when test="count($next.entry) = 0">
|
---|
| 245 | <xsl:apply-templates select="following-sibling::seeie"
|
---|
| 246 | mode="indexentry"/>
|
---|
| 247 | <xsl:apply-templates select="following-sibling::seealsoie"
|
---|
| 248 | mode="indexentry"/>
|
---|
| 249 | </xsl:when>
|
---|
| 250 | </xsl:choose>
|
---|
| 251 | </dd>
|
---|
| 252 | </dl>
|
---|
| 253 | </xsl:template>
|
---|
| 254 |
|
---|
| 255 | <xsl:template match="seeie" mode="indexentry">
|
---|
| 256 | <dt>
|
---|
| 257 | <xsl:text>(</xsl:text>
|
---|
| 258 | <xsl:call-template name="gentext">
|
---|
| 259 | <xsl:with-param name="key" select="'see'"/>
|
---|
| 260 | </xsl:call-template>
|
---|
| 261 | <xsl:text> </xsl:text>
|
---|
| 262 | <xsl:apply-templates/>
|
---|
| 263 | <xsl:text>)</xsl:text>
|
---|
| 264 | </dt>
|
---|
| 265 | </xsl:template>
|
---|
| 266 |
|
---|
| 267 | <xsl:template match="seealsoie" mode="indexentry">
|
---|
| 268 | <div>
|
---|
| 269 | <xsl:text>(</xsl:text>
|
---|
| 270 | <xsl:call-template name="gentext">
|
---|
| 271 | <xsl:with-param name="key" select="'seealso'"/>
|
---|
| 272 | </xsl:call-template>
|
---|
| 273 | <xsl:text> </xsl:text>
|
---|
| 274 | <xsl:apply-templates/>
|
---|
| 275 | <xsl:text>)</xsl:text>
|
---|
| 276 | </div>
|
---|
| 277 | </xsl:template>
|
---|
| 278 |
|
---|
| 279 | </xsl:stylesheet>
|
---|