]> granicus.if.org Git - docbook-dsssl/commitdiff
Add DocBook abstract -> OPF dc:description mapping and tests
authorKeith Fahlgren <abdelazer@users.sourceforge.net>
Fri, 10 Apr 2009 02:00:12 +0000 (02:00 +0000)
committerKeith Fahlgren <abdelazer@users.sourceforge.net>
Fri, 10 Apr 2009 02:00:12 +0000 (02:00 +0000)
xsl/epub/bin/spec/epub_realbook_spec.rb
xsl/epub/bin/spec/files/orm.book.001.xml
xsl/epub/docbook.xsl

index a57149f71e674c146e2eef51d2c6a3d8ccb5a340..0804fb6fe129513c85ffb395d9cfc6d48ace257f 100755 (executable)
@@ -78,6 +78,10 @@ describe DocBook::Epub do
     @opf_lines.to_s.should =~ /publisher[^>]+>O'Rxxxxx Mxxxx, Ixx.</
   end
 
+  it "should use the <abstract> as dc:description for the 'Real Book' test document #{@xml_file}" do
+    @opf_lines.to_s.should =~ /description[^>]+>This is a great title! Many people love it!</
+  end
+
   after(:all) do
     FileUtils.rm_r(@tmpdir, :force => true)
     FileUtils.rm_r(@tmpdir2, :force => true)
index b26fb9a3ea6682b5596bd471f48e1d75f73ba594..28dabacc29d0b6fc809c41c130e8bdf50a736c43 100644 (file)
@@ -54,6 +54,7 @@
         <para>Axxxx, dddd</para>
       </formalpara>
     </printhistory>
+    <abstract><para>This is a great title!</para><para>Many people love it!</para></abstract>
     <copyright>
       <year>dddd</year>
       <holder>O’Rxxxxx Mxxxx</holder>
index 86c8bc85099ed0fd84670ab5bfb76cce34255187..680a42adac9d6d068c53607469cafcda647472f6 100644 (file)
     </xsl:element>
   </xsl:template>
 
+  <!-- Space separate the compontents of the abstract (dropping the inline markup, sadly) -->
+  <xsl:template match="abstract" mode="opf.metadata">
+    <xsl:element name="dc:description">
+      <xsl:for-each select="formalpara|para|simpara|title">
+        <xsl:choose>
+          <xsl:when test="self::formalpara">
+            <xsl:value-of select="normalize-space(string(title))"/>
+            <xsl:text> </xsl:text>
+            <xsl:value-of select="normalize-space(string(para))"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:value-of select="normalize-space(string(.))"/>
+          </xsl:otherwise>  
+        </xsl:choose>
+        <xsl:if test="not(position() = last())">
+          <xsl:text> </xsl:text>
+        </xsl:if>
+      </xsl:for-each>  
+    </xsl:element>
+  </xsl:template>
+
   <xsl:template match="publisher" mode="opf.metadata">
     <xsl:apply-templates select="publishername" mode="opf.metadata"/>
   </xsl:template>