Commits

Anonymous committed 5fb950b

Add <ol>/<ul>/<li> to the proto-Text and XML grammar.

TODO : add them to the XSLT.

  • Participants
  • Parent commits 07074e1

Comments (0)

Files changed (6)

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

 t/fiction/data/proto-text/with-multi-line-comments.txt
 t/fiction/data/proto-text/with-multi-para-desc.txt
 t/fiction/data/proto-text/with-tags-inside-paragraphs.txt
+t/fiction/data/proto-text/with-ul-ol-li.txt
 t/fiction/data/xml/dialogue-with-several-paragraphs.xml
 t/fiction/data/xml/nested-s.xml
 t/fiction/data/xml/scenes-with-titles.xml
 t/fiction/data/xml/with-multi-line-comments.xml
 t/fiction/data/xml/with-multi-para-desc.xml
 t/fiction/data/xml/with-tags-inside-paragraphs.xml
+t/fiction/data/xml/with-ul-ol-li.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/extradata/fiction-xml.rng

     </define>
     <define name="several_paras">
         <zeroOrMore>
-            <ref name="para"/>
+            <choice>
+                <ref name="para"/>
+                <ref name="ol"/>
+                <ref name="ul"/>
+            </choice>
         </zeroOrMore>
     </define>
+    <define name="inside_list">
+        <oneOrMore>
+            <ref name="li" />
+        </oneOrMore>
+    </define>
+    <define name="ol">
+        <element name="fic:ol">
+            <ref name="inside_list" />
+        </element>
+    </define>
+    <define name="ul">
+        <element name="fic:ul">
+            <ref name="inside_list" />
+        </element>
+    </define>
+    <define name="li">
+        <element name="fic:li">
+            <oneOrMore>
+                <ref name="para" />
+            </oneOrMore>
+        </element>
+    </define>
     <define name="para">
         <element name="fic:p">
             <zeroOrMore>

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

     return;
 }
 
+
+sub _handle_elem_of_name_li
+{
+    my ($self, $elem) = @_;
+
+    $self->_output_tag_with_childs(
+        {
+            start => ['li'],
+            elem => $elem,
+        }
+    );
+
+    return;
+}
+
+sub _handle_elem_of_name_ol
+{
+    my ($self, $elem) = @_;
+
+    $self->_output_tag_with_childs(
+        {
+            start => ['ol'],
+            elem => $elem,
+        }
+    );
+
+    return;
+}
+
+sub _handle_elem_of_name_ul
+{
+    my ($self, $elem) = @_;
+
+    $self->_output_tag_with_childs(
+        {
+            start => ['ul'],
+            elem => $elem,
+        }
+    );
+
+    return;
+}
+
 sub _handle_elem_of_name_title
 {
     my ($self, $elem) = @_;

File perl/modules/XML-Grammar-Fiction/t/fiction/data/proto-text/with-ul-ol-li.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:
+
+<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>
+
+
+</s>
+
+</s>
+
+</body>
+

File perl/modules/XML-Grammar-Fiction/t/fiction/data/xml/with-ul-ol-li.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>
+    <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>
+    </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 => 8;
+use Test::More tests => 10;
 
 use Test::XML;
 
     sections-p-b-i
     sections-p-b-i-comments
     sections-a-href
+    with-ul-ol-li
     ));
 
-# TEST:$num_texts=4
+# TEST:$num_texts=5
 
 my $grammar = XML::Grammar::Fiction::FromProto->new({
         parser_class => "XML::Grammar::Fiction::FromProto::Parser::QnD",