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
--- /dev/null
+<?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>
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',