]> granicus.if.org Git - docbook-dsssl/commitdiff
Fix a bug when using index.on.type: an 'index symbols' section was created
authorKeith Fahlgren <abdelazer@users.sourceforge.net>
Wed, 12 Aug 2009 02:54:56 +0000 (02:54 +0000)
committerKeith Fahlgren <abdelazer@users.sourceforge.net>
Wed, 12 Aug 2009 02:54:56 +0000 (02:54 +0000)
even if that typed index didn't include any symbols (they were in the other types).

xsl/epub/bin/spec/epub_regressions_spec.rb
xsl/epub/bin/spec/files/index.with.symbol.and.type.xml [new file with mode: 0644]
xsl/epub/bin/spec/files/test_cust.xsl
xsl/html/autoidx.xsl

index d12d128cfeba87afe25ec55f25b68811f03a7156..0d0172f95066caa7c19d50d85f8c23bbb604e1f6 100755 (executable)
@@ -167,6 +167,15 @@ describe DocBook::Epub do
     container_lines.to_s.should =~ /<container/
   end
 
+  it "should not include an index entry for Symbols when using @types and the symbols are not a part of that @type" do
+    css_file = nil
+    index_on_type_customization_layer = File.join(@filedir, "test_cust.xsl")
+    typed_index_epub = DocBook::Epub.new(File.join(@filedir, "index.with.symbol.and.type.xml"), @tmpdir, css_file, index_on_type_customization_layer)
+    typed_index_epubfile  = File.join(@tmpdir, "typed_indexepub.epub")
+    typed_index_epub.render_to_file(typed_index_epubfile, $DEBUG)
+    typed_index_epubfile.should be_valid_epub  
+  end
+
   after(:all) do
     FileUtils.rm_r(@tmpdir, :force => true)
   end  
diff --git a/xsl/epub/bin/spec/files/index.with.symbol.and.type.xml b/xsl/epub/bin/spec/files/index.with.symbol.and.type.xml
new file mode 100644 (file)
index 0000000..2812620
--- /dev/null
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN" "http://www.oasis-open.org/docbook/xml/4.4/docbookx.dtd">
+<book>
+  <title>First Book</title>
+  <chapter>
+    <title>Chapter</title>
+    <para>Some test data
+<indexterm type="a"><primary>First Book</primary></indexterm></para>
+  </chapter>
+  <chapter>
+    <title>Chapter</title>
+    <para>Some test data
+<indexterm type="b"><primary>λ (lambda operator)</primary></indexterm></para>
+  </chapter>
+  <part>
+    <title>Part Title</title>
+    <chapter>
+      <title>Chapter</title>
+      <para>Some test data
+<indexterm type="b"><primary>Third Book</primary></indexterm></para>
+    </chapter>
+    <index type="a">
+      <title>A Index</title>
+    </index>
+    <index type="b">
+      <title>B Index</title>
+    </index>
+    <index/>
+  </part>
+</book>
index 6e66a58b79f610e44dd9889081303fd2a50d3776..bf84017e4601c5ebe4d0bc203286a8dba447af18 100644 (file)
@@ -4,5 +4,6 @@ version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
   <xsl:import href="../../../../epub/docbook.xsl" />
   <xsl:param name="xref.with.number.and.title" select="0"/>
+  <xsl:param name="index.on.type" select="1"/>
 
 </xsl:stylesheet>
index 8137bc83199bd6ed8121eae6e0b5ecfb2fe8acde..cd068e4d6c0cc02999cabe061ebbaad3cf080602 100644 (file)
                                              substring(&primary;, 1, 1)))]"/>
   <div class="index">
     <xsl:if test="$others">
-      <div class="indexdiv">
-        <h3>
-          <xsl:call-template name="gentext">
-            <xsl:with-param name="key" select="'index symbols'"/>
-          </xsl:call-template>
-        </h3>
-        <dl>
-          <xsl:apply-templates select="$others[count(.|key('primary',
-                                       &primary;)[&scope;][1]) = 1]"
-                               mode="index-symbol-div">
-            <xsl:with-param name="position" select="position()"/>                                
-            <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>
-      </div>
+      <xsl:choose>
+        <xsl:when test="normalize-space($type) != '' and 
+                        $others[@type = $type][count(.|key('primary', &primary;)[&scope;][1]) = 1]">
+          <div class="indexdiv">
+            <h3>
+              <xsl:call-template name="gentext">
+                <xsl:with-param name="key" select="'index symbols'"/>
+              </xsl:call-template>
+            </h3>
+            <dl>
+              <xsl:apply-templates select="$others[count(.|key('primary', &primary;)[&scope;][1]) = 1]"
+                                   mode="index-symbol-div">
+                <xsl:with-param name="position" select="position()"/>                                
+                <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>
+          </div>
+        </xsl:when>
+        <xsl:when test="normalize-space($type) != ''"> 
+          <!-- Output nothing, as there isn't a match for $other using this $type -->
+        </xsl:when>  
+        <xsl:otherwise>
+          <div class="indexdiv">
+            <h3>
+              <xsl:call-template name="gentext">
+                <xsl:with-param name="key" select="'index symbols'"/>
+              </xsl:call-template>
+            </h3>
+            <dl>
+              <xsl:apply-templates select="$others[count(.|key('primary',
+                                          &primary;)[&scope;][1]) = 1]"
+                                  mode="index-symbol-div">
+                <xsl:with-param name="position" select="position()"/>                                
+                <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>
+          </div>
+        </xsl:otherwise>
+      </xsl:choose>
     </xsl:if>
 
     <xsl:apply-templates select="$alphabetical[count(.|key('letter',