clone 458713 -1
reassign -1 libsql-translator-perl 0.08.001-1
retitle -1 libsql-translator-perl: Please move away from libxml-xpath-perl
severity -1 wishlist
tag -1 upstream patch
forwarded -1 http://rt.cpan.org/Public/Bug/Display.html?id=32130
block 458713 by -1
thanks

On Wed, Jan 02, 2008 at 02:39:27PM +0200, Niko Tyni wrote:
 
> It looks like the libxml-xpath-perl package should be phased out and
> eventually get removed from Debian. The module is unmaintained upstream
> (last release was in 2003), and there's a maintained, faster and less
> buggy alternative available in libxml-libxml-perl.

> The reverse dependencies of libxml-xpath-perl are currently
 
>  * libsql-translator-perl: currently only supports libxml-xpath-perl 

The attached patch makes libsql-translator-perl work with
XML::LibXML::XPathContext instead of XML::XPath. I have reported it
upstream as CPAN ticket #32130.

I'm cloning a separate bug for this to document the situation.

Cheers,
-- 
Niko Tyni   [EMAIL PROTECTED]
diff --git a/Build.PL b/Build.PL
index 3190371..d49bd7f 100644
--- a/Build.PL
+++ b/Build.PL
@@ -38,7 +38,7 @@ my $builder = Module::Build->new(
         'Text::ParseWords'        => 0,
         'Text::RecordParser'      => 0.02,
         'XML::Writer'             => 0.500,
-        'XML::XPath'              => 1.13,
+        'XML::LibXML'             => 1.61,
     },
     build_requires    => {
         'File::Basename'          => 0,
diff --git a/lib/SQL/Translator/Parser/XML/SQLFairy.pm b/lib/SQL/Translator/Parser/XML/SQLFairy.pm
index a627665..896ba28 100644
--- a/lib/SQL/Translator/Parser/XML/SQLFairy.pm
+++ b/lib/SQL/Translator/Parser/XML/SQLFairy.pm
@@ -110,16 +110,17 @@ use base qw(Exporter);
 
 use base qw/SQL::Translator::Parser/;  # Doesnt do anything at the mo!
 use SQL::Translator::Utils 'debug';
-use XML::XPath;
-use XML::XPath::XMLParser;
+use XML::LibXML;
+use XML::LibXML::XPathContext;
 
 sub parse {
     my ( $translator, $data ) = @_;
     my $schema                = $translator->schema;
     local $DEBUG              = $translator->debug;
-    my $xp                    = XML::XPath->new(xml => $data);
+    my $doc                   = XML::LibXML->new->parse_string($data);
+    my $xp                    = XML::LibXML::XPathContext->new($doc);
 
-    $xp->set_namespace("sqlf", "http://sqlfairy.sourceforge.net/sqlfairy.xml";);
+    $xp->registerNs("sqlf", "http://sqlfairy.sourceforge.net/sqlfairy.xml";);
 
     #
     # Work our way through the tables
@@ -274,27 +275,26 @@ sub get_tagfields {
 
         my $is_attrib = m/^(sql|comments|action|extra)$/ ? 0 : 1;
 
-        my $attrib_path = "[EMAIL PROTECTED]";
+        my $attrib_path = "[EMAIL PROTECTED]";
         my $tag_path    = "$thisns$_";
-        if ( $xp->exists($attrib_path,$node) ) {
-            $data{$_} = "".$xp->findvalue($attrib_path,$node);
+        if ( my $found = $xp->find($attrib_path,$node) ) {
+            $data{$_} = "".$found->to_literal;
             warn "Use of '$_' as an attribute is depricated."
                 ." Use a child tag instead."
                 ." To convert your file to the new version see the Docs.\n"
                 unless $is_attrib;
             debug "Got $_=".( defined $data{ $_ } ? $data{ $_ } : 'UNDEF' );
         }
-        elsif ( $xp->exists($tag_path,$node) ) {
+        elsif ( $found = $xp->find($tag_path,$node) ) {
             if ($_ eq "extra") {
                 my %extra;
-                my $extra_nodes = $xp->find($tag_path,$node);
-                foreach ( $extra_nodes->pop->getAttributes ) {
+                foreach ( $found->pop->getAttributes ) {
                     $extra{$_->getName} = $_->getData;
                 }
                 $data{$_} = \%extra;
             }
             else {
-                $data{$_} = "".$xp->findvalue($tag_path,$node);
+                $data{$_} = "".$found->to_literal;
             }
             warn "Use of '$_' as a child tag is depricated."
                 ." Use an attribute instead."

Reply via email to