]> granicus.if.org Git - docbook-dsssl/commitdiff
Removed the unnecessary generate-index-from-terms template
authorBob Stayton <bobs@sagehill.net>
Mon, 6 Jan 2003 09:00:55 +0000 (09:00 +0000)
committerBob Stayton <bobs@sagehill.net>
Mon, 6 Jan 2003 09:00:55 +0000 (09:00 +0000)
in favor of generate-index, called with scope parameter.

xsl/fo/autoidx.xsl
xsl/fo/index.xsl

index 101d59e745e6e3d1637a0cad2f82a796def45e85..6373716ea9683e4f19e3e5457a46468acc89d70f 100644 (file)
@@ -9,6 +9,7 @@
 <!ENTITY tertiary  'normalize-space(concat(tertiary/@sortas, tertiary[not(@sortas)]))'>
 
 <!ENTITY sep '" "'>
+<!ENTITY scope 'count(ancestor::node()|$scope) = count(ancestor::node())'>
 ]>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 xmlns:fo="http://www.w3.org/1999/XSL/Format"
          match="indexterm[see]"
          use="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, see)"/>
 
-<!-- The obvious way to implement generate-index, generate-setindex, and
-     generate-index-from-terms would be to pass the root node for term
-     selection as a parameter. But if you do that, Saxon says:
-
-     java.lang.UnsupportedOperationException: Cannot create intensional
-       node-set with context dependencies: class com.icl.saxon.expr.PathExpression:128
-       at com.icl.saxon.expr.NodeSetIntent.<init>(NodeSetIntent.java:26)
-       ...
-
-     I can't decide if that's a Saxon bug or an XSLT limitation. But I want
-     to avoid it in either event. -->
-
 <xsl:template name="generate-index">
-  <xsl:param name="root" select="/"/>
+  <xsl:param name="scope" select="(ancestor::book|/)[last()]"/>
 
-  <xsl:variable name="scope" select="(ancestor::book|/)[last()]"/>
-  <xsl:variable name="terms"
-                select="(ancestor::book|/)[last()]//indexterm[count(.|key('letter',
-                                                translate(substring(&primary;, 1, 1),
-                                                          &lowercase;,
-                                                          &uppercase;))[ancestor::* = $scope][1]) = 1
-                                    and not(@class = 'endofrange')]"/>
-
-  <xsl:call-template name="generate-index-from-terms">
-    <xsl:with-param name="terms" select="$terms"/>
-    <xsl:with-param name="scope" select="$scope"/>
-  </xsl:call-template>
-</xsl:template>
-
-<xsl:template name="generate-setindex">
-  <xsl:variable name="scope" select="/"/>
   <xsl:variable name="terms"
                 select="//indexterm[count(.|key('letter',
                                                 translate(substring(&primary;, 1, 1),
                                                           &lowercase;,
-                                                          &uppercase;))[ancestor::* = $scope][1]) = 1
+                                                          &uppercase;))[&scope;][1]) = 1
                                     and not(@class = 'endofrange')]"/>
 
-  <xsl:call-template name="generate-index-from-terms">
-    <xsl:with-param name="terms" select="$terms"/>
-    <xsl:with-param name="scope" select="$scope"/>
-  </xsl:call-template>
-</xsl:template>
-
-<xsl:template name="generate-index-from-terms">
-  <xsl:param name="terms"/>
-  <xsl:param name="scope"/>
-
   <xsl:variable name="alphabetical"
                 select="$terms[contains(concat(&lowercase;, &uppercase;),
                                         substring(&primary;, 1, 1))]"/>
-
   <xsl:variable name="others" select="$terms[not(contains(concat(&lowercase;,
                                                  &uppercase;),
                                              substring(&primary;, 1, 1)))]"/>
       </fo:block>
       <fo:block>
         <xsl:apply-templates select="$others[count(.|key('primary',
-                                     &primary;)[ancestor::* = $scope][1]) = 1]"
+                                     &primary;)[&scope;][1]) = 1]"
                              mode="index-symbol-div">
           <xsl:with-param name="scope" select="$scope"/>
           <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
       </fo:block>
     </xsl:if>
     <xsl:apply-templates select="$alphabetical[count(.|key('letter',
-                                 translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;))[ancestor::* = $scope][1]) = 1]"
+                                 translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;))[&scope;][1]) = 1]"
                          mode="index-div">
       <xsl:with-param name="scope" select="$scope"/>
       <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
   <xsl:param name="scope" select="."/>
 
   <xsl:variable name="key" select="translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;)"/>
-  <xsl:variable name="terms" select="key('letter', $key)[ancestor::* = $scope][count(.|key('primary', &primary;)[1]) = 1]"/>
   <fo:block>
     <xsl:if test="contains(concat(&lowercase;, &uppercase;), $key)">
       <fo:block font-size="16pt"
       </fo:block>
     </xsl:if>
     <fo:block>
-      <xsl:apply-templates select="$terms"
+      <xsl:apply-templates select="key('letter', $key)[&scope;][count(.|key('primary', &primary;)[&scope;][1]) = 1]"
                            mode="index-primary">
-        <xsl:with-param name="scope" select="$scope"/>
         <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
+        <xsl:with-param name="scope" select="$scope"/>
       </xsl:apply-templates>
     </fo:block>
   </fo:block>
 
 <xsl:template match="indexterm" mode="index-symbol-div">
   <xsl:param name="scope" select="."/>
+
   <xsl:variable name="key" select="translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;)"/>
 
   <fo:block>
-    <xsl:apply-templates select="key('letter', $key)[count(.|key('primary', &primary;)[ancestor::* = $scope][1]) = 1]"
+    <xsl:apply-templates select="key('letter', $key)[&scope;][count(.|key('primary', &primary;)[&scope;][1]) = 1]"
                          mode="index-primary">
       <xsl:with-param name="scope" select="$scope"/>
       <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
 
 <xsl:template match="indexterm" mode="index-primary">
   <xsl:param name="scope" select="."/>
+
   <xsl:variable name="key" select="&primary;"/>
-  <xsl:variable name="refs" select="key('primary', $key)[ancestor::* = $scope]"/>
+  <xsl:variable name="refs" select="key('primary', $key)[&scope;]"/>
   <fo:block>
     <xsl:value-of select="primary"/>
 
       </xsl:for-each>
 
       <xsl:if test="$refs[not(secondary)]/*[self::see]">
-        <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &sep;, &sep;, see))[ancestor::* = $scope][1])]"
+        <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:sort select="translate(see, &lowercase;, &uppercase;)"/>
 
   <xsl:if test="$refs/secondary or $refs[not(secondary)]/*[self::seealso]">
     <fo:block start-indent="1pc">
-      <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see-also', concat(&primary;, &sep;, &sep;, &sep;, seealso))[ancestor::* = $scope][1])]"
+      <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:sort select="translate(seealso, &lowercase;, &uppercase;)"/>
       </xsl:apply-templates>
-      <xsl:apply-templates select="$refs[secondary and count(.|key('secondary', concat($key, &sep;, &secondary;))[ancestor::* = $scope][1]) = 1]"
+      <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:sort select="translate(&secondary;, &lowercase;, &uppercase;)"/>
 
 <xsl:template match="indexterm" mode="index-secondary">
   <xsl:param name="scope" select="."/>
+
   <xsl:variable name="key" select="concat(&primary;, &sep;, &secondary;)"/>
-  <xsl:variable name="refs" select="key('secondary', $key)[ancestor::* = $scope]"/>
+  <xsl:variable name="refs" select="key('secondary', $key)[&scope;]"/>
   <fo:block>
     <xsl:value-of select="secondary"/>
 
       </xsl:for-each>
 
       <xsl:if test="$refs[not(tertiary)]/*[self::see]">
-        <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &secondary;, &sep;, &sep;, see))[ancestor::* = $scope][1])]"
+        <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:sort select="translate(see, &lowercase;, &uppercase;)"/>
 
   <xsl:if test="$refs/tertiary or $refs[not(tertiary)]/*[self::seealso]">
     <fo:block start-indent="2pc">
-      <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see-also', concat(&primary;, &sep;, &secondary;, &sep;, &sep;, seealso))[ancestor::* = $scope][1])]"
+      <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:sort select="translate(seealso, &lowercase;, &uppercase;)"/>
       </xsl:apply-templates>
-      <xsl:apply-templates select="$refs[tertiary and count(.|key('tertiary', concat($key, &sep;, &tertiary;))[ancestor::* = $scope][1]) = 1]" 
+      <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:sort select="translate(&tertiary;, &lowercase;, &uppercase;)"/>
 <xsl:template match="indexterm" mode="index-tertiary">
   <xsl:param name="scope" select="."/>
   <xsl:variable name="key" select="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;)"/>
-  <xsl:variable name="refs" select="key('tertiary', $key)[ancestor::* = $scope]"/>
+  <xsl:variable name="refs" select="key('tertiary', $key)[&scope;]"/>
   <fo:block>
     <xsl:value-of select="tertiary"/>
 
       </xsl:for-each>
 
       <xsl:if test="$refs/see">
-        <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, see))[ancestor::* = $scope][1])]"
+        <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:sort select="translate(see, &lowercase;, &uppercase;)"/>
 
   <xsl:if test="$refs/seealso">
     <fo:block>
-      <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see-also', concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, seealso))[ancestor::* = $scope][1])]"
+      <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:sort select="translate(seealso, &lowercase;, &uppercase;)"/>
         <fo:page-number-citation ref-id="{$id}"/>
       </fo:basic-link>
 
-      <xsl:if test="key('endofrange', @id)">
-        <xsl:apply-templates select="key('endofrange', @id)[ancestor::* = $scope][last()]"
+      <xsl:if test="key('endofrange', @id)[&scope;]">
+        <xsl:apply-templates select="key('endofrange', @id)[&scope;][last()]"
                              mode="reference">
           <xsl:with-param name="scope" select="$scope"/>
           <xsl:with-param name="separator" select="'-'"/>
 <xsl:template name="reference">
   <xsl:param name="scope" select="."/>
   <xsl:param name="zones"/>
+
   <xsl:choose>
     <xsl:when test="contains($zones, ' ')">
       <xsl:variable name="zone" select="substring-before($zones, ' ')"/>
-      <xsl:variable name="target" select="key('id', $zone)[ancestor::* = $scope]"/>
+      <xsl:variable name="target" select="key('id', $zone)[&scope;]"/>
 
       <xsl:variable name="id">
         <xsl:call-template name="object.id">
     </xsl:when>
     <xsl:otherwise>
       <xsl:variable name="zone" select="$zones"/>
-      <xsl:variable name="target" select="key('id', $zone)[ancestor::* = $scope]"/>
+      <xsl:variable name="target" select="key('id', $zone)[&scope;]"/>
 
       <xsl:variable name="id">
         <xsl:call-template name="object.id">
 
 <xsl:template match="indexterm" mode="index-see">
    <xsl:param name="scope" select="."/>
+
    <fo:inline>
      <xsl:text> (</xsl:text>
      <xsl:call-template name="gentext">
 
 <xsl:template match="indexterm" mode="index-seealso">
    <xsl:param name="scope" select="."/>
+
    <fo:block>
      <xsl:text>(</xsl:text>
      <xsl:call-template name="gentext">
 <!-- ====================================================================== -->
 
 <xsl:template name="generate-index-markup">
-  <xsl:variable name="scope" select="(ancestor::book|/)[last()]"/>
-  <xsl:variable name="terms" select="$scope//indexterm[count(.|key('letter',
-                                     translate(substring(&primary;, 1, 1),&lowercase;,
-                                     &uppercase;))[ancestor::* = $scope][1]) = 1]"/>
+  <xsl:param name="scope" select="(ancestor::book|/)[last()]"/>
 
-  <xsl:call-template name="generate-index-markup-from-terms">
-    <xsl:with-param name="terms" select="$terms"/>
-    <xsl:with-param name="scope" select="$scope"/>
-  </xsl:call-template>
-</xsl:template>
-
-<xsl:template name="generate-setindex-markup">
-  <xsl:variable name="scope" select="/"/>
   <xsl:variable name="terms" select="$scope//indexterm[count(.|key('letter',
-                                     translate(substring(&primary;, 1, 1),&lowercase;,
-                                     &uppercase;))[ancestor::* = $scope][1]) = 1]"/>
-
-  <xsl:call-template name="generate-index-markup-from-terms">
-    <xsl:with-param name="terms" select="$terms"/>
-    <xsl:with-param name="scope" select="$scope"/>
-  </xsl:call-template>
-</xsl:template>
-
-<xsl:template name="generate-index-markup-from-terms">
-  <xsl:param name="terms"/>
-  <xsl:param name="scope"/>
-
+                                     translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;))[&scope;][1]) = 1]"/>
   <xsl:variable name="alphabetical"
                 select="$terms[contains(concat(&lowercase;, &uppercase;),
                                         substring(&primary;, 1, 1))]"/>
-
   <xsl:variable name="others" select="$terms[not(contains(concat(&lowercase;,
                                                  &uppercase;),
                                              substring(&primary;, 1, 1)))]"/>
     </xsl:call-template>
     <xsl:text>&lt;/title&gt;&#10;</xsl:text>
     <xsl:apply-templates select="$others[count(.|key('primary',
-                                 &primary;)[ancestor::* = $scope][1]) = 1]"
+                                 &primary;)[&scope;][1]) = 1]"
                          mode="index-symbol-div-markup">
       <xsl:with-param name="scope" select="$scope"/>
       <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
   </xsl:if>
 
   <xsl:apply-templates select="$alphabetical[count(.|key('letter',
-                               translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;))[ancestor::* = $scope][1]) = 1]"
+                               translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;))[&scope;][1]) = 1]"
                        mode="index-div-markup">
       <xsl:with-param name="scope" select="$scope"/>
       <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
   <xsl:value-of select="translate($key, &lowercase;, &uppercase;)"/>
   <xsl:text>&lt;/title&gt;&#10;</xsl:text>
 
-  <xsl:apply-templates select="key('letter', $key)[count(.|key('primary', &primary;)[ancestor::* = $scope][1]) = 1]"
+  <xsl:apply-templates select="key('letter', $key)[&scope;][count(.|key('primary', &primary;)[&scope;][1]) = 1]"
                        mode="index-primary-markup">
     <xsl:with-param name="scope" select="$scope"/>
     <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
   <xsl:param name="scope" select="."/>
   <xsl:variable name="key" select="translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;)"/>
 
-  <xsl:apply-templates select="key('letter', $key)[count(.|key('primary', &primary;)[ancestor::* = $scope][1]) = 1]"
+  <xsl:apply-templates select="key('letter', $key)[&scope;][count(.|key('primary', &primary;)[&scope;][1]) = 1]"
                        mode="index-primary-markup">
     <xsl:with-param name="scope" select="$scope"/>
     <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
 <xsl:template match="indexterm" mode="index-primary-markup">
   <xsl:param name="scope" select="."/>
   <xsl:variable name="key" select="&primary;"/>
-  <xsl:variable name="refs" select="key('primary', $key)[ancestor::* = $scope]"/>
+  <xsl:variable name="refs" select="key('primary', $key)[&scope;]"/>
   <xsl:variable name="pages" select="$refs[not(see) and not(seealso)]"/>
 
   <xsl:text>&#10;&lt;indexentry&gt;&#10;</xsl:text>
   <xsl:text>&lt;/primaryie&gt;&#10;</xsl:text>
 
   <xsl:if test="$refs/secondary or $refs[not(secondary)]/*[self::see or self::seealso]">
-    <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &sep;, &sep;, see))[ancestor::* = $scope][1])]"
+    <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &sep;, &sep;, see))[&scope;][1])]"
                          mode="index-see-markup">
       <xsl:with-param name="scope" select="$scope"/>
       <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;, &sep;, &sep;, seealso))[ancestor::* = $scope][1])]"
+    <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see-also', concat(&primary;, &sep;, &sep;, &sep;, seealso))[&scope;][1])]"
                          mode="index-seealso-markup">
       <xsl:with-param name="scope" select="$scope"/>
       <xsl:sort select="translate(seealso, &lowercase;, &uppercase;)"/>
     </xsl:apply-templates>
 
-    <xsl:apply-templates select="$refs[secondary and count(.|key('secondary', concat($key, &sep;, &secondary;))[ancestor::* = $scope][1]) = 1]" 
+    <xsl:apply-templates select="$refs[secondary and count(.|key('secondary', concat($key, &sep;, &secondary;))[&scope;][1]) = 1]" 
                          mode="index-secondary-markup">
       <xsl:with-param name="scope" select="$scope"/>
       <xsl:sort select="translate(&secondary;, &lowercase;, &uppercase;)"/>
 <xsl:template match="indexterm" mode="index-secondary-markup">
   <xsl:param name="scope" select="."/>
   <xsl:variable name="key" select="concat(&primary;, &sep;, &secondary;)"/>
-  <xsl:variable name="refs" select="key('secondary', $key)[ancestor::* = $scope]"/>
+  <xsl:variable name="refs" select="key('secondary', $key)[&scope;]"/>
   <xsl:variable name="pages" select="$refs[not(see) and not(seealso)]"/>
 
   <xsl:text>&lt;secondaryie&gt;</xsl:text>
   <xsl:text>&lt;/secondaryie&gt;&#10;</xsl:text>
 
   <xsl:if test="$refs/tertiary or $refs[not(tertiary)]/*[self::see or self::seealso]">
-    <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &secondary;, &sep;, &sep;, see))[ancestor::* = $scope][1])]"
+    <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &secondary;, &sep;, &sep;, see))[&scope;][1])]"
                          mode="index-see-markup">
       <xsl:with-param name="scope" select="$scope"/>
       <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;, &sep;, seealso))[ancestor::* = $scope][1])]"
+    <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see-also', concat(&primary;, &sep;, &secondary;, &sep;, &sep;, seealso))[&scope;][1])]"
                          mode="index-seealso-markup">
       <xsl:with-param name="scope" select="$scope"/>
       <xsl:sort select="translate(seealso, &lowercase;, &uppercase;)"/>
     </xsl:apply-templates>
-    <xsl:apply-templates select="$refs[tertiary and count(.|key('tertiary', concat($key, &sep;, &tertiary;))[ancestor::* = $scope][1]) = 1]" 
+    <xsl:apply-templates select="$refs[tertiary and count(.|key('tertiary', concat($key, &sep;, &tertiary;))[&scope;][1]) = 1]" 
                          mode="index-tertiary-markup">
       <xsl:with-param name="scope" select="$scope"/>
       <xsl:sort select="translate(&tertiary;, &lowercase;, &uppercase;)"/>
 <xsl:template match="indexterm" mode="index-tertiary-markup">
   <xsl:param name="scope" select="."/>
   <xsl:variable name="key" select="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;)"/>
-  <xsl:variable name="refs" select="key('tertiary', $key)[ancestor::* = $scope]"/>
+  <xsl:variable name="refs" select="key('tertiary', $key)[&scope;]"/>
   <xsl:variable name="pages" select="$refs[not(see) and not(seealso)]"/>
 
   <xsl:text>&lt;tertiaryie&gt;</xsl:text>
 
   <xsl:variable name="see" select="$refs/see | $refs/seealso"/>
   <xsl:if test="$see">
-    <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, see))[ancestor::* = $scope][1])]"
+    <xsl:apply-templates select="$refs[generate-id() = generate-id(key('see', concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, see))[&scope;][1])]"
                          mode="index-see-markup">
       <xsl:with-param name="scope" select="$scope"/>
       <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))[ancestor::* = $scope][1])]"
+    <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-markup">
       <xsl:with-param name="scope" select="$scope"/>
       <xsl:sort select="translate(seealso, &lowercase;, &uppercase;)"/>
   <xsl:choose>
     <xsl:when test="contains($zones, ' ')">
       <xsl:variable name="zone" select="substring-before($zones, ' ')"/>
-      <xsl:variable name="target" select="key('id', $zone)[ancestor::* = $scope]"/>
+      <xsl:variable name="target" select="key('id', $zone)[&scope;]"/>
 
       <xsl:variable name="id">
         <xsl:call-template name="object.id">
     </xsl:when>
     <xsl:otherwise>
       <xsl:variable name="zone" select="$zones"/>
-      <xsl:variable name="target" select="key('id', $zone)"/>
+      <xsl:variable name="target" select="key('id', $zone)[&scope;]"/>
 
       <xsl:variable name="id">
         <xsl:call-template name="object.id">
index 531b66d9792a5964764efc99d65ffb50c81f8505..51b558738b313473b40daaa9d91ddb8eb5d6be89 100644 (file)
@@ -24,7 +24,9 @@
   <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="scope" select="(ancestor::book|/)[last()]"/>
+        </xsl:call-template>
       </fo:block>
     </xsl:when>
     <xsl:otherwise>
@@ -33,7 +35,9 @@
         <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="scope" 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="scope" 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="scope" select="(ancestor::book|/)[last()]"/>
+            </xsl:call-template>
           </xsl:otherwise>
         </xsl:choose>
       </xsl:if>
   <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:choose>
+          <xsl:when test="$make.index.markup != 0">body</xsl:when>
+          <xsl:otherwise>index</xsl:otherwise>
+        </xsl:choose>
       </xsl:with-param>
     </xsl:call-template>
   </xsl:variable>
                       white-space-collapse='false'
                       xsl:use-attribute-sets="monospace.verbatim.properties"
                       linefeed-treatment="preserve">
-              <xsl:call-template name="generate-setindex-markup"/>
+              <xsl:call-template name="generate-index-markup">
+                <xsl:with-param name="scope" 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-setindex"/>
+            <xsl:call-template name="generate-index">
+              <xsl:with-param name="scope" select="/"/>
+            </xsl:call-template>
           </xsl:otherwise>
         </xsl:choose>
       </xsl:if>