use="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, see)"/>
<xsl:template name="generate-index">
+ <xsl:param name="root" select="/"/>
+
<xsl:variable name="scope" select=".." />
<xsl:variable name="terms"
- select="..//indexterm[count(.|key('letter',
+ select="$root//indexterm[count(.|key('letter',
translate(substring(&primary;, 1, 1),
&lowercase;,
&uppercase;))[ancestor::* = $scope][1]) = 1
<!-- ====================================================================== -->
<xsl:template name="generate-index-markup">
+ <xsl:param name="root" select="/"/>
+
<xsl:variable name="scope" select=".."/>
- <xsl:variable name="terms" select="..//indexterm[count(.|key('letter',
+ <xsl:variable name="terms" select="$root//indexterm[count(.|key('letter',
translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;))[ancestor::* = $scope][1]) = 1]"/>
<xsl:variable name="alphabetical"
select="$terms[contains(concat(&lowercase;, &uppercase;),
<xsl:choose>
<xsl:when test="$make.index.markup != 0">
<fo:block>
- <xsl:call-template name="generate-index-markup"/>
+ <xsl:call-template name="generate-index-markup">
+ <xsl:with-param name="root" select="(ancestor::book|/)[last()]"/>
+ </xsl:call-template>
</fo:block>
</xsl:when>
<xsl:otherwise>
<xsl:call-template name="index.titlepage"/>
<xsl:apply-templates/>
<xsl:if test="count(indexentry) = 0 and count(indexdiv) = 0">
- <xsl:call-template name="generate-index"/>
+ <xsl:call-template name="generate-index">
+ <xsl:with-param name="root" select="(ancestor::book|/)[last()]"/>
+ </xsl:call-template>
</xsl:if>
</fo:block>
</xsl:otherwise>
white-space-collapse='false'
xsl:use-attribute-sets="monospace.verbatim.properties"
linefeed-treatment="preserve">
- <xsl:call-template name="generate-index-markup"/>
+ <xsl:call-template name="generate-index-markup">
+ <xsl:with-param name="root" select="(ancestor::book|/)[last()]"/>
+ </xsl:call-template>
</fo:block>
</xsl:when>
<xsl:when test="indexentry|indexdiv/indexentry">
<xsl:apply-templates/>
</xsl:when>
<xsl:otherwise>
- <xsl:call-template name="generate-index"/>
+ <xsl:call-template name="generate-index">
+ <xsl:with-param name="root" select="(ancestor::book|/)[last()]"/>
+ </xsl:call-template>
+ </xsl:otherwise>
+ </xsl:choose>
+ </xsl:if>
+ </fo:flow>
+ </fo:page-sequence>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match="setindex">
+ <xsl:variable name="id">
+ <xsl:call-template name="object.id"/>
+ </xsl:variable>
+
+ <xsl:if test="$generate.index != 0">
+ <xsl:variable name="master-reference">
+ <xsl:call-template name="select.pagemaster">
+ <xsl:with-param name="pageclass">
+ <xsl:if test="$make.index.markup != 0">body</xsl:if>
+ </xsl:with-param>
+ </xsl:call-template>
+ </xsl:variable>
+
+ <fo:page-sequence id="{$id}"
+ hyphenate="{$hyphenate}"
+ master-reference="{$master-reference}">
+ <xsl:attribute name="language">
+ <xsl:call-template name="l10n.language"/>
+ </xsl:attribute>
+ <xsl:attribute name="format">
+ <xsl:call-template name="page.number.format"/>
+ </xsl:attribute>
+ <xsl:if test="$double.sided != 0">
+ <xsl:attribute name="initial-page-number">auto-odd</xsl:attribute>
+ </xsl:if>
+
+ <xsl:apply-templates select="." mode="running.head.mode">
+ <xsl:with-param name="master-reference" select="$master-reference"/>
+ </xsl:apply-templates>
+ <xsl:apply-templates select="." mode="running.foot.mode">
+ <xsl:with-param name="master-reference" select="$master-reference"/>
+ </xsl:apply-templates>
+
+ <fo:flow flow-name="xsl-region-body">
+ <xsl:call-template name="index.titlepage"/>
+ <xsl:apply-templates/>
+ <xsl:if test="count(indexentry) = 0 and count(indexdiv) = 0">
+
+ <xsl:choose>
+ <xsl:when test="$make.index.markup != 0">
+ <fo:block wrap-option='no-wrap'
+ white-space-collapse='false'
+ xsl:use-attribute-sets="monospace.verbatim.properties"
+ linefeed-treatment="preserve">
+ <xsl:call-template name="generate-index-markup">
+ <xsl:with-param name="root" select="/"/>
+ </xsl:call-template>
+ </fo:block>
+ </xsl:when>
+ <xsl:when test="indexentry|indexdiv/indexentry">
+ <xsl:apply-templates/>
+ </xsl:when>
+ <xsl:otherwise>
+ <xsl:call-template name="generate-index">
+ <xsl:with-param name="root" select="/"/>
+ </xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:if>
<xsl:key name="sections" match="*[@id]" use="@id"/>
<xsl:template name="generate-index">
+ <xsl:param name="root" select="/"/>
+
<xsl:variable name="terms"
- select="//indexterm[count(.|key('letter',
+ select="$root//indexterm[count(.|key('letter',
translate(substring(&primary;, 1, 1),
&lowercase;,
&uppercase;))[1]) = 1
<!-- ==================================================================== -->
-<xsl:template match="index|setindex">
+<xsl:template match="index">
<!-- some implementations use completely empty index tags to indicate -->
<!-- where an automatically generated index should be inserted. so -->
<!-- if the index is completely empty, skip it. Unless generate.index -->
<xsl:apply-templates/>
<xsl:if test="count(indexentry) = 0 and count(indexdiv) = 0">
- <xsl:call-template name="generate-index"/>
+ <xsl:call-template name="generate-index">
+ <xsl:with-param name="root" select="(ancestor::book|/)[last()]"/>
+ </xsl:call-template>
+ </xsl:if>
+
+ <xsl:if test="not(parent::article)">
+ <xsl:call-template name="process.footnotes"/>
+ </xsl:if>
+ </div>
+ </xsl:if>
+</xsl:template>
+
+<xsl:template match="setindex">
+ <!-- some implementations use completely empty index tags to indicate -->
+ <!-- where an automatically generated index should be inserted. so -->
+ <!-- if the index is completely empty, skip it. Unless generate.index -->
+ <!-- is non-zero, in which case, this is where the automatically -->
+ <!-- generated index should go. -->
+
+ <xsl:if test="count(*)>0 or $generate.index != '0'">
+ <div class="{name(.)}">
+ <xsl:if test="$generate.id.attributes != 0">
+ <xsl:attribute name="id">
+ <xsl:call-template name="object.id"/>
+ </xsl:attribute>
+ </xsl:if>
+
+ <xsl:call-template name="index.titlepage"/>
+ <xsl:apply-templates/>
+
+ <xsl:if test="count(indexentry) = 0 and count(indexdiv) = 0">
+ <xsl:call-template name="generate-index">
+ <xsl:with-param name="root" select="/"/>
+ </xsl:call-template>
</xsl:if>
<xsl:if test="not(parent::article)">