]> granicus.if.org Git - docbook-dsssl/commitdiff
Adding regression for dropped text in dedications and bookinfos
authorKeith Fahlgren <abdelazer@users.sourceforge.net>
Thu, 26 Jun 2008 01:07:55 +0000 (01:07 +0000)
committerKeith Fahlgren <abdelazer@users.sourceforge.net>
Thu, 26 Jun 2008 01:07:55 +0000 (01:07 +0000)
xsl/epub/bin/spec/epub_regressions_spec.rb
xsl/epub/bin/spec/epub_spec.rb
xsl/epub/docbook.xsl

index ac6a9cedb6dd477ad239ae7ccbd666efa3574308..262516d4dd0baa3ace8f5465c4c96e0f4de155ce 100755 (executable)
@@ -41,6 +41,27 @@ describe DocBook::Epub do
     itemrefs.should == itemrefs.uniq
   end
 
+  it "should preserve content from <dedication> elements" do
+    begin
+      tmpdir = File.join(Dir::tmpdir(), "epubdedtest"); Dir.mkdir(tmpdir) rescue Errno::EEXIST
+      
+      epub = DocBook::Epub.new(File.join(@testdocsdir, "xref.001.xml"), @tmpdir)
+      epubfile = File.join(tmpdir, "regress.ded.epub")
+      epub.render_to_file(epubfile, $DEBUG)
+      FileUtils.copy(epubfile, ".re.ded.epub") if $DEBUG
+
+      success = system("unzip -q -d #{File.expand_path(tmpdir)} -o #{epubfile}")
+      raise "Could not unzip #{epubfile}" unless success
+      glob = Dir.glob(File.join(tmpdir, "**", "*.opf"))
+      index_html_links = glob.find_all {|opf_file| File.open(opf_file).readlines.to_s =~ /href=["']index.html["']/}
+      index_html_links.should_not be_empty
+    rescue => e
+      raise e
+    ensure
+      FileUtils.rm_r(tmpdir, :force => true)
+    end  
+  end
+
   after(:all) do
     FileUtils.rm_r(@tmpdir, :force => true)
   end  
index 54cdf397784e519e31250b7fc4da9f7afd8e3c4f..4c734f49abc551bb636e1a7070c766713d43762e 100755 (executable)
@@ -88,7 +88,6 @@ describe DocBook::Epub do
     FileUtils.copy(article_nosects_epubfile, ".as.epub") if $DEBUG
 
     article_nosects_epubfile.should be_valid_epub  
-
   end
 
 
@@ -204,6 +203,7 @@ describe DocBook::Epub do
       epub = DocBook::Epub.new(File.join(@testdocsdir, "book.002.xml"), @tmpdir)
       epubfile = File.join(tmpdir, "toclink.epub")
       epub.render_to_file(epubfile, $DEBUG)
+      FileUtils.copy(epubfile, ".tcl.epub") if $DEBUG
 
       success = system("unzip -q -d #{File.expand_path(tmpdir)} -o #{epubfile}")
       raise "Could not unzip #{epubfile}" unless success
index 6a4b8ad3e1e23e5c72b78c573928e26d970b923a..ab850115a032881db111afd28a8b192eef5633b2 100644 (file)
@@ -19,7 +19,6 @@
   <xsl:param name="chunk.tocs.and.lots">1</xsl:param>
   <xsl:param name="toc.section.depth">2</xsl:param>
   <xsl:param name="generate.toc">
-  article   toc,title
   book   toc,title
   </xsl:param>
 
   <!-- no navigation in .epub -->
   <xsl:param name="suppress.navigation" select="'1'"/> 
 
+  <xsl:variable name="toc.params">
+    <xsl:call-template name="find.path.params">
+      <xsl:with-param name="node" select="/*"/>
+      <xsl:with-param name="table" select="normalize-space($generate.toc)"/>
+    </xsl:call-template>
+  </xsl:variable>
   <xsl:variable name="root.is.a.chunk">
     <xsl:choose>
       <xsl:when test="/*[not(self::book)][not(sect1) or not(section)]">
         <xsl:text>1</xsl:text>
       </xsl:when>
-      <xsl:when test="/book[*[last()][self::bookinfo]]">
+      <xsl:when test="/book[*[last()][self::bookinfo]]|book[bookinfo]">
         <xsl:text>1</xsl:text>
       </xsl:when>
       <xsl:when test="/bibliography">
     </xsl:call-template>
   </xsl:template>
 
-  <!-- TODO: Are we certain of this match list? -->
   <xsl:template match="book|
                        article|
                        part|
   </xsl:template>
 
   <xsl:template name="opf.guide">
-    <xsl:if test="$root.is.a.chunk = '0' or /*/*[contains(name(.), 'info')]/mediaobject[@role='cover']"> 
+    <xsl:if test="contains($toc.params, 'toc') or 
+                  /*/*[contains(name(.), 'info')]/mediaobject[@role='cover']"> 
       <xsl:element name="guide">
         <xsl:attribute name="xmlns">http://www.idpf.org/2007/opf</xsl:attribute>
         <xsl:if test="/*/*[contains(name(.), 'info')]/mediaobject[@role='cover']"> 
           </xsl:element>
         </xsl:if>  
 
-        <!-- TODO test against generate.toc -->
-        <xsl:if test="$root.is.a.chunk = '0'">
+        <xsl:if test="contains($toc.params, 'toc')">
           <xsl:element name="reference">
             <xsl:attribute name="href">
               <!-- TODO: Figure out how to get this to work right with generation but also not be hardcoded -->
       </xsl:if>
 
 
-      <xsl:if test="$root.is.a.chunk = '0'">
-        <!-- TODO test against generate.toc -->
+      <xsl:if test="contains($toc.params, 'toc')">
         <xsl:element name="itemref">
           <xsl:attribute name="idref"> <xsl:value-of select="$epub.html.toc.id"/> </xsl:attribute>
           <xsl:attribute name="linear">yes</xsl:attribute>
         <xsl:attribute name="href"><xsl:value-of select="$epub.ncx.filename"/> </xsl:attribute>
       </xsl:element>
 
-      <!-- TODO test against generate.toc -->
-      <xsl:if test="$root.is.a.chunk = '0'">
+      <xsl:if test="contains($toc.params, 'toc')">
         <xsl:element name="item">
           <xsl:attribute name="id"> <xsl:value-of select="$epub.html.toc.id"/> </xsl:attribute>
           <xsl:attribute name="media-type">application/xhtml+xml</xsl:attribute>
       <!-- TODO: be nice to have a id="titlepage" here -->
       <xsl:apply-templates select="//part|
                                    //book[*[last()][self::bookinfo]]|
+                                   //book[bookinfo]|
                                    /set|
                                    /set/book|
                                    //reference|
     </xsl:if>
   </xsl:template>
 
-  <!-- TODO: Are we certain of this match list? -->
+  <!-- Warning: While the test indicate this match list is accurate, it may 
+       need further tweaking to ensure _never_ dropping generated content (XHTML)
+       from the manifest (OPF file) -->
   <xsl:template
       match="set|
             book[parent::set]|
             book[*[last()][self::bookinfo]]|
+            book[bookinfo]|
             article|
             part|
             reference|