]> granicus.if.org Git - docbook-dsssl/commitdiff
Make sure that indexdivs are properly scoped. I've done this by adding a test to...
authorNorman Walsh <ndw@nwalsh.com>
Sun, 12 Jan 2003 18:17:51 +0000 (18:17 +0000)
committerNorman Walsh <ndw@nwalsh.com>
Sun, 12 Jan 2003 18:17:51 +0000 (18:17 +0000)
xsl/fo/autoidx.xsl
xsl/html/autoidx.xsl

index 6373716ea9683e4f19e3e5457a46468acc89d70f..96343b3510219284df798c4f0b0fda1cb53e2296 100644 (file)
@@ -69,6 +69,7 @@
   <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:apply-templates>
       </fo:block>
     </xsl:if>
+
     <xsl:apply-templates select="$alphabetical[count(.|key('letter',
-                                 translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;))[&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:template match="indexterm" mode="index-div">
   <xsl:param name="scope" select="."/>
 
-  <xsl:variable name="key" select="translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;)"/>
-  <fo:block>
-    <xsl:if test="contains(concat(&lowercase;, &uppercase;), $key)">
-      <fo:block font-size="16pt"
-                font-weight="bold"
-                keep-with-next.within-column="always"
-                space-before="1em">
-        <xsl:value-of select="translate($key, &lowercase;, &uppercase;)"/>
-      </fo:block>
-    </xsl:if>
+  <xsl:variable name="key"
+                select="translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;)"/>
+
+  <xsl:if test="key('letter', $key)[&scope;]
+                [count(.|key('primary', &primary;)[&scope;][1]) = 1]">
     <fo:block>
-      <xsl:apply-templates select="key('letter', $key)[&scope;][count(.|key('primary', &primary;)[&scope;][1]) = 1]"
-                           mode="index-primary">
-        <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
-        <xsl:with-param name="scope" select="$scope"/>
-      </xsl:apply-templates>
+      <xsl:if test="contains(concat(&lowercase;, &uppercase;), $key)">
+        <fo:block font-size="16pt"
+                  font-weight="bold"
+                  keep-with-next.within-column="always"
+                  space-before="1em">
+          <xsl:value-of select="translate($key, &lowercase;, &uppercase;)"/>
+        </fo:block>
+      </xsl:if>
+      <fo:block>
+        <xsl:apply-templates select="key('letter', $key)[&scope;]
+                                     [count(.|key('primary', &primary;)[&scope;][1])=1]"
+                             mode="index-primary">
+          <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>
+          <xsl:with-param name="scope" select="$scope"/>
+        </xsl:apply-templates>
+      </fo:block>
     </fo:block>
-  </fo:block>
+  </xsl:if>
 </xsl:template>
 
 <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;)"/>
+  <xsl:variable name="key"
+                select="translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;)"/>
 
   <fo:block>
     <xsl:apply-templates select="key('letter', $key)[&scope;][count(.|key('primary', &primary;)[&scope;][1]) = 1]"
index eaf8ab690db16063332dd605be9a602e2a6ad7ff..46d90476239781f648d3099b0ef8ab875efe32ee 100644 (file)
@@ -99,6 +99,7 @@
   <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)))]"/>
         </dl>
       </div>
     </xsl:if>
+
     <xsl:apply-templates select="$alphabetical[count(.|key('letter',
-                                 translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;))[&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:template match="indexterm" mode="index-div">
   <xsl:param name="scope" select="."/>
 
-  <xsl:variable name="key" select="translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;)"/>
+  <xsl:variable name="key"
+                select="translate(substring(&primary;, 1, 1),&lowercase;,&uppercase;)"/>
 
-  <div class="indexdiv">
-    <xsl:if test="contains(concat(&lowercase;, &uppercase;), $key)">
-      <h3>
-        <xsl:value-of select="translate($key, &lowercase;, &uppercase;)"/>
-      </h3>
-    </xsl:if>
-    <dl>
-      <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:apply-templates>
-    </dl>
-  </div>
+  <!-- Make sure that we don't generate a div if there are no terms in scope -->
+  <xsl:if test="key('letter', $key)[&scope;]
+                [count(.|key('primary', &primary;)[&scope;][1]) = 1]">
+    <div class="indexdiv">
+      <xsl:if test="contains(concat(&lowercase;, &uppercase;), $key)">
+        <h3>
+          <xsl:value-of select="translate($key, &lowercase;, &uppercase;)"/>
+        </h3>
+      </xsl:if>
+      <dl>
+        <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:apply-templates>
+      </dl>
+    </div>
+  </xsl:if>
 </xsl:template>
 
 <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;)"/>
-  <xsl:apply-templates select="key('letter', $key)[count(.|key('primary', &primary;)[&scope;][1]) = 1]"
+
+  <xsl:variable name="key" select="translate(substring(&primary;, 1, 1),
+                                             &lowercase;,&uppercase;)"/>
+
+  <xsl:apply-templates select="key('letter', $key)
+                               [count(.|key('primary', &primary;)[&scope;][1]) = 1]"
                        mode="index-primary">
     <xsl:with-param name="scope" select="$scope"/>
     <xsl:sort select="translate(&primary;, &lowercase;, &uppercase;)"/>