]> granicus.if.org Git - docbook-dsssl/commitdiff
Fix serious indexing bug that caused many index terms to be missing from the automati...
authorNorman Walsh <ndw@nwalsh.com>
Thu, 22 Aug 2002 21:39:14 +0000 (21:39 +0000)
committerNorman Walsh <ndw@nwalsh.com>
Thu, 22 Aug 2002 21:39:14 +0000 (21:39 +0000)
xsl/fo/autoidx.xsl

index decd0abd65abe8611f6e14131f2cc84a12bd0f70..0da182ece2cd8b2bd01b4d8b5d46a83162c23318 100644 (file)
@@ -8,29 +8,6 @@
 <!ENTITY secondary 'normalize-space(concat(secondary/@sortas, secondary[not(@sortas)]))'>
 <!ENTITY tertiary  'normalize-space(concat(tertiary/@sortas, tertiary[not(@sortas)]))'>
 
-<!ENTITY section   '(ancestor-or-self::set
-                     |ancestor-or-self::book
-                     |ancestor-or-self::part
-                     |ancestor-or-self::reference
-                     |ancestor-or-self::partintro
-                     |ancestor-or-self::chapter
-                     |ancestor-or-self::appendix
-                     |ancestor-or-self::preface
-                     |ancestor-or-self::section
-                     |ancestor-or-self::sect1
-                     |ancestor-or-self::sect2
-                     |ancestor-or-self::sect3
-                     |ancestor-or-self::sect4
-                     |ancestor-or-self::sect5
-                     |ancestor-or-self::refsect1
-                     |ancestor-or-self::refsect2
-                     |ancestor-or-self::refsect3
-                     |ancestor-or-self::simplesect
-                     |ancestor-or-self::bibliography
-                     |ancestor-or-self::glossary
-                     |ancestor-or-self::index)[last()]'>
-
-<!ENTITY section.id 'generate-id(&section;)'>
 <!ENTITY sep '" "'>
 ]>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
          match="indexterm"
          use="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;)"/>
 
-<xsl:key name="primary-section"
-         match="indexterm[not(secondary) and not(see)]"
-         use="concat(&primary;, &sep;, &section.id;)"/>
-
-<xsl:key name="secondary-section"
-         match="indexterm[not(tertiary) and not(see)]"
-         use="concat(&primary;, &sep;, &secondary;, &sep;, &section.id;)"/>
-
-<xsl:key name="tertiary-section"
-         match="indexterm[not(see)]"
-         use="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, &section.id;)"/>
-
 <xsl:key name="see-also"
          match="indexterm[seealso]"
          use="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, seealso)"/>
@@ -86,8 +51,6 @@
          match="indexterm[see]"
          use="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, see)"/>
 
-<xsl:key name="sections" match="*[@id]" use="@id"/>
-
 <xsl:template name="generate-index">
   <xsl:variable name="terms" select="//indexterm[count(.|key('letter',
                                      translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;))[1]) = 1]"/>
     <xsl:value-of select="primary"/>
 
     <xsl:variable name="page-number-citations">
-      <xsl:for-each select="$refs[generate-id() = generate-id(key('primary-section', concat($key, &sep;, &section.id;))[1])]">
+      <xsl:for-each select="$refs[not(see) and not(seealso)]">
         <xsl:apply-templates select="." mode="reference"/>
       </xsl:for-each>
 
       </xsl:otherwise>
     </xsl:choose>
   </fo:block>
+
   <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))[1])]"
     <xsl:value-of select="secondary"/>
 
     <xsl:variable name="page-number-citations">
-      <xsl:for-each select="$refs[generate-id() = generate-id(key('secondary-section', concat($key, &sep;, &section.id;))[1])]">
+      <xsl:for-each select="$refs[not(see) and not(seealso)]">
         <xsl:apply-templates select="." mode="reference"/>
       </xsl:for-each>
 
     <xsl:value-of select="tertiary"/>
 
     <xsl:variable name="page-number-citations">
-      <xsl:for-each select="$refs[generate-id() = generate-id(key('tertiary-section', concat($key, &sep;, &section.id;))[1])]">
+      <xsl:for-each select="$refs[not(see) and not(seealso)]">
         <xsl:apply-templates select="." mode="reference"/>
       </xsl:for-each>
 
   <xsl:choose>
     <xsl:when test="contains($zones, ' ')">
       <xsl:variable name="zone" select="substring-before($zones, ' ')"/>
-      <xsl:variable name="target" select="key('sections', $zone)"/>
+      <xsl:variable name="target" select="key('id', $zone)"/>
 
       <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('sections', $zone)"/>
+      <xsl:variable name="target" select="key('id', $zone)"/>
 
       <xsl:variable name="id">
         <xsl:call-template name="object.id">
 <xsl:template match="indexterm" mode="index-primary-markup">
   <xsl:variable name="key" select="&primary;"/>
   <xsl:variable name="refs" select="key('primary', $key)"/>
-  <xsl:variable name="pages" select="$refs[generate-id() = generate-id(key('primary-section', concat($key, &sep;, &section.id;))[1])]"/>
+  <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;</xsl:text>
 <xsl:template match="indexterm" mode="index-secondary-markup">
   <xsl:variable name="key" select="concat(&primary;, &sep;, &secondary;)"/>
   <xsl:variable name="refs" select="key('secondary', $key)"/>
-  <xsl:variable name="pages" select="$refs[generate-id() = generate-id(key('secondary-section', concat($key, &sep;, &section.id;))[1])]"/>
+  <xsl:variable name="pages" select="$refs[not(see) and not(seealso)]"/>
 
   <xsl:text>&lt;secondaryie&gt;</xsl:text>
   <xsl:text>&lt;phrase&gt;</xsl:text>
 <xsl:template match="indexterm" mode="index-tertiary-markup">
   <xsl:variable name="key" select="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;)"/>
   <xsl:variable name="refs" select="key('tertiary', $key)"/>
-  <xsl:variable name="pages" select="$refs[generate-id() = generate-id(key('tertiary-section', concat($key, &sep;, &section.id;))[1])]"/>
+  <xsl:variable name="pages" select="$refs[not(see) and not(seealso)]"/>
 
   <xsl:text>&lt;tertiaryie&gt;</xsl:text>
   <xsl:text>&lt;phrase&gt;</xsl:text>
   <xsl:choose>
     <xsl:when test="contains($zones, ' ')">
       <xsl:variable name="zone" select="substring-before($zones, ' ')"/>
-      <xsl:variable name="target" select="key('sections', $zone)"/>
+      <xsl:variable name="target" select="key('id', $zone)"/>
 
       <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('sections', $zone)"/>
+      <xsl:variable name="target" select="key('id', $zone)"/>
 
       <xsl:variable name="id">
         <xsl:call-template name="object.id">