<!ENTITY section.id 'generate-id(§ion;)'>
<!ENTITY sep '" "'>
-<!ENTITY scope 'count(ancestor::node()|$scope) = count(ancestor::node())'>
+<!ENTITY scope 'count(ancestor::node()|$scope) = count(ancestor::node())
+ and ($role = @role or string-length($role) = 0)'>
]>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0">
<xsl:template name="generate-index">
<xsl:param name="scope" select="(ancestor::book|/)[last()]"/>
+ <xsl:variable name="role">
+ <xsl:if test="$index.on.role != 0">
+ <xsl:value-of select="@role"/>
+ </xsl:if>
+ </xsl:variable>
+
<xsl:variable name="terms"
select="//indexterm[count(.|key('letter',
translate(substring(&primary;, 1, 1),
&primary;)[&scope;][1]) = 1]"
mode="index-symbol-div">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
<xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
</xsl:apply-templates>
</dl>
&lowercase;,&uppercase;))[&scope;][1]) = 1]"
mode="index-div">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
<xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
</xsl:apply-templates>
</div>
<xsl:template match="indexterm" mode="index-div">
<xsl:param name="scope" select="."/>
+ <xsl:param name="role" select="''"/>
<xsl:variable name="key"
select="translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;)"/>
[count(.|key('primary', &primary;)[&scope;][1])=1]"
mode="index-primary">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
<xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
</xsl:apply-templates>
</dl>
<xsl:template match="indexterm" mode="index-symbol-div">
<xsl:param name="scope" select="/"/>
+ <xsl:param name="role" select="''"/>
<xsl:variable name="key" select="translate(substring(&primary;, 1, 1),
&lowercase;,&uppercase;)"/>
[count(.|key('primary', &primary;)[&scope;][1]) = 1]"
mode="index-primary">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
<xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
</xsl:apply-templates>
</xsl:template>
<xsl:template match="indexterm" mode="index-primary">
<xsl:param name="scope" select="."/>
+ <xsl:param name="role" select="''"/>
<xsl:variable name="key" select="&primary;"/>
<xsl:variable name="refs" select="key('primary', $key)[&scope;]"/>
<xsl:for-each select="$refs[generate-id() = generate-id(key('primary-section', concat($key, &sep;, §ion.id;))[&scope;][1])]">
<xsl:apply-templates select="." mode="reference">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
</xsl:apply-templates>
</xsl:for-each>
<xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &sep;, &sep;, see))[&scope;][1])]"
mode="index-see">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
<xsl:sort select="translate(see, &lowercase;, &uppercase;)"/>
</xsl:apply-templates>
</xsl:if>
<xsl:apply-templates select="$refs[generate-id() = generate-id(key('see-also', concat(&primary;, &sep;, &sep;, &sep;, seealso))[&scope;][1])]"
mode="index-seealso">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
<xsl:sort select="translate(seealso, &lowercase;, &uppercase;)"/>
</xsl:apply-templates>
<xsl:apply-templates select="$refs[secondary and count(.|key('secondary', concat($key, &sep;, &secondary;))[&scope;][1]) = 1]"
mode="index-secondary">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
<xsl:sort select="translate(&secondary;, &lowercase;, &uppercase;)"/>
</xsl:apply-templates>
</dl>
<xsl:template match="indexterm" mode="index-secondary">
<xsl:param name="scope" select="."/>
+ <xsl:param name="role" select="''"/>
<xsl:variable name="key" select="concat(&primary;, &sep;, &secondary;)"/>
<xsl:variable name="refs" select="key('secondary', $key)[&scope;]"/>
<xsl:for-each select="$refs[generate-id() = generate-id(key('secondary-section', concat($key, &sep;, §ion.id;))[&scope;][1])]">
<xsl:apply-templates select="." mode="reference">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
</xsl:apply-templates>
</xsl:for-each>
<xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &secondary;, &sep;, &sep;, see))[&scope;][1])]"
mode="index-see">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
<xsl:sort select="translate(see, &lowercase;, &uppercase;)"/>
</xsl:apply-templates>
</xsl:if>
<xsl:apply-templates select="$refs[generate-id() = generate-id(key('see-also', concat(&primary;, &sep;, &secondary;, &sep;, &sep;, seealso))[&scope;][1])]"
mode="index-seealso">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
<xsl:sort select="translate(seealso, &lowercase;, &uppercase;)"/>
</xsl:apply-templates>
<xsl:apply-templates select="$refs[tertiary and count(.|key('tertiary', concat($key, &sep;, &tertiary;))[&scope;][1]) = 1]"
mode="index-tertiary">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
<xsl:sort select="translate(&tertiary;, &lowercase;, &uppercase;)"/>
</xsl:apply-templates>
</dl>
<xsl:template match="indexterm" mode="index-tertiary">
<xsl:param name="scope" select="."/>
+ <xsl:param name="role" select="''"/>
<xsl:variable name="key" select="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;)"/>
<xsl:variable name="refs" select="key('tertiary', $key)[&scope;]"/>
<xsl:for-each select="$refs[generate-id() = generate-id(key('tertiary-section', concat($key, &sep;, §ion.id;))[&scope;][1])]">
<xsl:apply-templates select="." mode="reference">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
</xsl:apply-templates>
</xsl:for-each>
<xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, see))[&scope;][1])]"
mode="index-see">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
<xsl:sort select="translate(see, &lowercase;, &uppercase;)"/>
</xsl:apply-templates>
</xsl:if>
<xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, see))[&scope;][1])]"
mode="index-see">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
<xsl:sort select="translate(see, &lowercase;, &uppercase;)"/>
</xsl:apply-templates>
<xsl:apply-templates select="$refs[generate-id() = generate-id(key('see-also', concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, seealso))[&scope;][1])]"
mode="index-seealso">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
<xsl:sort select="translate(seealso, &lowercase;, &uppercase;)"/>
</xsl:apply-templates>
</dl>
<xsl:template match="indexterm" mode="reference">
<xsl:param name="scope" select="."/>
+ <xsl:param name="role" select="''"/>
<xsl:param name="separator" select="', '"/>
<xsl:value-of select="$separator"/>
<xsl:call-template name="reference">
<xsl:with-param name="zones" select="normalize-space(@zone)"/>
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates select="key('endofrange', @id)[&scope;][last()]"
mode="reference">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
<xsl:with-param name="separator" select="'-'"/>
</xsl:apply-templates>
</xsl:if>
<xsl:template name="reference">
<xsl:param name="scope" select="."/>
+ <xsl:param name="role" select="''"/>
<xsl:param name="zones"/>
<xsl:choose>
<xsl:call-template name="reference">
<xsl:with-param name="zones" select="substring-after($zones, ' ')"/>
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:template match="indexterm" mode="index-see">
<xsl:param name="scope" select="."/>
+ <xsl:param name="role" select="''"/>
<xsl:text> (</xsl:text>
<xsl:call-template name="gentext">
<xsl:template match="indexterm" mode="index-seealso">
<xsl:param name="scope" select="."/>
+ <xsl:param name="role" select="''"/>
<dt>
<xsl:text>(</xsl:text>