Commits

Anonymous committed 40dad8d

add partial support for hyperlinks to Fiction-Text/Fiction-XML.

TODO : add to the XSLT.

Comments (0)

Files changed (8)

perl/modules/XML-Grammar-Fiction/Changes

 Revision history for XML-Grammar-Fiction.
 
-    * Now handling the a element only in XML::Grammar::Screenplay - it
+    * Now handling the <a /> element only in XML::Grammar::Screenplay - it
     does not exist in ::Fiction.
+    * Add support for the <a href="$URL">$CONTENT</a> tag in Fiction-Text 
+    which is translated into <span xlink:href="$URL" >$CONTENT</span> in
+    the Fiction-XML grammar.
 
 0.1.5       Mon Apr  4 23:08:18 IDT 2011
 

perl/modules/XML-Grammar-Fiction/MANIFEST

 t/data/proto-text-invalid/wrong-closing-inner-tag.txt
 t/data/proto-text/nested-s.txt
 t/data/proto-text/scenes-with-titles.txt
+t/data/proto-text/sections-a-href.txt
 t/data/proto-text/sections-and-paras.txt
 t/data/proto-text/sections-p-b-i-comments.txt
 t/data/proto-text/sections-p-b-i.txt
 t/data/xml/dialogue-with-several-paragraphs.xml
 t/data/xml/nested-s.xml
 t/data/xml/scenes-with-titles.xml
+t/data/xml/sections-a-href.xml
 t/data/xml/sections-and-paras.xml
 t/data/xml/sections-p-b-i-comments.xml
 t/data/xml/sections-p-b-i.xml

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

 <!-- $Id: testSuite.rng,v 1.12 2003/01/29 12:24:07 jjc Exp $ -->
 <grammar xmlns="http://relaxng.org/ns/structure/1.0"
     xmlns:fic="http://web-cpan.berlios.de/modules/XML-Grammar-Fortune/fiction-xml-0.2/"
+    xmlns:xlink="http://www.w3.org/1999/xlink"
     datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes"
     >
     <start>
                 <data type="NCName" />
             </attribute>
         </optional>
+        <optional>
+            <attribute name="xlink:href">
+                <data type="anyURI"/>
+            </attribute>
+        </optional>
     </define>
     <define name="section">
         <element name="fic:section">
         <element name="fic:p">
             <zeroOrMore>
                 <choice>
-                    <ref name="b" />
-                    <ref name="i" />
-                    <text />
+                    <ref name="text_with_style" />
+                    <ref name="span" />
                 </choice>
             </zeroOrMore>
         </element>
     </define>
+    <define name="text_with_style">
+        <choice>
+            <text />
+            <ref name="b" />
+            <ref name="i" />
+        </choice>
+    </define>
+    <define name="span">
+        <element name="fic:span">
+            <ref name="common_attrs" />
+            <oneOrMore>
+                <ref name="text_with_style" />
+            </oneOrMore>
+        </element>
+    </define>
     <define name="b">
         <element name="fic:b">
             <text />

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

 
 my $fiction_ns = q{http://web-cpan.berlios.de/modules/XML-Grammar-Fortune/fiction-xml-0.2/};
 my $xml_ns = "http://www.w3.org/XML/1998/namespace";
+my $xlink_ns = "http://www.w3.org/1999/xlink";
 
 =head1 NAME
 
     return "p";
 }
 
+sub _handle_elem_of_name_a
+{
+    my ($self, $elem) = @_;
+
+    $self->_output_tag_with_childs(
+        {
+            start =>
+            [
+                "span",
+                [$xlink_ns, "href"] => $elem->lookup_attr("href"),
+            ],
+            elem => $elem,
+        }
+    );
+
+    return;
+}
+
 sub _handle_elem_of_name_title
 {
     my ($self, $elem) = @_;
         NAMESPACES => 1,
         PREFIX_MAP =>
         {
-             $fiction_ns => "",
-             $xml_ns => "xml",
+             $fiction_ns => q{},
+             $xml_ns => 'xml',
+             $xlink_ns => 'xlink',
         }
     );
 

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

 sub _handle_elem_of_name_a
 {
     my ($self, $elem) = @_;
+
     $self->_output_tag_with_childs(
         {
             start => ["ulink", "url" => $elem->lookup_attr("href")],

perl/modules/XML-Grammar-Fiction/t/data/proto-text/sections-a-href.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!".
+
+</s>
+
+</s>
+
+</body>
+

perl/modules/XML-Grammar-Fiction/t/data/xml/sections-a-href.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>
+    </section>
+    </section>
+</body>
+</document>

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

 use strict;
 use warnings;
 
-use Test::More tests => 6;
+use Test::More tests => 8;
 
 use Test::XML;
 
     sections-and-paras
     sections-p-b-i
     sections-p-b-i-comments
+    sections-a-href
     ));
 
-# TEST:$num_texts=3
+# TEST:$num_texts=4
 
 my $grammar = XML::Grammar::Fiction::FromProto->new({
         parser_class => "XML::Grammar::Fiction::FromProto::Parser::QnD",
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.