Commits

Shlomi Fish committed 223a45f

Extract methods to avoid duplicate vars.

Comments (0)

Files changed (2)

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

 use List::Util (qw(first));
 
 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
 
     }
     else
     {
-        push @attr, ([$xml_ns, "id"] => $id);
+        push @attr, ([$self->_get_xml_xml_ns, "id"] => $id);
     }
 
     if (defined($lang))
     {
-        push @attr, ([$xml_ns, 'lang'] => $lang);
+        push @attr, ([$self->_get_xml_xml_ns, 'lang'] => $lang);
     }
 
     if (! defined($href))
     }
     else
     {
-        push @attr, ([$xlink_ns, 'href'] => $href);
+        push @attr, ([$self->_get_xlink_xml_ns(), 'href'] => $href);
     }
 
     return $self->_output_tag_with_childs(

perl/modules/XML-Grammar-Fiction/lib/XML/Grammar/FictionBase/TagsTree2XML.pm

 
 use XML::Grammar::Fiction::FromProto::Nodes;
 
-my $xml_ns = "http://www.w3.org/XML/1998/namespace";
-my $xlink_ns = "http://www.w3.org/1999/xlink";
+sub _get_xml_xml_ns
+{
+    return "http://www.w3.org/XML/1998/namespace";
+}
+
+sub _get_xlink_xml_ns
+{
+    return "http://www.w3.org/1999/xlink";
+}
 
 =head1 NAME
 
         PREFIX_MAP =>
         {
             $self->_get_default_xml_ns() => "",
-            $xml_ns => 'xml',
-            $xlink_ns => 'xlink',
+            $self->_get_xml_xml_ns() => 'xml',
+            $self->_get_xlink_xml_ns() => 'xlink',
         },
     );