LibXML misbehaving with default namespace

Emmanuel Rodriguez <[email protected]>
Newsgroups gmane.comp.lang.perl.xml
Message-ID <[email protected]>
Hi,

I've encountered a strange behavior from XML::LibXML when parsing a 
default namespace. I made a small proof-of-concept script that can 
demonstrate the problem. Sample script:

#!/usr/bin/perl

use strict;
use warnings;

use XML::LibXML qw(:all);
use Data::Dumper;

# Which libxml?   
printf "libxml compiled version %s\n", XML::LibXML::LIBXML_VERSION;
printf "libxml runtime  version %s\n", XML::LibXML::LIBXML_RUNTIME_VERSION;
printf "libxml version %s\n", XML::LibXML::LIBXML_DOTTED_VERSION;
print "XML::LibXML version $XML::LibXML::VERSION\n";

my $parser = XML::LibXML->new();
my $document = $parser->parse_string('<html 
xmlns="http://www.w3.org/1999/xhtml"/>');

# Print the namespaces
my ($namespace) = $document->documentElement->getNamespaces;
foreach my $namespace ($document->documentElement->getNamespaces) {
    my $uri = $namespace->getNamespaceURI;
    my $prefix = $namespace->getPrefix || 'undef';
    print "$prefix => $uri\n";
}

The output of this script differers based on the version of 
LibXML/libxml installed. At home I have the following results:
    libxml compiled version 20630
    libxml runtime  version 20631
    libxml version 2.6.30
    XML::LibXML version 1.63
    undef => http://www.w3.org/1999/xhtml

And at work I get:
    libxml compiled version 20627
    libxml runtime  version 20631
    libxml version 2.6.27
    XML::LibXML version 1.66
    xmlns => http://www.w3.org/2000/xmlns/

Anyone noticed this?

Emmanuel Rodriguez

_______________________________________________
Perl-XML mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.