Commits

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

Add support for id=".." and lang="..." into <blockquote>.

  • Participants
  • Parent commits 39002c4

Comments (0)

Files changed (10)

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

 Revision history for XML-Grammar-Fiction.
 
+    * <blockquote> now supports xml:id and xml:lang.
+
 0.7.0       Wed May 25 12:47:13 IDT 2011
     * Add support for the lang="..." attribute of <body> in Fiction-Text which
     would be translated to <body xml:lang=".."> attribute in Fiction-XML (and

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

 t/fiction/data/docbook/sections-and-paras.docbook.xml
 t/fiction/data/docbook/sections-p-b-i-comments.docbook.xml
 t/fiction/data/docbook/with-blockquote.docbook.xml
+t/fiction/data/docbook/with-blockquote-with-lang-and-id.docbook.xml
 t/fiction/data/docbook/with-internal-description.docbook.xml
 t/fiction/data/docbook/with-programlisting.docbook.xml
 t/fiction/data/docbook/with-span.docbook.xml
 t/fiction/data/proto-text/sections-p-b-i-comments.txt
 t/fiction/data/proto-text/sections-p-b-i.txt
 t/fiction/data/proto-text/with-blockquote.txt
+t/fiction/data/proto-text/with-blockquote-with-lang-and-id.txt
 t/fiction/data/proto-text/with-internal-description.txt
 t/fiction/data/proto-text/with-programlisting.txt
 t/fiction/data/proto-text/with-span.txt
 t/fiction/data/xml/sections-and-paras.xml
 t/fiction/data/xml/sections-p-b-i-comments.xml
 t/fiction/data/xml/sections-p-b-i.xml
+t/fiction/data/xml/with-blockquote-with-lang-and-id.xml
 t/fiction/data/xml/with-blockquote.xml
 t/fiction/data/xml/with-programlisting.xml
 t/fiction/data/xml/with-span.xml

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

 
 <xsl:template match="fic:blockquote">
     <blockquote>
+        <xsl:if test="@xlink:href">
+            <xsl:copy-of select="@xlink:href" />
+        </xsl:if>
+        <xsl:if test="@xml:lang">
+            <xsl:copy-of select="@xml:lang" />
+        </xsl:if>
+        <xsl:if test="@xml:id">
+            <xsl:copy-of select="@xml:id" />
+        </xsl:if>
         <xsl:apply-templates/>
     </blockquote>
 </xsl:template>

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

     </define>
     <define name="blockquote">
         <element name="fic:blockquote">
+            <ref name="common_attrs" />
             <ref name="several_paras"/>
         </element>
     </define>

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

 {
     my ($self, $elem) = @_;
 
-    $self->_output_tag_with_childs(
+    $self->_output_tag_with_childs_and_common_attributes(
+        $elem,
+        'blockquote',
         {
-            start => ['blockquote'],
-            elem => $elem,
-        }
+            optional_id => 1,
+        },
     );
 
     return;

File perl/modules/XML-Grammar-Fiction/t/fiction/data/docbook/with-blockquote-with-lang-and-id.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="" version="5.0">
+  <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>
+    <para>
+    David started listing Goliath's disadvantages:
+    </para>
+    <blockquote xml:lang="fr-FR" xml:id="my_blockquote">
+    <orderedlist>
+    <listitem>
+    <para>
+    You're slow.
+    </para>
+    </listitem>
+    <listitem>
+    <para>
+    You're big.
+    </para>
+    </listitem>
+    <listitem>
+    <para>
+    You're stupid.
+    </para>
+    </listitem>
+    </orderedlist>
+    <para>
+    Goliath was insulted and told David he should use bullets for the
+    points, instead:
+    </para>
+    <itemizedlist>
+    <listitem>
+    <para>
+    David.
+    </para>
+    </listitem>
+    <listitem>
+    <para>
+    Saul.
+    </para>
+    </listitem>
+    <listitem>
+    <para>
+    Jonathan.
+    </para>
+    </listitem>
+    <listitem>
+    <para>
+    Michal.
+    </para>
+    </listitem>
+    <listitem>
+    <para>
+    Meyrav.
+    </para>
+    </listitem>
+    </itemizedlist>
+    </blockquote>
+    </section>
+  </section>
+</article>

File perl/modules/XML-Grammar-Fiction/t/fiction/data/proto-text/with-blockquote-with-lang-and-id.txt

+<body id="index">
+
+<title>David vs. Goliath - Part I</title>
+
+<s id="top">
+
+<title>The Top Section</title>
+
+<!-- David has Green hair here -->
+
+King <a href="http://en.wikipedia.org/wiki/David">David</a> 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 has to reply to that. -->
+
+Goliath was not amused.
+
+He said to David: "Oh, really. <i>David</i>, the red-headed!".
+
+David started listing Goliath's disadvantages:
+
+<blockquote lang="fr-FR" id="my_blockquote">
+
+<ol>
+
+<li>
+
+You're slow.
+
+</li>
+
+<li>
+
+You're big.
+
+</li>
+
+<li>
+
+You're stupid.
+
+</li>
+
+</ol>
+
+Goliath was insulted and told David he should use bullets for the points, 
+instead:
+
+<ul>
+
+<li>
+
+David.
+
+</li>
+
+<li>
+
+Saul.
+
+</li>
+
+<li>
+
+Jonathan.
+
+</li>
+
+<li>
+
+Michal.
+
+</li>
+
+<li>
+
+Meyrav.
+
+</li>
+
+</ul>
+
+</blockquote>
+
+</s>
+
+</s>
+
+</body>
+

File perl/modules/XML-Grammar-Fiction/t/fiction/data/xml/with-blockquote-with-lang-and-id.xml

+<?xml version='1.0' encoding='utf-8'?>
+<document xmlns="http://web-cpan.berlios.de/modules/XML-Grammar-Fortune/fiction-xml-0.2/" xmlns:xlink="http://www.w3.org/1999/xlink" version="0.2">
+    <head>
+    </head>
+    <body xml:id="index">
+    <title>David vs. Goliath - Part I</title>
+    <section xml:id="top">
+    <title>The Top Section</title>
+    <!-- David has Green hair here -->
+    <p>
+    King <span xlink:href="http://en.wikipedia.org/wiki/David">David</span> 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>
+    <!-- Goliath has to reply to that. -->
+    <p>
+    Goliath was not amused.
+    </p>
+    <p>
+    He said to David: "Oh, really. <i>David</i>, the red-headed!".
+    </p>
+    <p>
+    David started listing Goliath's disadvantages:
+    </p>
+    <blockquote xml:lang="fr-FR" xml:id="my_blockquote">
+    <ol>
+    <li>
+    <p>
+    You're slow.
+    </p>
+    </li>
+    <li>
+    <p>
+    You're big.
+    </p>
+    </li>
+    <li>
+    <p>
+    You're stupid.
+    </p>
+    </li>
+    </ol>
+    <p>
+    Goliath was insulted and told David he should use bullets for the
+    points, instead:
+    </p>
+    <ul>
+    <li>
+    <p>
+    David.
+    </p>
+    </li>
+    <li>
+    <p>
+    Saul.
+    </p>
+    </li>
+    <li>
+    <p>
+    Jonathan.
+    </p>
+    </li>
+    <li>
+    <p>
+    Michal.
+    </p>
+    </li>
+    <li>
+    <p>
+    Meyrav.
+    </p>
+    </li>
+    </ul>
+    </blockquote>
+    </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 => 25;
+use Test::More tests => 27;
 
 use Test::XML;
 
     with-xml-lang-attr-in-section
     with-span
     a-href-with-id-and-lang
+    with-blockquote-with-lang-and-id
     ));
 
-# TEST:$num_texts=12
+# TEST:$num_texts=13
 
 my $grammar = XML::Grammar::Fiction::FromProto->new({
         parser_class => "XML::Grammar::Fiction::FromProto::Parser::QnD",

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

 
 use Test::More;
 
-use Test::XML tests => 30;
+use Test::XML tests => 33;
 
 use File::Spec;
 
         with-xml-lang-attr-in-section
         with-span
         a-href-with-id-and-lang
+        with-blockquote-with-lang-and-id
     ));
 
 sub load_xml
     return $contents;
 }
 
-# TEST:$num_texts=10
+# TEST:$num_texts=11
 
 my $converter = XML::Grammar::Fiction::ToDocBook->new({
         data_dir => File::Spec->catdir(File::Spec->curdir(), "extradata"),