[2] | 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: glossary.xsl,v 1.19 2005/05/13 17:23:42 bobstayton 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="glossary">
|
---|
| 18 | <div class="{name(.)}">
|
---|
| 19 | <xsl:if test="$generate.id.attributes != 0">
|
---|
| 20 | <xsl:attribute name="id">
|
---|
| 21 | <xsl:call-template name="object.id"/>
|
---|
| 22 | </xsl:attribute>
|
---|
| 23 | </xsl:if>
|
---|
| 24 |
|
---|
| 25 | <xsl:call-template name="glossary.titlepage"/>
|
---|
| 26 |
|
---|
| 27 | <xsl:choose>
|
---|
| 28 | <xsl:when test="glossdiv">
|
---|
| 29 | <xsl:apply-templates select="(glossdiv[1]/preceding-sibling::*)"/>
|
---|
| 30 | </xsl:when>
|
---|
| 31 | <xsl:otherwise>
|
---|
| 32 | <xsl:apply-templates select="(glossentry[1]/preceding-sibling::*)"/>
|
---|
| 33 | </xsl:otherwise>
|
---|
| 34 | </xsl:choose>
|
---|
| 35 |
|
---|
| 36 | <xsl:choose>
|
---|
| 37 | <xsl:when test="glossdiv">
|
---|
| 38 | <xsl:apply-templates select="glossdiv"/>
|
---|
| 39 | </xsl:when>
|
---|
| 40 | <xsl:otherwise>
|
---|
| 41 | <dl>
|
---|
| 42 | <xsl:apply-templates select="glossentry"/>
|
---|
| 43 | </dl>
|
---|
| 44 | </xsl:otherwise>
|
---|
| 45 | </xsl:choose>
|
---|
| 46 |
|
---|
| 47 | <xsl:if test="not(parent::article)">
|
---|
| 48 | <xsl:call-template name="process.footnotes"/>
|
---|
| 49 | </xsl:if>
|
---|
| 50 | </div>
|
---|
| 51 | </xsl:template>
|
---|
| 52 |
|
---|
| 53 | <xsl:template match="glossary/glossaryinfo"></xsl:template>
|
---|
| 54 | <xsl:template match="glossary/title"></xsl:template>
|
---|
| 55 | <xsl:template match="glossary/subtitle"></xsl:template>
|
---|
| 56 | <xsl:template match="glossary/titleabbrev"></xsl:template>
|
---|
| 57 |
|
---|
| 58 | <!-- ==================================================================== -->
|
---|
| 59 |
|
---|
| 60 | <xsl:template match="glosslist">
|
---|
| 61 | <div class="{name(.)}">
|
---|
| 62 | <xsl:call-template name="anchor"/>
|
---|
| 63 | <xsl:if test="blockinfo/title|title">
|
---|
| 64 | <xsl:call-template name="formal.object.heading"/>
|
---|
| 65 | </xsl:if>
|
---|
| 66 | <dl>
|
---|
| 67 | <xsl:apply-templates select="glossentry"/>
|
---|
| 68 | </dl>
|
---|
| 69 | </div>
|
---|
| 70 | </xsl:template>
|
---|
| 71 |
|
---|
| 72 | <!-- ==================================================================== -->
|
---|
| 73 |
|
---|
| 74 | <xsl:template match="glossdiv">
|
---|
| 75 | <div class="{name(.)}">
|
---|
| 76 | <xsl:apply-templates select="(glossentry[1]/preceding-sibling::*)"/>
|
---|
| 77 |
|
---|
| 78 | <dl>
|
---|
| 79 | <xsl:apply-templates select="glossentry"/>
|
---|
| 80 | </dl>
|
---|
| 81 | </div>
|
---|
| 82 | </xsl:template>
|
---|
| 83 |
|
---|
| 84 | <xsl:template match="glossdiv/title">
|
---|
| 85 | <h3 class="{name(.)}">
|
---|
| 86 | <xsl:apply-templates/>
|
---|
| 87 | </h3>
|
---|
| 88 | </xsl:template>
|
---|
| 89 |
|
---|
| 90 | <!-- ==================================================================== -->
|
---|
| 91 |
|
---|
| 92 | <!--
|
---|
| 93 | GlossEntry ::=
|
---|
| 94 | GlossTerm, Acronym?, Abbrev?,
|
---|
| 95 | (IndexTerm)*,
|
---|
| 96 | RevHistory?,
|
---|
| 97 | (GlossSee | GlossDef+)
|
---|
| 98 | -->
|
---|
| 99 |
|
---|
| 100 | <xsl:template match="glossentry">
|
---|
| 101 | <xsl:choose>
|
---|
| 102 | <xsl:when test="$glossentry.show.acronym = 'primary'">
|
---|
| 103 | <dt>
|
---|
| 104 | <xsl:call-template name="anchor">
|
---|
| 105 | <xsl:with-param name="conditional">
|
---|
| 106 | <xsl:choose>
|
---|
| 107 | <xsl:when test="$glossterm.auto.link != 0">0</xsl:when>
|
---|
| 108 | <xsl:otherwise>1</xsl:otherwise>
|
---|
| 109 | </xsl:choose>
|
---|
| 110 | </xsl:with-param>
|
---|
| 111 | </xsl:call-template>
|
---|
| 112 |
|
---|
| 113 | <xsl:choose>
|
---|
| 114 | <xsl:when test="acronym|abbrev">
|
---|
| 115 | <xsl:apply-templates select="acronym|abbrev"/>
|
---|
| 116 | <xsl:text> (</xsl:text>
|
---|
| 117 | <xsl:apply-templates select="glossterm"/>
|
---|
| 118 | <xsl:text>)</xsl:text>
|
---|
| 119 | </xsl:when>
|
---|
| 120 | <xsl:otherwise>
|
---|
| 121 | <xsl:apply-templates select="glossterm"/>
|
---|
| 122 | </xsl:otherwise>
|
---|
| 123 | </xsl:choose>
|
---|
| 124 | </dt>
|
---|
| 125 | </xsl:when>
|
---|
| 126 | <xsl:when test="$glossentry.show.acronym = 'yes'">
|
---|
| 127 | <dt>
|
---|
| 128 | <xsl:call-template name="anchor">
|
---|
| 129 | <xsl:with-param name="conditional">
|
---|
| 130 | <xsl:choose>
|
---|
| 131 | <xsl:when test="$glossterm.auto.link != 0">0</xsl:when>
|
---|
| 132 | <xsl:otherwise>1</xsl:otherwise>
|
---|
| 133 | </xsl:choose>
|
---|
| 134 | </xsl:with-param>
|
---|
| 135 | </xsl:call-template>
|
---|
| 136 |
|
---|
| 137 | <xsl:apply-templates select="glossterm"/>
|
---|
| 138 |
|
---|
| 139 | <xsl:if test="acronym|abbrev">
|
---|
| 140 | <xsl:text> (</xsl:text>
|
---|
| 141 | <xsl:apply-templates select="acronym|abbrev"/>
|
---|
| 142 | <xsl:text>)</xsl:text>
|
---|
| 143 | </xsl:if>
|
---|
| 144 | </dt>
|
---|
| 145 | </xsl:when>
|
---|
| 146 | <xsl:otherwise>
|
---|
| 147 | <dt>
|
---|
| 148 | <xsl:call-template name="anchor">
|
---|
| 149 | <xsl:with-param name="conditional">
|
---|
| 150 | <xsl:choose>
|
---|
| 151 | <xsl:when test="$glossterm.auto.link != 0">0</xsl:when>
|
---|
| 152 | <xsl:otherwise>1</xsl:otherwise>
|
---|
| 153 | </xsl:choose>
|
---|
| 154 | </xsl:with-param>
|
---|
| 155 | </xsl:call-template>
|
---|
| 156 |
|
---|
| 157 | <xsl:apply-templates select="glossterm"/>
|
---|
| 158 | </dt>
|
---|
| 159 | </xsl:otherwise>
|
---|
| 160 | </xsl:choose>
|
---|
| 161 |
|
---|
| 162 | <xsl:apply-templates select="indexterm|revhistory|glosssee|glossdef"/>
|
---|
| 163 | </xsl:template>
|
---|
| 164 |
|
---|
| 165 | <xsl:template match="glossentry/glossterm">
|
---|
| 166 | <xsl:apply-templates/>
|
---|
| 167 | <xsl:if test="following-sibling::glossterm">, </xsl:if>
|
---|
| 168 | </xsl:template>
|
---|
| 169 |
|
---|
| 170 | <xsl:template match="glossentry/acronym">
|
---|
| 171 | <xsl:apply-templates/>
|
---|
| 172 | <xsl:if test="following-sibling::acronym|following-sibling::abbrev">, </xsl:if>
|
---|
| 173 | </xsl:template>
|
---|
| 174 |
|
---|
| 175 | <xsl:template match="glossentry/abbrev">
|
---|
| 176 | <xsl:apply-templates/>
|
---|
| 177 | <xsl:if test="following-sibling::acronym|following-sibling::abbrev">, </xsl:if>
|
---|
| 178 | </xsl:template>
|
---|
| 179 |
|
---|
| 180 | <xsl:template match="glossentry/revhistory">
|
---|
| 181 | </xsl:template>
|
---|
| 182 |
|
---|
| 183 | <xsl:template match="glossentry/glosssee">
|
---|
| 184 | <xsl:variable name="otherterm" select="@otherterm"/>
|
---|
| 185 | <xsl:variable name="targets" select="//node()[@id=$otherterm]"/>
|
---|
| 186 | <xsl:variable name="target" select="$targets[1]"/>
|
---|
| 187 |
|
---|
| 188 | <dd>
|
---|
| 189 | <p>
|
---|
| 190 | <xsl:variable name="template">
|
---|
| 191 | <xsl:call-template name="gentext.template">
|
---|
| 192 | <xsl:with-param name="context" select="'glossary'"/>
|
---|
| 193 | <xsl:with-param name="name" select="'see'"/>
|
---|
| 194 | </xsl:call-template>
|
---|
| 195 | </xsl:variable>
|
---|
| 196 |
|
---|
| 197 | <xsl:variable name="title">
|
---|
| 198 | <xsl:choose>
|
---|
| 199 | <xsl:when test="$target">
|
---|
| 200 | <a>
|
---|
| 201 | <xsl:attribute name="href">
|
---|
| 202 | <xsl:call-template name="href.target">
|
---|
| 203 | <xsl:with-param name="object" select="$target"/>
|
---|
| 204 | </xsl:call-template>
|
---|
| 205 | </xsl:attribute>
|
---|
| 206 | <xsl:apply-templates select="$target" mode="xref-to"/>
|
---|
| 207 | </a>
|
---|
| 208 | </xsl:when>
|
---|
| 209 | <xsl:when test="$otherterm != '' and not($target)">
|
---|
| 210 | <xsl:message>
|
---|
| 211 | <xsl:text>Warning: glosssee @otherterm reference not found: </xsl:text>
|
---|
| 212 | <xsl:value-of select="$otherterm"/>
|
---|
| 213 | </xsl:message>
|
---|
| 214 | <xsl:apply-templates/>
|
---|
| 215 | </xsl:when>
|
---|
| 216 | <xsl:otherwise>
|
---|
| 217 | <xsl:apply-templates/>
|
---|
| 218 | </xsl:otherwise>
|
---|
| 219 | </xsl:choose>
|
---|
| 220 | </xsl:variable>
|
---|
| 221 |
|
---|
| 222 | <xsl:call-template name="substitute-markup">
|
---|
| 223 | <xsl:with-param name="template" select="$template"/>
|
---|
| 224 | <xsl:with-param name="title" select="$title"/>
|
---|
| 225 | </xsl:call-template>
|
---|
| 226 | <xsl:text>.</xsl:text>
|
---|
| 227 | </p>
|
---|
| 228 | </dd>
|
---|
| 229 | </xsl:template>
|
---|
| 230 |
|
---|
| 231 | <xsl:template match="glossentry/glossdef">
|
---|
| 232 | <dd>
|
---|
| 233 | <xsl:apply-templates select="*[local-name(.) != 'glossseealso']"/>
|
---|
| 234 | <xsl:if test="glossseealso">
|
---|
| 235 | <p>
|
---|
| 236 | <xsl:variable name="template">
|
---|
| 237 | <xsl:call-template name="gentext.template">
|
---|
| 238 | <xsl:with-param name="context" select="'glossary'"/>
|
---|
| 239 | <xsl:with-param name="name" select="'seealso'"/>
|
---|
| 240 | </xsl:call-template>
|
---|
| 241 | </xsl:variable>
|
---|
| 242 | <xsl:variable name="title">
|
---|
| 243 | <xsl:apply-templates select="glossseealso"/>
|
---|
| 244 | </xsl:variable>
|
---|
| 245 | <xsl:call-template name="substitute-markup">
|
---|
| 246 | <xsl:with-param name="template" select="$template"/>
|
---|
| 247 | <xsl:with-param name="title" select="$title"/>
|
---|
| 248 | </xsl:call-template>
|
---|
| 249 | </p>
|
---|
| 250 | </xsl:if>
|
---|
| 251 | </dd>
|
---|
| 252 | </xsl:template>
|
---|
| 253 |
|
---|
| 254 | <xsl:template match="glossseealso">
|
---|
| 255 | <xsl:variable name="otherterm" select="@otherterm"/>
|
---|
| 256 | <xsl:variable name="targets" select="//node()[@id=$otherterm]"/>
|
---|
| 257 | <xsl:variable name="target" select="$targets[1]"/>
|
---|
| 258 |
|
---|
| 259 | <xsl:choose>
|
---|
| 260 | <xsl:when test="$target">
|
---|
| 261 | <a>
|
---|
| 262 | <xsl:attribute name="href">
|
---|
| 263 | <xsl:call-template name="href.target">
|
---|
| 264 | <xsl:with-param name="object" select="$target"/>
|
---|
| 265 | </xsl:call-template>
|
---|
| 266 | </xsl:attribute>
|
---|
| 267 | <xsl:apply-templates select="$target" mode="xref-to"/>
|
---|
| 268 | </a>
|
---|
| 269 | </xsl:when>
|
---|
| 270 | <xsl:when test="$otherterm != '' and not($target)">
|
---|
| 271 | <xsl:message>
|
---|
| 272 | <xsl:text>Warning: glossseealso @otherterm reference not found: </xsl:text>
|
---|
| 273 | <xsl:value-of select="$otherterm"/>
|
---|
| 274 | </xsl:message>
|
---|
| 275 | <xsl:apply-templates/>
|
---|
| 276 | </xsl:when>
|
---|
| 277 | <xsl:otherwise>
|
---|
| 278 | <xsl:apply-templates/>
|
---|
| 279 | </xsl:otherwise>
|
---|
| 280 | </xsl:choose>
|
---|
| 281 |
|
---|
| 282 | <xsl:choose>
|
---|
| 283 | <xsl:when test="position() = last()">
|
---|
| 284 | <xsl:text>.</xsl:text>
|
---|
| 285 | </xsl:when>
|
---|
| 286 | <xsl:otherwise>
|
---|
| 287 | <xsl:text>, </xsl:text>
|
---|
| 288 | </xsl:otherwise>
|
---|
| 289 | </xsl:choose>
|
---|
| 290 | </xsl:template>
|
---|
| 291 |
|
---|
| 292 | <!-- ==================================================================== -->
|
---|
| 293 |
|
---|
| 294 | <!-- Glossary collection -->
|
---|
| 295 |
|
---|
| 296 | <xsl:template match="glossary[@role='auto']" priority="2">
|
---|
| 297 | <xsl:variable name="terms" select="//glossterm[not(parent::glossdef)]|//firstterm"/>
|
---|
| 298 | <xsl:variable name="collection" select="document($glossary.collection, .)"/>
|
---|
| 299 |
|
---|
| 300 | <xsl:if test="$glossary.collection = ''">
|
---|
| 301 | <xsl:message>
|
---|
| 302 | <xsl:text>Warning: processing automatic glossary </xsl:text>
|
---|
| 303 | <xsl:text>without a glossary.collection file.</xsl:text>
|
---|
| 304 | </xsl:message>
|
---|
| 305 | </xsl:if>
|
---|
| 306 |
|
---|
| 307 | <xsl:if test="not($collection) and $glossary.collection != ''">
|
---|
| 308 | <xsl:message>
|
---|
| 309 | <xsl:text>Warning: processing automatic glossary but unable to </xsl:text>
|
---|
| 310 | <xsl:text>open glossary.collection file '</xsl:text>
|
---|
| 311 | <xsl:value-of select="$glossary.collection"/>
|
---|
| 312 | <xsl:text>'</xsl:text>
|
---|
| 313 | </xsl:message>
|
---|
| 314 | </xsl:if>
|
---|
| 315 |
|
---|
| 316 | <div class="{name(.)}">
|
---|
| 317 | <xsl:if test="$generate.id.attributes != 0">
|
---|
| 318 | <xsl:attribute name="id">
|
---|
| 319 | <xsl:call-template name="object.id"/>
|
---|
| 320 | </xsl:attribute>
|
---|
| 321 | </xsl:if>
|
---|
| 322 |
|
---|
| 323 | <xsl:call-template name="glossary.titlepage"/>
|
---|
| 324 |
|
---|
| 325 | <xsl:choose>
|
---|
| 326 | <xsl:when test="glossdiv and $collection//glossdiv">
|
---|
| 327 | <xsl:for-each select="$collection//glossdiv">
|
---|
| 328 | <!-- first see if there are any in this div -->
|
---|
| 329 | <xsl:variable name="exist.test">
|
---|
| 330 | <xsl:for-each select="glossentry">
|
---|
| 331 | <xsl:variable name="cterm" select="glossterm"/>
|
---|
| 332 | <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
|
---|
| 333 | <xsl:value-of select="glossterm"/>
|
---|
| 334 | </xsl:if>
|
---|
| 335 | </xsl:for-each>
|
---|
| 336 | </xsl:variable>
|
---|
| 337 |
|
---|
| 338 | <xsl:if test="$exist.test != ''">
|
---|
| 339 | <xsl:apply-templates select="." mode="auto-glossary">
|
---|
| 340 | <xsl:with-param name="terms" select="$terms"/>
|
---|
| 341 | </xsl:apply-templates>
|
---|
| 342 | </xsl:if>
|
---|
| 343 | </xsl:for-each>
|
---|
| 344 | </xsl:when>
|
---|
| 345 | <xsl:otherwise>
|
---|
| 346 | <dl>
|
---|
| 347 | <xsl:for-each select="$collection//glossentry">
|
---|
| 348 | <xsl:variable name="cterm" select="glossterm"/>
|
---|
| 349 | <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
|
---|
| 350 | <xsl:apply-templates select="." mode="auto-glossary"/>
|
---|
| 351 | </xsl:if>
|
---|
| 352 | </xsl:for-each>
|
---|
| 353 | </dl>
|
---|
| 354 | </xsl:otherwise>
|
---|
| 355 | </xsl:choose>
|
---|
| 356 |
|
---|
| 357 | <xsl:if test="not(parent::article)">
|
---|
| 358 | <xsl:call-template name="process.footnotes"/>
|
---|
| 359 | </xsl:if>
|
---|
| 360 | </div>
|
---|
| 361 | </xsl:template>
|
---|
| 362 |
|
---|
| 363 | <xsl:template match="*" mode="auto-glossary">
|
---|
| 364 | <!-- pop back out to the default mode for most elements -->
|
---|
| 365 | <xsl:apply-templates select="."/>
|
---|
| 366 | </xsl:template>
|
---|
| 367 |
|
---|
| 368 | <xsl:template match="glossdiv" mode="auto-glossary">
|
---|
| 369 | <xsl:param name="terms" select="."/>
|
---|
| 370 |
|
---|
| 371 | <div class="{name(.)}">
|
---|
| 372 | <xsl:apply-templates select="(glossentry[1]/preceding-sibling::*)"/>
|
---|
| 373 |
|
---|
| 374 | <dl>
|
---|
| 375 | <xsl:for-each select="glossentry">
|
---|
| 376 | <xsl:variable name="cterm" select="glossterm"/>
|
---|
| 377 | <xsl:if test="$terms[@baseform = $cterm or . = $cterm]">
|
---|
| 378 | <xsl:apply-templates select="." mode="auto-glossary"/>
|
---|
| 379 | </xsl:if>
|
---|
| 380 | </xsl:for-each>
|
---|
| 381 | </dl>
|
---|
| 382 | </div>
|
---|
| 383 | </xsl:template>
|
---|
| 384 |
|
---|
| 385 | <!-- ==================================================================== -->
|
---|
| 386 |
|
---|
| 387 | </xsl:stylesheet>
|
---|