Commits

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

lang="..." attribute in the body.

  • Participants
  • Parent commits b0b2a27

Comments (0)

Files changed (6)

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

 Revision history for XML-Grammar-Fiction.
 
+    * Add support for the lang="..." attribute of <body> in Fiction-Text which
+    would be translated to <body xml:lang=".."> attribute in Fiction-XML (and
+    eventually to DocBook 5/XML).
+
 0.6.0      Mon May 23 22:59:05 IDT 2011
     * Add the version="5.0" attribute to the top-level tag of the
     DocBook 5/XML generated by extradata/fiction-xml-to-docbook.xslt .

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

 t/fiction/data/proto-text/with-internal-description.txt
 t/fiction/data/proto-text/with-programlisting.txt
 t/fiction/data/proto-text/with-ul-ol-li.txt
+t/fiction/data/proto-text/with-xml-lang-attribute.txt
 t/fiction/data/xml/paras-with-entities-at-start-of-line.xml
 t/fiction/data/xml/sections-a-href.xml
 t/fiction/data/xml/sections-and-paras.xml
 t/fiction/data/xml/with-blockquote.xml
 t/fiction/data/xml/with-programlisting.xml
 t/fiction/data/xml/with-ul-ol-li.xml
+t/fiction/data/xml/with-xml-lang-attribute.xml
 t/fiction/proto-text-invalid.t
 t/fiction/proto-text-to-xml-using-custom-parser.t
 t/fiction/qnd-parser-unit.t

File perl/modules/XML-Grammar-Fiction/lib/XML/Grammar/Fiction/FromProto.pm

     }
 
     my $id = $body->lookup_attr("id");
-
+    my $lang = $body->lookup_attr("lang");
 =begin foo
 
     my $title =
 
 =cut
 
+    my @lang_attr;
+
+    if (defined($lang))
+    {
+        push @lang_attr, ([$xml_ns, 'lang'] => $lang);
+    }
     $self->_output_tag_with_childs(
         {
-            'start' => ["body", [$xml_ns, "id"] => $id],
+            'start' => ["body", [$xml_ns, "id"] => $id, @lang_attr,],
             elem => $body,
         }
     );

File perl/modules/XML-Grammar-Fiction/t/fiction/data/proto-text/with-xml-lang-attribute.txt

+<body id="index" lang="en-US">
+
+<title>David vs. Goliath - Part I</title>
+
+<s id="top">
+
+<title>The Top Section</title>
+
+David and Goliath were standing by each other.    
+
+David said unto Goliath: "I will shoot you. I <b>swear</b> I will"
+
+<s id="goliath">
+
+<title>Goliath's Response</title>
+
+Goliath was not amused.
+
+He said to David: "Oh, really. <i>David</i>, the red-headed!".
+
+</s>
+
+</s>
+
+</body>
+

File perl/modules/XML-Grammar-Fiction/t/fiction/data/xml/with-xml-lang-attribute.xml

+<?xml version='1.0' encoding='utf-8'?>
+<document xmlns="http://web-cpan.berlios.de/modules/XML-Grammar-Fortune/fiction-xml-0.2/" version="0.2">
+    <head>
+    </head>
+    <body xml:id="index" xml:lang="en-US">
+    <title>David vs. Goliath - Part I</title>
+    <section xml:id="top">
+    <title>The Top Section</title>
+    <p>
+    David and Goliath were standing by each other.    
+    </p>
+    <p>
+    David said unto Goliath: "I will shoot you. I <b>swear</b> I will"
+    </p>
+    <section xml:id="goliath">
+    <title>Goliath's Response</title>
+    <p>
+    Goliath was not amused.
+    </p>
+    <p>
+    He said to David: "Oh, really. <i>David</i>, the red-headed!".
+    </p>
+    </section>
+    </section>
+</body>
+</document>

File perl/modules/XML-Grammar-Fiction/t/fiction/proto-text-to-xml-using-custom-parser.t

 use strict;
 use warnings;
 
-use Test::More tests => 17;
+use Test::More tests => 19;
 
 use Test::XML;
 
     with-blockquote
     with-programlisting
     paras-with-entities-at-start-of-line
+    with-xml-lang-attribute
     ));
 
-# TEST:$num_texts=8
+# TEST:$num_texts=9
 
 my $grammar = XML::Grammar::Fiction::FromProto->new({
         parser_class => "XML::Grammar::Fiction::FromProto::Parser::QnD",