2
<!DOCTYPE xsl:stylesheet [ <!ENTITY % xsldoc.ent SYSTEM "./xsldoc.ent"> %xsldoc.ent; ]>
3
<!--#############################################################################
4
| $Id: index.mod.xsl,v 1.17 2004/01/27 05:59:51 j-devenish Exp $
5
|- #############################################################################
6
| $Author: j-devenish $
7
+ ############################################################################## -->
9
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
10
xmlns:doc="http://nwalsh.com/xsl/documentation/1.0"
11
exclude-result-prefixes="doc" version='1.0'>
13
<doc:reference id="index" xmlns="">
15
<releaseinfo role="meta">
16
$Id: index.mod.xsl,v 1.17 2004/01/27 05:59:51 j-devenish Exp $
23
<year>2000</year><year>2001</year><year>2002</year><year>2003</year>
24
<holder>Ramon Casellas</holder>
27
<doc:revision rcasver="1.11">&rev_2003_05;</doc:revision>
30
<title>Indices <filename>index.mod.xsl</filename></title>
32
<para>The file <filename>index.mod.xsl</filename> contains the
33
XSL template for <doc:db>index</doc:db>.</para>
35
<para>Describe indexterm-range key.</para>
38
An <literal>indexterm-range</literal> XSLT key is defined for
39
all <quote>startofrange</quote> <doc:db>indexterm</doc:db>
40
elements, matching their <sgmltag
41
class="attribute">id</sgmltag> attribute.
47
<!-- Our key for ranges -->
48
<xsl:key name="indexterm-range" match="indexterm[@class='startofrange']" use="@id"/>
50
<doc:template basename="index" xmlns="">
51
<refpurpose>Process <doc:db>index</doc:db> and <doc:db>setindex</doc:db> elements</refpurpose>
54
Produce a chapter-level index in &LaTeX;.
64
You will need to run your typesetter at least twice, and
65
possibly three times, to have the index generated normally (you
66
will also need to run the <command>makeidx</command> command).
73
<simplelist type='inline'>
80
<xsl:template match="index|setindex">
81
<xsl:variable name="preamble" select="node()[not(self::indexinfo or self::setindexinfo or self::title or self::subtitle or self::titleabbrev or self::indexdiv or self::indexentry)]"/>
82
<xsl:text>\setlength\saveparskip\parskip </xsl:text>
83
<xsl:text>\setlength\saveparindent\parindent </xsl:text>
84
<xsl:text>\begin{dbtolatexindex}{</xsl:text>
85
<xsl:call-template name="generate.label.id"/>
86
<xsl:text>} </xsl:text>
87
<xsl:text>\setlength\tempparskip\parskip \setlength\tempparindent\parindent </xsl:text>
88
<xsl:text>\parskip\saveparskip \parindent\saveparindent </xsl:text>
89
<xsl:text>\noindent </xsl:text><!-- -->
90
<xsl:apply-templates select="$preamble"/>
91
<xsl:call-template name="map.begin"/>
92
<xsl:text>\parskip\tempparskip </xsl:text>
93
<xsl:text>\parindent\tempparindent </xsl:text>
94
<xsl:text>\makeatletter\@input@{\jobname.ind}\makeatother </xsl:text>
95
<xsl:call-template name="map.end"/>
96
<xsl:text>\end{dbtolatexindex} </xsl:text>
99
<doc:template xmlns="">
100
<refpurpose> Essential preamble for <filename>index.mod.xsl</filename> support </refpurpose>
104
This preamble aids the following:
108
Allow user to override the &LaTeX; default index name
109
with a &DocBook; localisation.
112
Integrate <doc:db>index</doc:db>/@<sgmltag
113
class="attribute">id</sgmltag> cross-references
114
with &LaTeX; and tables of contents (makes indices
115
behave a bit like chapters).
118
Allow <quote>preamble</quote> templates or
119
mappings to be applied for indices.
128
<listitem><simpara>&preamble;</simpara></listitem>
132
<xsl:template name="latex.preamble.essential.index">
135
% index labeling helper
136
\newif\ifdocbooktolatexprintindex\docbooktolatexprintindextrue
137
\let\dbtolatex@@theindex\theindex
138
\let\dbtolatex@@endtheindex\endtheindex
139
\def\theindex{\relax}
140
\def\endtheindex{\relax}
141
\newenvironment{dbtolatexindex}[1]
143
\if@openright\cleardoublepage\else\clearpage\fi
144
\let\dbtolatex@@indexname\indexname
145
\def\dbtolatex@indexlabel{%
146
\ifnum \c@secnumdepth >\m@ne \refstepcounter{chapter}\fi%
147
\label{#1}\hypertarget{#1}{\dbtolatex@@indexname}%
148
\global\docbooktolatexprintindexfalse}
149
\def\indexname{\ifdocbooktolatexprintindex\dbtolatex@indexlabel\else\dbtolatex@@indexname\fi}
153
\dbtolatex@@endtheindex\let\indexname\dbtolatex@@indexname
156
\newlength\saveparskip \newlength\saveparindent
157
\newlength\tempparskip \newlength\tempparindent
163
<xsl:template match="index/title">
164
<xsl:call-template name="label.id"> <xsl:with-param name="object" select=".."/> </xsl:call-template>
167
<xsl:template match="indexdiv">
168
<xsl:apply-templates/>
171
<xsl:template match="indexdiv/title">
172
<xsl:call-template name="label.id"> <xsl:with-param name="object" select=".."/> </xsl:call-template>
175
<xsl:template match="primary|secondary|tertiary|see|seealso"/>
179
<doc:template xmlns="">
180
<refpurpose>Process <doc:db>indexterm</doc:db> elements</refpurpose>
183
Identify an instance of an indexed term.
188
<listitem><simpara><xref linkend="param.latex.generate.indexterm"/></simpara></listitem>
196
&LaTeX; code used to format the displayed entry.
197
By default, this is drawn from any <quote>latex-index-style</quote>
198
processing instructions (and is therefore empty most of the time).
199
</simpara></listitem>
205
A &LaTeX; <function condition="latex">index</function> command
206
is issued. When an <doc:db>index</doc:db> element is included
207
in your document and indexing is enabled, this indexterm will
211
When <link linkend="param.latex.is.draft">draft mode</link> is
212
enabled, the physical location of <doc:db
213
basename="indexterm">indexterms</doc:db> will be highlighted
214
within the body of the text as well as appearing in the index
218
&DB2LaTeX; includes some logic to handle the
219
<quote>startofrange</quote> and <quote>endofrange</quote>
223
It is possible to format an entry (e.g.
224
make it bold or italic) by inserting a processing instruction
225
named <quote>latex-index-style</quote> in the appropriate
230
<simplelist type='inline'>
240
<listitem><simpara><xref linkend="param.latex.is.draft"/></simpara></listitem>
244
<!-- INDEX TERM CONTENT MODEL
253
<xsl:template match="indexterm">
254
<xsl:if test="$latex.generate.indexterm='1'">
255
<xsl:variable name="idxterm">
256
<xsl:apply-templates mode="indexterm"/>
259
<xsl:if test="@class and @zone">
260
<xsl:message terminate="yes">Error: Only one attribute (@class or @zone) is in indexterm possible!</xsl:message>
264
<xsl:when test="@class='startofrange'">
265
<xsl:text>\index{</xsl:text>
266
<xsl:value-of select="$idxterm"/>
267
<xsl:text>|(}</xsl:text>
269
<xsl:when test="@class='endofrange'">
271
<xsl:when test="count(key('indexterm-range',@startref)) = 0">
272
<xsl:message terminate="yes"><xsl:text>Error: No indexterm with </xsl:text>
273
<xsl:text>id='</xsl:text><xsl:value-of select="@startref"/>
274
<xsl:text>' found!</xsl:text>
275
<xsl:text> Check your attributs id/startref in your indexterms!</xsl:text>
279
<xsl:variable name="thekey" select="key('indexterm-range',@startref)"/>
280
<xsl:for-each select="$thekey[1]">
281
<xsl:text>\index{</xsl:text>
282
<xsl:apply-templates mode="indexterm"/>
283
<xsl:text>|)}</xsl:text>
289
<xsl:text>\index{</xsl:text>
290
<xsl:value-of select="$idxterm"/>
291
<xsl:text>}</xsl:text>
297
<xsl:template match="*" mode="indexterm">
298
<xsl:message>WARNING: Element '<xsl:value-of select="local-name()"/>' in indexterm not supported and skipped!</xsl:message>
302
<xsl:template match="acronym|foreignphrase" mode="indexterm">
303
<xsl:apply-templates mode="indexterm"/>
307
<doc:template xmlns="">
308
<refpurpose>Process the contents of <doc:db basename="indexterm">indexterms</doc:db></refpurpose>
311
Register a primary index term.
319
Calls <xref linkend="template.index.subterm"/>.
323
<xsl:template match="primary" mode="indexterm">
324
<xsl:call-template name="index.subterm"/>
327
<doc:template xmlns="">
328
<refpurpose>Process the contents of <doc:db basename="indexterm">indexterms</doc:db></refpurpose>
331
Register a secondary or tertiary index term.
339
Calls <xref linkend="template.index.subterm"/>.
343
<xsl:template match="secondary|tertiary" mode="indexterm">
344
<xsl:text>!</xsl:text>
345
<xsl:call-template name="index.subterm"/>
348
<doc:template xmlns="">
349
<refpurpose>Process the contents of <doc:db basename="indexterm">indexterms</doc:db></refpurpose>
352
Register a primary, secondary or tertiary index term.
361
If no <sgmltag class="attribute">sortas</sgmltag> attribute is
362
present, the contents of <doc:db>primary</doc:db>,
363
<doc:db>secondary</doc:db> and <doc:db>tertiary</doc:db>
364
elements are converted to text-only and no templates are
365
applied. If the <sgmltag class="attribute">sortas</sgmltag>
366
attribute is present and non-empty, its value is used for indexing
367
and sorting (but not for display)<!-- and templates
368
<emphasis>are</emphasis> applied for display purposes-->.
373
If a <quote>latex-index-style</quote> processing instruction is
374
present, the displayed indexterm will be formatted by treating
375
the content of the PI as a &LaTeX; command.
380
<xsl:template name="index.subterm">
381
<xsl:variable name="style" select="processing-instruction('latex-index-style')"/>
383
<xsl:when test="@sortas!=''">
384
<xsl:variable name="string">
385
<xsl:call-template name="scape-indexterm">
386
<xsl:with-param name="string" select="@sortas"/>
389
<xsl:variable name="content">
390
<xsl:call-template name="scape-indexterm">
391
<xsl:with-param name="string" select="."/>
394
<xsl:value-of select="normalize-space($string)"/>
395
<xsl:text>@{</xsl:text>
396
<xsl:value-of select="$style"/>
397
<xsl:text>{</xsl:text>
398
<xsl:value-of select="normalize-space($content)"/>
399
<xsl:text>}}</xsl:text>
402
<xsl:variable name="string">
403
<xsl:call-template name="scape-indexterm">
404
<xsl:with-param name="string" select="."/>
407
<xsl:value-of select="normalize-space($string)"/>
408
<xsl:if test="$style!=''">
409
<xsl:text>@{</xsl:text>
410
<xsl:value-of select="$style"/>
411
<xsl:text>{</xsl:text>
412
<xsl:value-of select="normalize-space($string)"/>
413
<xsl:text>}}</xsl:text>
418
<xsl:apply-templates mode="indexterm"/>
422
<doc:template xmlns="">
423
<refpurpose>Process the contents of <doc:db>see</doc:db> and <doc:db>seealso</doc:db> elements</refpurpose>
426
Annotate an index entry with a <quote>See</quote> or <quote>See also</quote> cross-reference.
434
Templates are applied.
435
<quote>See</quote> or <quote>see also</quote> text
436
is generated by <literal>gentext.element.name</literal>
437
and formatted in italics.
441
<xsl:template match="see|seealso" mode="indexterm">
442
<xsl:text>|textit{</xsl:text>
443
<xsl:call-template name="gentext.element.name"/>
444
<xsl:text>} {</xsl:text>
445
<xsl:apply-templates/>
447
<xsl:apply-templates mode="indexterm"/>
449
<xsl:text>} </xsl:text>
452
<doc:template xmlns="">
453
<refpurpose> Skip <doc:db>indexentry</doc:db>-related elements </refpurpose>
456
Ignores the elements.
464
&DB2LaTeX; only supports indices that are generated by &LaTeX; itself.
468
<xsl:template match="indexentry|primaryie|secondaryie|tertiaryie|seeie|seealsoie"/>