Commits

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

Add the global <body>/<title> attribute - applied to the DocBook/XML.

  • Participants
  • Parent commits af3fbda

Comments (0)

Files changed (5)

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

         <xsl:attribute name="xml:lang">
             <xsl:value-of select="@xml:lang" />
         </xsl:attribute>
+        <info>
+            <title>
+                <xsl:value-of select="fic:title" />
+            </title>
+        </info>
         <xsl:apply-templates select="fic:section" />
     </article>
 </xsl:template>

File perl/modules/XML-Grammar-Fiction/extradata/fiction-xml.rng

             </element>
             <element name="fic:body">
                 <ref name="common_attrs" />
+                <ref name="title" />
                 <oneOrMore>
                     <ref name="section" />
                 </oneOrMore>
     <define name="section">
         <element name="fic:section">
             <ref name="common_attrs" />
-            <element name="fic:title">
-                <text />
-            </element>
+            <ref name="title" />
             <ref name="several_paras" />
             <zeroOrMore>
                 <ref name="section" />
             <text />
         </element>
     </define>
+    <define name="title">
+        <element name="fic:title">
+            <text />
+        </element>
+    </define>
 </grammar>
 

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

     <head>
     </head>
     <body xml:id="index">
+    <title>David vs. Goliath - Part I</title>        
     <section xml:id="top">
     <title>The Top Section</title>
     <p>

File perl/modules/XML-Grammar-Fiction/t/data/xml/sections-p-b-i.xml

     <head>
     </head>
     <body xml:id="index">
+        <title>David vs. Goliath - Part I</title>
     <section xml:id="top">
     <title>The Top Section</title>
     <p>

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

 use strict;
 use warnings;
 
-use Test::More tests => 12;
+use Test::More tests => 16;
 
 use File::Spec;
 
         "Found one article with id index",
     );
 
+    {
+        my @title = $db_find->(q{//db:article/db:info/db:title});
+
+        # TEST*$num_texts
+        is (
+            scalar(@title),
+            1,
+            "Found one global <db:title>",
+        );
+
+        # TEST*$num_texts
+        is ($title[0]->textContent(), "David vs. Goliath - Part I");
+    }
+
     # TEST*$num_texts
     ok (
         (scalar(() = $xhtml_find->(q{//x:div}))