2 <!DOCTYPE xsl:stylesheet [
3 <!ENTITY primary 'normalize-space(concat(primary/@sortas, primary[not(@sortas)]))'>
4 <!ENTITY secondary 'normalize-space(concat(secondary/@sortas, secondary[not(@sortas)]))'>
5 <!ENTITY tertiary 'normalize-space(concat(tertiary/@sortas, tertiary[not(@sortas)]))'>
7 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
8 xmlns:fo="http://www.w3.org/1999/XSL/Format"
9 xmlns:rx="http://www.renderx.com/XSL/Extensions"
12 <!-- ********************************************************************
13 $Id: index.xsl 8317 2009-03-12 06:14:02Z bobstayton $
14 ********************************************************************
16 This file is part of the XSL DocBook Stylesheet distribution.
17 See ../README or http://docbook.sf.net/release/xsl/current/ for
18 copyright and other information.
20 ******************************************************************** -->
22 <!-- ==================================================================== -->
24 <xsl:template match="index">
25 <xsl:variable name="id">
26 <xsl:call-template name="object.id"/>
29 <xsl:if test="$generate.index != 0">
31 <xsl:when test="$make.index.markup != 0">
33 <xsl:call-template name="generate-index-markup">
34 <xsl:with-param name="scope" select="(ancestor::book|/)[last()]"/>
40 <xsl:call-template name="index.titlepage"/>
42 <xsl:apply-templates/>
43 <xsl:if test="count(indexentry) = 0 and count(indexdiv) = 0">
44 <xsl:call-template name="generate-index">
45 <xsl:with-param name="scope" select="(ancestor::book|/)[last()]"/>
53 <xsl:template match="book/index|part/index">
54 <xsl:variable name="id">
55 <xsl:call-template name="object.id"/>
58 <xsl:if test="$generate.index != 0">
59 <xsl:variable name="master-reference">
60 <xsl:call-template name="select.pagemaster">
61 <xsl:with-param name="pageclass">
62 <xsl:if test="$make.index.markup != 0">body</xsl:if>
67 <fo:page-sequence hyphenate="{$hyphenate}"
68 master-reference="{$master-reference}">
69 <xsl:attribute name="language">
70 <xsl:call-template name="l10n.language"/>
72 <xsl:attribute name="format">
73 <xsl:call-template name="page.number.format">
74 <xsl:with-param name="master-reference" select="$master-reference"/>
78 <xsl:attribute name="initial-page-number">
79 <xsl:call-template name="initial.page.number">
80 <xsl:with-param name="master-reference" select="$master-reference"/>
84 <xsl:attribute name="force-page-count">
85 <xsl:call-template name="force.page.count">
86 <xsl:with-param name="master-reference" select="$master-reference"/>
90 <xsl:attribute name="hyphenation-character">
91 <xsl:call-template name="gentext">
92 <xsl:with-param name="key" select="'hyphenation-character'"/>
95 <xsl:attribute name="hyphenation-push-character-count">
96 <xsl:call-template name="gentext">
97 <xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
100 <xsl:attribute name="hyphenation-remain-character-count">
101 <xsl:call-template name="gentext">
102 <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
106 <xsl:apply-templates select="." mode="running.head.mode">
107 <xsl:with-param name="master-reference" select="$master-reference"/>
108 </xsl:apply-templates>
109 <xsl:apply-templates select="." mode="running.foot.mode">
110 <xsl:with-param name="master-reference" select="$master-reference"/>
111 </xsl:apply-templates>
113 <fo:flow flow-name="xsl-region-body">
114 <xsl:call-template name="set.flow.properties">
115 <xsl:with-param name="element" select="local-name(.)"/>
116 <xsl:with-param name="master-reference" select="$master-reference"/>
120 xsl:use-attribute-sets="component.titlepage.properties">
121 <xsl:call-template name="index.titlepage"/>
123 <xsl:apply-templates/>
124 <xsl:if test="count(indexentry) = 0 and count(indexdiv) = 0">
127 <xsl:when test="$make.index.markup != 0">
128 <fo:block wrap-option='no-wrap'
129 white-space-collapse='false'
130 xsl:use-attribute-sets="monospace.verbatim.properties"
131 linefeed-treatment="preserve">
132 <xsl:call-template name="generate-index-markup">
133 <xsl:with-param name="scope" select="(ancestor::book|/)[last()]"/>
137 <xsl:when test="indexentry|indexdiv/indexentry">
138 <xsl:apply-templates/>
141 <xsl:call-template name="generate-index">
142 <xsl:with-param name="scope" select="(ancestor::book|/)[last()]"/>
152 <xsl:template match="setindex">
153 <xsl:variable name="id">
154 <xsl:call-template name="object.id"/>
157 <xsl:if test="$generate.index != 0">
158 <xsl:variable name="master-reference">
159 <xsl:call-template name="select.pagemaster">
160 <xsl:with-param name="pageclass">
162 <xsl:when test="$make.index.markup != 0">body</xsl:when>
163 <xsl:otherwise>index</xsl:otherwise>
169 <fo:page-sequence hyphenate="{$hyphenate}"
170 master-reference="{$master-reference}">
171 <xsl:attribute name="language">
172 <xsl:call-template name="l10n.language"/>
174 <xsl:attribute name="format">
175 <xsl:call-template name="page.number.format">
176 <xsl:with-param name="master-reference" select="$master-reference"/>
180 <xsl:attribute name="initial-page-number">
181 <xsl:call-template name="initial.page.number">
182 <xsl:with-param name="master-reference" select="$master-reference"/>
186 <xsl:attribute name="force-page-count">
187 <xsl:call-template name="force.page.count">
188 <xsl:with-param name="master-reference" select="$master-reference"/>
192 <xsl:attribute name="hyphenation-character">
193 <xsl:call-template name="gentext">
194 <xsl:with-param name="key" select="'hyphenation-character'"/>
197 <xsl:attribute name="hyphenation-push-character-count">
198 <xsl:call-template name="gentext">
199 <xsl:with-param name="key" select="'hyphenation-push-character-count'"/>
202 <xsl:attribute name="hyphenation-remain-character-count">
203 <xsl:call-template name="gentext">
204 <xsl:with-param name="key" select="'hyphenation-remain-character-count'"/>
208 <xsl:apply-templates select="." mode="running.head.mode">
209 <xsl:with-param name="master-reference" select="$master-reference"/>
210 </xsl:apply-templates>
211 <xsl:apply-templates select="." mode="running.foot.mode">
212 <xsl:with-param name="master-reference" select="$master-reference"/>
213 </xsl:apply-templates>
215 <fo:flow flow-name="xsl-region-body">
216 <xsl:call-template name="set.flow.properties">
217 <xsl:with-param name="element" select="local-name(.)"/>
218 <xsl:with-param name="master-reference" select="$master-reference"/>
221 <fo:block id="{$id}">
222 <xsl:call-template name="setindex.titlepage"/>
224 <xsl:apply-templates/>
225 <xsl:if test="count(indexentry) = 0 and count(indexdiv) = 0">
228 <xsl:when test="$make.index.markup != 0">
229 <fo:block wrap-option='no-wrap'
230 white-space-collapse='false'
231 xsl:use-attribute-sets="monospace.verbatim.properties"
232 linefeed-treatment="preserve">
233 <xsl:call-template name="generate-index-markup">
234 <xsl:with-param name="scope" select="/"/>
238 <xsl:when test="indexentry|indexdiv/indexentry">
239 <xsl:apply-templates/>
242 <xsl:call-template name="generate-index">
243 <xsl:with-param name="scope" select="/"/>
253 <xsl:template match="index/indexinfo"></xsl:template>
254 <xsl:template match="index/info"></xsl:template>
255 <xsl:template match="index/title"></xsl:template>
256 <xsl:template match="index/subtitle"></xsl:template>
257 <xsl:template match="index/titleabbrev"></xsl:template>
259 <!-- ==================================================================== -->
261 <xsl:template name="indexdiv.title">
262 <xsl:param name="title"/>
263 <xsl:param name="titlecontent"/>
265 <fo:block xsl:use-attribute-sets="index.div.title.properties">
267 <xsl:when test="$title">
268 <xsl:apply-templates select="." mode="object.title.markup">
269 <xsl:with-param name="allow-anchors" select="1"/>
270 </xsl:apply-templates>
273 <xsl:copy-of select="$titlecontent"/>
279 <xsl:template match="indexdiv">
281 <xsl:call-template name="indexdiv.titlepage"/>
282 <xsl:apply-templates/>
286 <xsl:template match="indexdiv/title"/>
287 <xsl:template match="indexdiv/subtitle"/>
288 <xsl:template match="indexdiv/titleabbrev"/>
290 <!-- ==================================================================== -->
292 <!-- Text used for distiguishing between normal and significant entries -->
293 <xsl:variable name="significant.flag">.tnacifingis</xsl:variable>
295 <xsl:template match="indexterm" name="indexterm">
296 <!-- Temporal workaround for bug in AXF -->
297 <xsl:variable name="wrapper.name">
299 <xsl:when test="$axf.extensions != 0 or $fop1.extensions != 0">
300 <xsl:call-template name="inline.or.block"/>
302 <xsl:otherwise>fo:wrapper</xsl:otherwise>
306 <xsl:element name="{$wrapper.name}">
307 <xsl:attribute name="id">
308 <xsl:call-template name="object.id"/>
311 <xsl:when test="$xep.extensions != 0">
312 <xsl:attribute name="rx:key">
313 <xsl:value-of select="&primary;"/>
314 <xsl:if test="@significance='preferred'"><xsl:value-of select="$significant.flag"/></xsl:if>
315 <xsl:if test="secondary">
316 <xsl:text>, </xsl:text>
317 <xsl:value-of select="&secondary;"/>
319 <xsl:if test="tertiary">
320 <xsl:text>, </xsl:text>
321 <xsl:value-of select="&tertiary;"/>
327 <xsl:call-template name="comment-escape-string">
328 <xsl:with-param name="string">
329 <xsl:value-of select="primary"/>
330 <xsl:if test="secondary">
331 <xsl:text>, </xsl:text>
332 <xsl:value-of select="secondary"/>
334 <xsl:if test="tertiary">
335 <xsl:text>, </xsl:text>
336 <xsl:value-of select="tertiary"/>
346 <xsl:template match="indexterm[@class='startofrange']">
348 <xsl:when test="$xep.extensions != 0">
349 <rx:begin-index-range>
350 <xsl:call-template name="anchor"/>
351 <xsl:attribute name="rx:key">
352 <xsl:value-of select="&primary;"/>
353 <xsl:if test="@significance='preferred'"><xsl:value-of select="$significant.flag"/></xsl:if>
354 <xsl:if test="secondary">
355 <xsl:text>, </xsl:text>
356 <xsl:value-of select="&secondary;"/>
358 <xsl:if test="tertiary">
359 <xsl:text>, </xsl:text>
360 <xsl:value-of select="&tertiary;"/>
363 </rx:begin-index-range>
366 <xsl:call-template name="indexterm"/>
371 <xsl:template match="indexterm[@class='endofrange']">
373 <xsl:when test="$xep.extensions != 0">
375 <xsl:attribute name="ref-id">
376 <xsl:value-of select="@startref"/>
378 </rx:end-index-range>
381 <xsl:call-template name="indexterm"/>
386 <!-- ==================================================================== -->
388 <xsl:template match="indexentry">
390 <!-- don't process 'seeie's from here -->
391 <xsl:apply-templates select="primaryie|secondaryie|tertiaryie|seealsoie"/>
395 <xsl:template match="primaryie">
397 <xsl:apply-templates/>
398 <xsl:if test="following-sibling::seeie">
399 <xsl:text> (</xsl:text>
400 <xsl:call-template name="gentext">
401 <xsl:with-param name="key" select="'see'"/>
403 <xsl:text> </xsl:text>
404 <xsl:apply-templates select="following-sibling::seeie"/>
405 <xsl:text>)</xsl:text>
410 <xsl:template match="secondaryie">
411 <fo:block start-indent="1pc">
412 <xsl:apply-templates/>
413 <xsl:if test="following-sibling::seeie">
414 <xsl:text> (</xsl:text>
415 <xsl:call-template name="gentext">
416 <xsl:with-param name="key" select="'see'"/>
418 <xsl:text> </xsl:text>
419 <xsl:apply-templates select="following-sibling::seeie"/>
420 <xsl:text>)</xsl:text>
425 <xsl:template match="tertiaryie">
426 <fo:block start-indent="2pc">
427 <xsl:apply-templates/>
428 <xsl:if test="following-sibling::seeie">
429 <xsl:text> (</xsl:text>
430 <xsl:call-template name="gentext">
431 <xsl:with-param name="key" select="'see'"/>
433 <xsl:text> </xsl:text>
434 <xsl:apply-templates select="following-sibling::seeie"/>
435 <xsl:text>)</xsl:text>
440 <xsl:template match="seeie">
442 <xsl:apply-templates/>
446 <xsl:template match="seealsoie">
448 <xsl:attribute name="start-indent">
450 <xsl:when test="(preceding-sibling::tertiaryie |
451 preceding-sibling::secondaryie)[last()]
452 [self::tertiaryie]">3pc</xsl:when>
453 <xsl:when test="(preceding-sibling::tertiaryie |
454 preceding-sibling::secondaryie)[last()]
455 [self::secondaryie]">2pc</xsl:when>
456 <xsl:otherwise>1pc</xsl:otherwise>
459 <xsl:text>(</xsl:text>
460 <xsl:call-template name="gentext">
461 <xsl:with-param name="key" select="'seealso'"/>
463 <xsl:text> </xsl:text>
464 <xsl:apply-templates/>
465 <xsl:text>)</xsl:text>
469 <!-- Determines if an object should be inserted as an fo:inline
470 or an fo:block. Used for indexterms -->
471 <xsl:template name="inline.or.block">
472 <xsl:param name="parentnode" select=".."/>
474 <xsl:variable name="parent" select="concat('|', local-name($parentnode), '|')"/>
476 <xsl:variable name="block.parents" select="'|answer|appendix|appendixinfo|article|articleinfo|bibliodiv|bibliography|bibliographyinfo|blockinfo|blockquote|bookinfo|callout|caution|chapter|chapterinfo|dedication|example|figure|formalpara|funcsynopsisinfo|glossary|glossaryinfo|glossdef|glossdiv|glossentry|highlights|important|index|indexinfo|info|informalexample|informalfigure|informaltable|itemizedlist|legalnotice|listitem|msgexplan|msgtext|note|objectinfo|orderedlist|partinfo|partintro|preface|prefaceinfo|procedure|qandadiv|qandaset|question|refentry|refentryinfo|referenceinfo|refmeta|refmiscinfo|refsect1|refsect1info|refsect2|refsect2info|refsect3|refsect3info|refsection|refsectioninfo|refsynopsisdiv|refsynopsisdivinfo|revdescription|screeninfo|sect1|sect1info|sect2|sect2info|sect3|sect3info|sect4|sect4info|sect5|sect5info|section|sectioninfo|setindex|setindexinfo|setinfo|sidebar|sidebarinfo|simplesect|step|table|task|taskprerequisites|taskrelated|tasksummary|tip|variablelist|warning|'"/>
479 <xsl:when test="contains($block.parents, $parent)">fo:block</xsl:when>
480 <xsl:when test="$fop1.extensions != 0">fo:wrapper</xsl:when>
481 <xsl:otherwise>fo:inline</xsl:otherwise>