]> granicus.if.org Git - docbook-dsssl/commitdiff
Support spanning index terms (endofrange/startref)
authorNorman Walsh <ndw@nwalsh.com>
Thu, 31 Oct 2002 18:30:57 +0000 (18:30 +0000)
committerNorman Walsh <ndw@nwalsh.com>
Thu, 31 Oct 2002 18:30:57 +0000 (18:30 +0000)
xsl/fo/autoidx.xsl
xsl/html/autoidx.xsl

index 74dda46dfd0ba6eaea9bb67c5bf7be22c2542fb8..5990701cdbaee3f74ad22254a7c935d1085364f6 100644 (file)
          match="indexterm"
          use="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;)"/>
 
+<xsl:key name="endofrange"
+         match="indexterm[@class='endofrange']"
+         use="@startref"/>
+
 <xsl:key name="see-also"
          match="indexterm[seealso]"
          use="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, seealso)"/>
@@ -52,7 +56,6 @@
          use="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;, &sep;, see)"/>
 
 <xsl:template name="generate-index">
-  <!-- FIXME: Ignore class='endofrange' terms because they come out wrong -->
   <xsl:variable name="terms"
                 select="//indexterm[count(.|key('letter',
                                                 translate(substring(&primary;, 1, 1),
 </xsl:template>
 
 <xsl:template match="indexterm" mode="reference">
+  <xsl:param name="separator" select="', '"/>
+
   <xsl:if test="$passivetex.extensions = '0'">
-    <xsl:text>, </xsl:text>
+    <xsl:value-of select="$separator"/>
   </xsl:if>
+
   <xsl:choose>
     <xsl:when test="@zone and string(@zone)">
       <xsl:call-template name="reference">
         <xsl:call-template name="object.id"/>
       </xsl:variable>
 
-      <xsl:choose>
-        <xsl:when test="@startref and @class='endofrange'">
-          <fo:basic-link internal-destination="{@startref}">
-            <fo:page-number-citation ref-id="{@startref}"/>
-            <xsl:text>-</xsl:text>
-            <fo:page-number-citation ref-id="{$id}"/>
-          </fo:basic-link>
-        </xsl:when>
-        <xsl:otherwise>
-          <fo:basic-link internal-destination="{$id}">
-            <fo:page-number-citation ref-id="{$id}"/>
-          </fo:basic-link>
-        </xsl:otherwise>
-      </xsl:choose>
+      <fo:basic-link internal-destination="{$id}">
+        <fo:page-number-citation ref-id="{$id}"/>
+      </fo:basic-link>
+
+      <xsl:if test="key('endofrange', @id)">
+        <xsl:apply-templates select="key('endofrange', @id)[last()]"
+                             mode="reference">
+          <xsl:with-param name="separator" select="'-'"/>
+        </xsl:apply-templates>
+      </xsl:if>
     </xsl:otherwise>
   </xsl:choose>
 </xsl:template>
index d788c8a3918311c594a5d9a088478973a8035393..f21314570c570b3593c86462d33aeb311e29b3e6 100644 (file)
          match="indexterm"
          use="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;)"/>
 
+<xsl:key name="endofrange"
+         match="indexterm[@class='endofrange']"
+         use="@startref"/>
+
 <xsl:key name="primary-section"
          match="indexterm[not(secondary) and not(see)]"
          use="concat(&primary;, &sep;, &section.id;)"/>
@@ -82,7 +86,6 @@
 <xsl:key name="sections" match="*[@id]" use="@id"/>
 
 <xsl:template name="generate-index">
-  <!-- FIXME: Ignore class='endofrange' terms because they come out wrong -->
   <xsl:variable name="terms"
                 select="//indexterm[count(.|key('letter',
                                                 translate(substring(&primary;, 1, 1),
 </xsl:template>
 
 <xsl:template match="indexterm" mode="reference">
-  <xsl:text>, </xsl:text>
+  <xsl:param name="separator" select="', '"/>
+
+  <xsl:value-of select="$separator"/>
   <xsl:choose>
     <xsl:when test="@zone and string(@zone)">
       <xsl:call-template name="reference">
 
         <xsl:value-of select="$title"/> <!-- text only -->
       </a>
+
+      <xsl:if test="key('endofrange', @id)">
+        <xsl:apply-templates select="key('endofrange', @id)[last()]"
+                             mode="reference">
+          <xsl:with-param name="separator" select="'-'"/>
+        </xsl:apply-templates>
+      </xsl:if>
     </xsl:otherwise>
   </xsl:choose>
 </xsl:template>