Commits

shl...@52c325ad-5fd0-0310-8a0f-c43feede02cc  committed bed71bf

Now supporting the Fiction-XML DocBook 5 output of the <span xlink:href>.

  • Participants
  • Parent commits ce04326

Comments (0)

Files changed (5)

File perl/modules/XML-Grammar-Fiction/MANIFEST

 tag-release.pl
 t/app-to-html.t
 t/boilerplate.t
+t/data/docbook/sections-a-href.docbook.xml
+t/data/docbook/sections-and-paras.docbook.xml
 t/data/docbook/sections-p-b-i-comments.docbook.xml
 t/data/docbook/with-internal-description.docbook.xml
 t/data/proto-text/dialogue-with-several-paragraphs.txt

File perl/modules/XML-Grammar-Fiction/extradata/fiction-xml-to-docbook.xslt

     </emphasis>
 </xsl:template>
 
+<xsl:template match="fic:span">
+    <xsl:choose>
+        <xsl:when test="@xlink:href">
+            <link>
+                <xsl:attribute name="xlink:href">
+                    <xsl:value-of select="@xlink:href" />
+                </xsl:attribute>
+                <xsl:apply-templates/>
+            </link>
+        </xsl:when>
+        <xsl:otherwise>
+            <xsl:apply-templates/>
+        </xsl:otherwise>
+    </xsl:choose>
+</xsl:template>
 </xsl:stylesheet>

File perl/modules/XML-Grammar-Fiction/t/data/docbook/sections-a-href.docbook.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<article xmlns="http://docbook.org/ns/docbook" xmlns:fic="http://web-cpan.berlios.de/modules/XML-Grammar-Fortune/fiction-xml-0.2/" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="index" xml:lang="">
+  <info>
+    <title>David vs. Goliath - Part I</title>
+  </info>
+  <section xml:id="top">
+    <info>
+      <title>The Top Section</title>
+    </info>
+    <para>
+        King <link xlink:href="http://en.wikipedia.org/wiki/David">David</link> and Goliath were standing by each other.    
+    </para>
+    <para>
+    David said unto Goliath: "I will shoot you. I <emphasis role="bold">swear</emphasis> I will"
+    </para>
+    <section xml:id="goliath">
+      <info>
+        <title>Goliath's Response</title>
+      </info>
+      <para>
+    Goliath was not amused.
+    </para>
+      <para>
+    He said to David: "Oh, really. <emphasis>David</emphasis>, the red-headed!".
+    </para>
+    </section>
+  </section>
+</article>

File perl/modules/XML-Grammar-Fiction/t/data/docbook/sections-and-paras.docbook.xml

+<?xml version="1.0" encoding="UTF-8"?>
+<article xmlns="http://docbook.org/ns/docbook" xmlns:fic="http://web-cpan.berlios.de/modules/XML-Grammar-Fortune/fiction-xml-0.2/" xmlns:xlink="http://www.w3.org/1999/xlink" xml:id="index" xml:lang="">
+  <info>
+    <title>David vs. Goliath - Part I</title>
+  </info>
+  <section xml:id="top">
+    <info>
+      <title>The Top Section</title>
+    </info>
+    <para>
+        David and Goliath were standing by each other.    
+    </para>
+    <para>
+        David said unto Goliath: "I will shoot you."
+    </para>
+    <section xml:id="goliath">
+      <info>
+        <title>Goliath's Response</title>
+      </info>
+      <para>
+    Goliath was not amused.
+    </para>
+      <para>
+    He said to David: "Oh, really".
+    </para>
+    </section>
+  </section>
+</article>

File perl/modules/XML-Grammar-Fiction/t/to-docbook.t

 
 use Test::More;
 
-use Test::XML tests => 4;
+use Test::XML tests => 9;
 
 use File::Spec;
 
 my @tests = (qw(
         sections-and-paras
         sections-p-b-i-comments
+        sections-a-href
     ));
 
 sub load_xml
 {
     my $path = shift;
 
-    open my $in, "<", $path;
+    open my $in, "<", $path
+        or die "Cannot open '$path' for reading";
     my $contents;
     {
         local $/;
-        $contents = <$in>
+        $contents = <$in>;
     }
     close($in);
     return $contents;
 }
 
-# TEST:$num_texts=2
+# TEST:$num_texts=3
 
 my $converter = XML::Grammar::Fiction::ToDocBook->new({
         data_dir => File::Spec->catdir(File::Spec->curdir(), "extradata"),
         ),
         "Found role=description sections",
     );
+
+    # TEST*$num_texts
+    is_xml ($docbook_text, load_xml("t/data/docbook/$fn.docbook.xml"),
+        "Output of the DocBook \"$fn\"",
+    );
 }
 
 1;