Commits

Anonymous committed 95d00ba

[XML-G-Fiction] Now we have an <h1> in the XHTML (with test).

  • Participants
  • Parent commits cf5a1b9

Comments (0)

Files changed (2)

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

             </title>
         </head>
         <body>
-            <div class="screenplay">
-            <xsl:attribute name="xml:id">
-                <xsl:value-of select="@xml:id" />
-            </xsl:attribute>
-            <xsl:apply-templates select="fic:section" />
+            <div class="fiction story">
+                <xsl:attribute name="xml:id">
+                    <xsl:value-of select="@xml:id" />
+                </xsl:attribute>                
+                <!-- TODO : duplicate code between here and fic:section.
+                    Abstract into a common functionality! 
+                -->
+                <xsl:element name="h{count(ancestor-or-self::fic:section|ancestor-or-self::fic:body)}">
+                    <xsl:value-of select="fic:title" />
+                </xsl:element>
+                
+                <xsl:apply-templates select="fic:section" />
             </div>
         </body>
     </html>

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

 use strict;
 use warnings;
 
-use Test::More tests => 20;
+use Test::More tests => 24;
 
 use File::Spec;
 
         is ($title[0]->textContent(), "David vs. Goliath - Part I");
     }
 
+    # TEST:$num_xhtml_top_titles=2;
+    # TEST:$n=$num_texts*$num_xhtml_top_titles;
+    foreach my $xpath (
+        q{//x:html/x:head/x:title}, 
+        q{//x:html/x:body/x:div/x:h1},
+    )
     {
-        my @title = $xhtml_find->(q{//x:html/x:head/x:title});
+        my @title = $xhtml_find->($xpath);
 
-        # TEST*$num_texts
+        # TEST*$n
         is (
             scalar(@title),
             1,
             "Found one global <x:title>",
         );
 
-        # TEST*$num_texts
+        # TEST*$n
         is ($title[0]->textContent(), "David vs. Goliath - Part I",
             "XHTML <title> has good content"
         );