]> granicus.if.org Git - docbook-dsssl/commitdiff
Added support for index.on.type to support new type attribute
authorBob Stayton <bobs@sagehill.net>
Sun, 13 Jun 2004 08:36:04 +0000 (08:36 +0000)
committerBob Stayton <bobs@sagehill.net>
Sun, 13 Jun 2004 08:36:04 +0000 (08:36 +0000)
on indexterm an index.

xsl/html/autoidx.xsl

index ef53bed5af5c60c33bea20ac31e22eadb723bd63..5b626a8b41b3a9a892329fd18978da905e72a3f4 100644 (file)
@@ -36,7 +36,8 @@
 <!ENTITY section.id 'generate-id(&section;)'>
 <!ENTITY sep '" "'>
 <!ENTITY scope 'count(ancestor::node()|$scope) = count(ancestor::node())
-                and ($role = @role or string-length($role) = 0)'>
+                and ($role = @role or $type = @type or
+                (string-length($role) = 0 and string-length($type) = 0))'>
 ]>
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                 version="1.0">
     </xsl:if>
   </xsl:variable>
 
+  <xsl:variable name="type">
+    <xsl:if test="$index.on.type != 0">
+      <xsl:value-of select="@type"/>
+    </xsl:if>
+  </xsl:variable>
+
   <xsl:variable name="terms"
                 select="//indexterm[count(.|key('letter',
                                                 translate(substring(&primary;, 1, 1),
                                mode="index-symbol-div">
             <xsl:with-param name="scope" select="$scope"/>
             <xsl:with-param name="role" select="$role"/>
+            <xsl:with-param name="type" select="$type"/>
             <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
           </xsl:apply-templates>
         </dl>
                          mode="index-div">
       <xsl:with-param name="scope" select="$scope"/>
       <xsl:with-param name="role" select="$role"/>
+      <xsl:with-param name="type" select="$type"/>
       <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:param name="type" select="''"/>
 
   <xsl:variable name="key"
                 select="translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;)"/>
                              mode="index-primary">
           <xsl:with-param name="scope" select="$scope"/>
           <xsl:with-param name="role" select="$role"/>
+          <xsl:with-param name="type" select="$type"/>
           <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:param name="type" select="''"/>
 
   <xsl:variable name="key" select="translate(substring(&primary;, 1, 1),
                                              &lowercase;,&uppercase;)"/>
                        mode="index-primary">
     <xsl:with-param name="scope" select="$scope"/>
     <xsl:with-param name="role" select="$role"/>
+    <xsl:with-param name="type" select="$type"/>
     <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:param name="type" select="''"/>
 
   <xsl:variable name="key" select="&primary;"/>
   <xsl:variable name="refs" select="key('primary', $key)[&scope;]"/>
       <xsl:apply-templates select="." mode="reference">
         <xsl:with-param name="scope" select="$scope"/>
         <xsl:with-param name="role" select="$role"/>
+        <xsl:with-param name="type" select="$type"/>
       </xsl:apply-templates>
     </xsl:for-each>
 
                            mode="index-see">
         <xsl:with-param name="scope" select="$scope"/>
         <xsl:with-param name="role" select="$role"/>
+        <xsl:with-param name="type" select="$type"/>
         <xsl:sort select="translate(see, &lowercase;, &uppercase;)"/>
       </xsl:apply-templates>
     </xsl:if>
                              mode="index-seealso">
           <xsl:with-param name="scope" select="$scope"/>
           <xsl:with-param name="role" select="$role"/>
+          <xsl:with-param name="type" select="$type"/>
           <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:with-param name="type" select="$type"/>
           <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:param name="type" select="''"/>
 
   <xsl:variable name="key" select="concat(&primary;, &sep;, &secondary;)"/>
   <xsl:variable name="refs" select="key('secondary', $key)[&scope;]"/>
       <xsl:apply-templates select="." mode="reference">
         <xsl:with-param name="scope" select="$scope"/>
         <xsl:with-param name="role" select="$role"/>
+        <xsl:with-param name="type" select="$type"/>
       </xsl:apply-templates>
     </xsl:for-each>
 
                            mode="index-see">
         <xsl:with-param name="scope" select="$scope"/>
         <xsl:with-param name="role" select="$role"/>
+        <xsl:with-param name="type" select="$type"/>
         <xsl:sort select="translate(see, &lowercase;, &uppercase;)"/>
       </xsl:apply-templates>
     </xsl:if>
                              mode="index-seealso">
           <xsl:with-param name="scope" select="$scope"/>
           <xsl:with-param name="role" select="$role"/>
+          <xsl:with-param name="type" select="$type"/>
           <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:with-param name="type" select="$type"/>
           <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:param name="type" select="''"/>
 
   <xsl:variable name="key" select="concat(&primary;, &sep;, &secondary;, &sep;, &tertiary;)"/>
   <xsl:variable name="refs" select="key('tertiary', $key)[&scope;]"/>
       <xsl:apply-templates select="." mode="reference">
         <xsl:with-param name="scope" select="$scope"/>
         <xsl:with-param name="role" select="$role"/>
+        <xsl:with-param name="type" select="$type"/>
       </xsl:apply-templates>
     </xsl:for-each>
 
                            mode="index-see">
         <xsl:with-param name="scope" select="$scope"/>
         <xsl:with-param name="role" select="$role"/>
+        <xsl:with-param name="type" select="$type"/>
         <xsl:sort select="translate(see, &lowercase;, &uppercase;)"/>
       </xsl:apply-templates>
     </xsl:if>
                              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:with-param name="type" select="$type"/>
+          <xsl:sort select="translate(seealso, &lowercase;, &uppercase;)"/>
         </xsl:apply-templates>
       </dl>
     </dd>
 <xsl:template match="indexterm" mode="reference">
   <xsl:param name="scope" select="."/>
   <xsl:param name="role" select="''"/>
+  <xsl:param name="type" select="''"/>
   <xsl:param name="separator" select="', '"/>
 
   <xsl:value-of select="$separator"/>
     <xsl:when test="@zone and string(@zone)">
       <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:with-param name="scope" select="$scope"/>
+        <xsl:with-param name="role" select="$role"/>
+        <xsl:with-param name="type" select="$type"/>
       </xsl:call-template>
     </xsl:when>
     <xsl:otherwise>
                              mode="reference">
           <xsl:with-param name="scope" select="$scope"/>
           <xsl:with-param name="role" select="$role"/>
+          <xsl:with-param name="type" select="$type"/>
           <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="type" select="''"/>
   <xsl:param name="zones"/>
 
   <xsl:choose>
         <xsl:with-param name="zones" select="substring-after($zones, ' ')"/>
         <xsl:with-param name="scope" select="$scope"/>
         <xsl:with-param name="role" select="$role"/>
+        <xsl:with-param name="type" select="$type"/>
       </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:param name="type" 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="''"/>
+  <xsl:param name="type" select="''"/>
 
   <xsl:for-each select="seealso">
     <xsl:sort select="translate(., &lowercase;, &uppercase;)"/>