Update of /cvsroot/docbook/xsl/fo
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16471
Modified Files:
autoidx.xsl
Log Message:
Add support for generating an index containing only
those terms with a matching role attribute.
Index: autoidx.xsl
===================================================================
RCS file: /cvsroot/docbook/xsl/fo/autoidx.xsl,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -U2 -r1.26 -r1.27
--- autoidx.xsl 1 Apr 2004 20:26:16 -0000 1.26
+++ autoidx.xsl 18 Apr 2004 19:28:41 -0000 1.27
@@ -10,5 +10,6 @@
<!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"
@@ -62,4 +63,10 @@
<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',
@@ -91,4 +98,5 @@
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>
@@ -101,4 +109,5 @@
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>
@@ -108,4 +117,5 @@
<xsl:template match="indexterm" mode="index-div">
<xsl:param name="scope" select="."/>
+ <xsl:param name="role" select="''"/>
<xsl:variable name="key"
@@ -128,4 +138,5 @@
<xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
</xsl:apply-templates>
</fo:block>
@@ -136,4 +147,5 @@
<xsl:template match="indexterm" mode="index-symbol-div">
<xsl:param name="scope" select="."/>
+ <xsl:param name="role" select="''"/>
<xsl:variable name="key"
@@ -144,4 +156,5 @@
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>
@@ -151,4 +164,5 @@
<xsl:template match="indexterm" mode="index-primary">
<xsl:param name="scope" select="."/>
+ <xsl:param name="role" select="''"/>
<xsl:variable name="key" select="&primary;"/>
@@ -184,4 +198,5 @@
<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>
@@ -205,4 +220,5 @@
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>
@@ -216,4 +232,5 @@
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>
@@ -221,4 +238,5 @@
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>
@@ -229,4 +247,5 @@
<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;)"/>
@@ -273,4 +292,5 @@
<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>
@@ -294,4 +314,5 @@
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>
@@ -305,4 +326,5 @@
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>
@@ -310,4 +332,5 @@
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>
@@ -318,4 +341,5 @@
<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;]"/>
@@ -365,4 +389,5 @@
<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>
@@ -386,4 +411,5 @@
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>
@@ -397,4 +423,5 @@
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>
@@ -405,4 +432,5 @@
<xsl:template match="indexterm" mode="reference">
<xsl:param name="scope" select="."/>
+ <xsl:param name="role" select="''"/>
<xsl:param name="separator" select="', '"/>
@@ -416,4 +444,5 @@
<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>
@@ -431,4 +460,5 @@
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>
@@ -440,4 +470,5 @@
<xsl:template name="reference">
<xsl:param name="scope" select="."/>
+ <xsl:param name="role" select="''"/>
<xsl:param name="zones"/>
@@ -463,4 +494,5 @@
<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>
@@ -484,4 +516,5 @@
<xsl:template match="indexterm" mode="index-see">
<xsl:param name="scope" select="."/>
+ <xsl:param name="role" select="''"/>
<fo:inline>
@@ -498,4 +531,5 @@
<xsl:template match="indexterm" mode="index-seealso">
<xsl:param name="scope" select="."/>
+ <xsl:param name="role" select="''"/>
<fo:block>
@@ -515,4 +549,6 @@
<xsl:param name="scope" select="(ancestor::book|/)[last()]"/>
+ <xsl:variable name="role" select="@role"/>
+
<xsl:variable name="terms" select="$scope//indexterm[count(.|key('letter',
translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;))[&scope;][1]) = 1]"/>
@@ -536,4 +572,5 @@
mode="index-symbol-div-markup">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
<xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
</xsl:apply-templates>
@@ -545,4 +582,5 @@
mode="index-div-markup">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
<xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
</xsl:apply-templates>
@@ -552,4 +590,5 @@
<xsl:template match="*" mode="index-markup">
<xsl:param name="scope" select="."/>
+ <xsl:param name="role" select="''"/>
<xsl:text><</xsl:text>
@@ -558,4 +597,5 @@
<xsl:apply-templates mode="index-markup">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
</xsl:apply-templates>
</xsl:template>
@@ -563,4 +603,5 @@
<xsl:template match="indexterm" mode="index-div-markup">
<xsl:param name="scope" select="."/>
+ <xsl:param name="role" select="''"/>
<xsl:variable name="key" select="translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;)"/>
<xsl:text> <indexdiv> </xsl:text>
@@ -572,4 +613,5 @@
mode="index-primary-markup">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
<xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
</xsl:apply-templates>
@@ -579,4 +621,5 @@
<xsl:template match="indexterm" mode="index-symbol-div-markup">
<xsl:param name="scope" select="."/>
+ <xsl:param name="role" select="''"/>
<xsl:variable name="key" select="translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;)"/>
@@ -584,4 +627,5 @@
mode="index-primary-markup">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
<xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
</xsl:apply-templates>
@@ -590,4 +634,5 @@
<xsl:template match="indexterm" mode="index-primary-markup">
<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;]"/>
@@ -607,4 +652,5 @@
<xsl:apply-templates select="." mode="reference-markup">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
</xsl:apply-templates>
</xsl:for-each>
@@ -616,4 +662,5 @@
mode="index-see-markup">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
<xsl:sort select="translate(see, &lowercase;, &uppercase;)"/>
</xsl:apply-templates>
@@ -622,4 +669,5 @@
mode="index-seealso-markup">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
<xsl:sort select="translate(seealso, &lowercase;, &uppercase;)"/>
</xsl:apply-templates>
@@ -628,4 +676,5 @@
mode="index-secondary-markup">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
<xsl:sort select="translate(&secondary;, &lowercase;, &uppercase;)"/>
</xsl:apply-templates>
@@ -636,4 +685,5 @@
<xsl:template match="indexterm" mode="index-secondary-markup">
<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;]"/>
@@ -652,4 +702,5 @@
<xsl:apply-templates select="." mode="reference-markup">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
</xsl:apply-templates>
</xsl:for-each>
@@ -661,4 +712,5 @@
mode="index-see-markup">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
<xsl:sort select="translate(see, &lowercase;, &uppercase;)"/>
</xsl:apply-templates>
@@ -666,4 +718,5 @@
mode="index-seealso-markup">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
<xsl:sort select="translate(seealso, &lowercase;, &uppercase;)"/>
</xsl:apply-templates>
@@ -671,4 +724,5 @@
mode="index-tertiary-markup">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
<xsl:sort select="translate(&tertiary;, &lowercase;, &uppercase;)"/>
</xsl:apply-templates>
@@ -678,4 +732,5 @@
<xsl:template match="indexterm" mode="index-tertiary-markup">
<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;]"/>
@@ -694,4 +749,5 @@
<xsl:apply-templates select="." mode="reference-markup">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
</xsl:apply-templates>
</xsl:for-each>
@@ -704,4 +760,5 @@
mode="index-see-markup">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
<xsl:sort select="translate(see, &lowercase;, &uppercase;)"/>
</xsl:apply-templates>
@@ -709,4 +766,5 @@
mode="index-seealso-markup">
<xsl:with-param name="scope" select="$scope"/>
+ <xsl:with-param name="role" select="$role"/>
<xsl:sort select="translate(seealso, &lowercase;, &uppercase;)"/>
</xsl:apply-templates>
@@ -716,4 +774,5 @@
<xsl:template match="indexterm" mode="reference-markup">
<xsl:param name="scope" select="."/>
+ <xsl:param name="role" select="''"/>
<xsl:choose>
<xsl:when test="@zone and string(@zone)">
@@ -721,4 +780,5 @@
<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>
@@ -765,4 +825,5 @@
<xsl:template name="reference-markup">
<xsl:param name="scope" select="."/>
+ <xsl:param name="role" select="''"/>
<xsl:param name="zones"/>
<xsl:choose>
@@ -794,4 +855,5 @@
<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>
@@ -825,4 +887,5 @@
<xsl:template match="indexterm" mode="index-see-markup">
<xsl:param name="scope" select="."/>
+ <xsl:param name="role" select="''"/>
<fo:block>
<xsl:text><seeie></xsl:text>
@@ -838,4 +901,5 @@
<xsl:template match="indexterm" mode="index-seealso-markup">
<xsl:param name="scope" select="."/>
+ <xsl:param name="role" select="''"/>
<fo:block>
<xsl:text><seealsoie></xsl:text>
|