Hello community, here is the log from the commit of package perl-XML-LibXML for openSUSE:Factory checked in at 2012-02-28 14:14:43 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/perl-XML-LibXML (Old) and /work/SRC/openSUSE:Factory/.perl-XML-LibXML.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-XML-LibXML", Maintainer is "[email protected]" Changes: -------- --- /work/SRC/openSUSE:Factory/perl-XML-LibXML/perl-XML-LibXML.changes 2012-02-14 11:26:09.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.perl-XML-LibXML.new/perl-XML-LibXML.changes 2012-02-28 14:14:46.000000000 +0100 @@ -1,0 +2,20 @@ +Wed Feb 22 02:34:38 UTC 2012 - [email protected] + +- update to 1.92 + - Fix for test failure on perls < 5.10. + - Fixes https://rt.cpan.org/Public/Bug/Display.html?id=75195 + - Thanks to Paul for the report, and for a patch that was not + accepted. +1.91 Tue Feb 21 13:57:54 IST 2012 + - Overload hash dereferencing on XML::LibXML::Elements, to provide + access to the element's attributes. + - See XML::LibXML::AttributeHash for details. + - Thanks to Toby Inkster. + - Pull some commits from Toby Inkster to add more convenient methods + to XML::LibXML::NodeList such as sort, map, grep, etc. + - https://bitbucket.org/shlomif/perl-xml-libxml/pull-request/11/xml-libxml-nodelist-improvements + - Thanks, Toby! + - Printed some warnings regardless if DEBUG is on. + - Thanks to http://search.cpan.org/~mstrout/ for the suggestion. + +------------------------------------------------------------------- Old: ---- XML-LibXML-1.90.tar.gz New: ---- XML-LibXML-1.92.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ perl-XML-LibXML.spec ++++++ --- /var/tmp/diff_new_pack.cnQAXa/_old 2012-02-28 14:14:52.000000000 +0100 +++ /var/tmp/diff_new_pack.cnQAXa/_new 2012-02-28 14:14:52.000000000 +0100 @@ -16,20 +16,21 @@ # + Name: perl-XML-LibXML -Version: 1.90 +Version: 1.92 Release: 0 +License: GPL-1.0+ or Artistic-1.0 %define cpan_name XML-LibXML Summary: Perl Binding for libxml2 -License: GPL-1.0+ or Artistic-1.0 -Group: Development/Libraries/Perl Url: http://search.cpan.org/dist/XML-LibXML/ +Group: Development/Libraries/Perl Source: http://www.cpan.org/authors/id/S/SH/SHLOMIF/%{cpan_name}-%{version}.tar.gz BuildRequires: perl -BuildRequires: perl-macros BuildRequires: perl(ExtUtils::MakeMaker) >= 6.56 BuildRequires: perl(XML::NamespaceSupport) >= 1.07 BuildRequires: perl(XML::SAX) >= 0.11 +BuildRequires: perl-macros BuildRequires: pkgconfig(libxml-2.0) >= 2.6.16 Requires: perl(XML::NamespaceSupport) >= 1.07 Requires: perl(XML::SAX) >= 0.11 ++++++ XML-LibXML-1.90.tar.gz -> XML-LibXML-1.92.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/Changes new/XML-LibXML-1.92/Changes --- old/XML-LibXML-1.90/Changes 2012-01-08 19:58:34.000000000 +0100 +++ new/XML-LibXML-1.92/Changes 2012-02-21 18:00:54.000000000 +0100 @@ -1,5 +1,23 @@ Revision history for Perl extension XML::LibXML +1.92 Tue Feb 21 19:00:48 IST 2012 + - Fix for test failure on perls < 5.10. + - Fixes https://rt.cpan.org/Public/Bug/Display.html?id=75195 + - Thanks to Paul for the report, and for a patch that was not + accepted. + +1.91 Tue Feb 21 13:57:54 IST 2012 + - Overload hash dereferencing on XML::LibXML::Elements, to provide + access to the element's attributes. + - See XML::LibXML::AttributeHash for details. + - Thanks to Toby Inkster. + - Pull some commits from Toby Inkster to add more convenient methods + to XML::LibXML::NodeList such as sort, map, grep, etc. + - https://bitbucket.org/shlomif/perl-xml-libxml/pull-request/11/xml-libxml-nodelist-improvements + - Thanks, Toby! + - Printed some warnings regardless if DEBUG is on. + - Thanks to http://search.cpan.org/~mstrout/ for the suggestion. + 1.90 Sun Jan 8 20:57:58 IST 2012 - Pull a commit from Aaron Crange to fix compilation bugs in Devel.xs: - local variable declarations must be in the PREINIT section, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/LibXML.pm new/XML-LibXML-1.92/LibXML.pm --- old/XML-LibXML-1.90/LibXML.pm 2012-01-08 19:56:33.000000000 +0100 +++ new/XML-LibXML-1.92/LibXML.pm 2012-02-21 18:01:18.000000000 +0100 @@ -27,7 +27,7 @@ use IO::Handle; # for FH reads called as methods BEGIN { -$VERSION = "1.90"; # VERSION TEMPLATE: DO NOT CHANGE +$VERSION = "1.92"; # VERSION TEMPLATE: DO NOT CHANGE $ABI_VERSION = 2; require Exporter; require DynaLoader; @@ -1485,8 +1485,57 @@ use vars qw(@ISA); @ISA = ('XML::LibXML::Node'); use XML::LibXML qw(:ns :libxml); +use XML::LibXML::AttributeHash; use Carp; +use overload + '%{}' => 'getAttributeHash', + 'bool' => sub { 1 }, + ; + +{ + # Note that we could generate a new hashref each time this + # is called. However, that breaks "each %$element" and + # "keys %$element". So instead we consistently return the + # same reference to the same (tied) hash. To do that, we + # need to use a fieldhash. Hash::FieldHash requires at least + # Perl 5.8, but XML-LibXML already dropped support for older + # Perls since XML-LibXML-1.77. + # + # If Hash::FieldHash isn't available we can sort of do the + # same thing by relying upon the stringification of non-scalar + # hash keys, and performing a bit of cleanup in DESTROY. + # + my %tiecache; + BEGIN + { + if (eval { require Hash::FieldHash; 1 }) + { + Hash::FieldHash::fieldhashes(\%tiecache); + *__destroy_tiecache = sub {}; + } + else + { + *__destroy_tiecache = sub { delete $tiecache{ $_[0] } }; + } + }; + sub getAttributeHash + { + my $self = shift; + if (!exists $tiecache{ $self }) { + tie my %attr, 'XML::LibXML::AttributeHash', $self, weaken => 1; + $tiecache{ $self } = \%attr; + } + return $tiecache{ $self }; + } + sub DESTROY + { + my ($self) = @_; + $self->__destroy_tiecache; + $self->SUPER::DESTROY; + } +} + sub setNamespace { my $self = shift; my $n = $self->nodeName; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/LibXML.pod new/XML-LibXML-1.92/LibXML.pod --- old/XML-LibXML-1.90/LibXML.pod 2012-01-08 19:57:10.000000000 +0100 +++ new/XML-LibXML-1.92/LibXML.pod 2012-02-21 18:01:32.000000000 +0100 @@ -505,7 +505,7 @@ =head1 VERSION -1.90 +1.92 =head1 COPYRIGHT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/MANIFEST new/XML-LibXML-1.92/MANIFEST --- old/XML-LibXML-1.90/MANIFEST 2012-01-08 20:00:13.000000000 +0100 +++ new/XML-LibXML-1.92/MANIFEST 2012-02-21 18:02:53.000000000 +0100 @@ -54,6 +54,7 @@ example/yahoo-finance-html-with-errors.html HACKING.txt lib/XML/LibXML/Attr.pod +lib/XML/LibXML/AttributeHash.pm lib/XML/LibXML/Boolean.pm lib/XML/LibXML/CDATASection.pod lib/XML/LibXML/Comment.pod @@ -158,6 +159,8 @@ t/60error_prev_chain.t t/60struct_error.t t/61error.t +t/71overloads.t +t/72destruction.t t/80registryleak.t t/90threads.t t/data/callbacks_returning_undef.xml diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/META.json new/XML-LibXML-1.92/META.json --- old/XML-LibXML-1.90/META.json 2012-01-08 20:00:13.000000000 +0100 +++ new/XML-LibXML-1.92/META.json 2012-02-21 18:02:53.000000000 +0100 @@ -67,5 +67,5 @@ "url" : "https://bitbucket.org/shlomif/perl-xml-libxml" } }, - "version" : "1.90" + "version" : "1.92" } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/META.yml new/XML-LibXML-1.92/META.yml --- old/XML-LibXML-1.90/META.yml 2012-01-08 20:00:13.000000000 +0100 +++ new/XML-LibXML-1.92/META.yml 2012-02-21 18:02:53.000000000 +0100 @@ -45,4 +45,4 @@ resources: homepage: https://bitbucket.org/shlomif/perl-xml-libxml repository: https://bitbucket.org/shlomif/perl-xml-libxml -version: 1.90 +version: 1.92 diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/Makefile.PL new/XML-LibXML-1.92/Makefile.PL --- old/XML-LibXML-1.90/Makefile.PL 2012-01-08 19:57:10.000000000 +0100 +++ new/XML-LibXML-1.92/Makefile.PL 2012-02-21 18:01:33.000000000 +0100 @@ -40,6 +40,7 @@ 'PREREQ_PM' => { 'base' => 0, 'ExtUtils::MakeMaker' => '6.56', + #'Hash::FieldHash' => '0.09', 'strict' => 0, 'Test::More' => 0, 'vars' => 0, @@ -201,7 +202,7 @@ } if ( $@ =~ /^UNTESTED (\S*)/ ) { warn "Note: libxml2 $1 was not tested with this XML::LibXML version.\n" -# warn <<UNTESTED; +# warn <<"UNTESTED"; # WARNING! # The installed version of libxml2 was not tested with this version of XML::LibXML. @@ -214,10 +215,10 @@ } if ( not defined $config{LIBS} and not defined $config{INC} ) { - warn "\nusing fallback values for LIBS and INC\n"; + warn "didn't manage to get libxml2 config, guessing\n"; $config{LIBS} = '-L/usr/local/lib -L/usr/lib -lxml2 -lm'; $config{INC} = '-I/usr/local/include -I/usr/include'; - print <<OPT; + print <<"OPT"; options: LIBS='$config{LIBS}' INC='$config{INC}' @@ -247,7 +248,7 @@ [0,7,2,0], [0,7,3,1], ); - print <<GDOME; + print <<"GDOME"; GDOME Support (experimental): XML::LibXML can parse into XML::GDOME DOMs if libgdome is installed. @@ -325,7 +326,7 @@ # -------------------------------------------------------------------------- # # test if the libraries are really installed! unless (have_library("xml2") or have_library("libxml2")) { - print STDERR <<DEATH; + print STDERR <<"DEATH"; libxml2, zlib, and/or the Math library (-lm) have not been found. Try setting LIBS and INC values on the command line Or get libxml2 from @@ -363,7 +364,7 @@ my $str = shift->SUPER::manifypods(@_); # warn $str; # $str =~ s/^manifypods : pure_all (.*)$/manifypods : pure_all docs $1/m; - $str .= <<EOF; + $str .= <<"EOF"; docs-fast : \t\@$^X -pi~ -e 's{<edition>[0-9.]*</edition>}{<edition>'"\$(VERSION)"'</edition>}' docs/libxml.dbk @@ -488,11 +489,11 @@ } sub xsystem { - my $command = shift; + my $command_aref = shift; if ($DEBUG) { - print $command, "\n"; - if (system($command) != 0) { - die "system call to '$command' failed"; + print "@$command_aref\n"; + if ((system { $command_aref->[0] } @$command_aref) != 0) { + die "system call to '@$command_aref' failed"; } return 1; } @@ -500,11 +501,11 @@ open(OLDERR, ">&STDERR"); open(STDOUT, ">$DEVNULL"); open(STDERR, ">$DEVNULL"); - my $retval = system($command); + my $retval = (system { $command_aref->[0] } @$command_aref); open(STDOUT, ">&OLDOUT"); open(STDERR, ">&OLDERR"); if ($retval != 0) { - die "system call to '$command' failed"; + die "system call to '@$command_aref' failed"; } return 1; } @@ -547,7 +548,7 @@ { open(my $cfile, '>', 'Conftest.xs') or die "Cannot write to file Conftest.xs: $!"; - print {$cfile} <<EOT; + print {$cfile} <<"EOT"; #ifdef __cplusplus extern "C" { #endif @@ -560,7 +561,7 @@ EOT print {$cfile} $src; - print {$cfile} <<EOT; + print {$cfile} <<"EOT"; MODULE = Conftest PACKAGE = Conftest @@ -600,23 +601,24 @@ { open(my $cfile, ">test.pl") or die "Cannot write to file test.pl: $!"; - print {$cfile} <<EOT; + print {$cfile} <<"EOT"; use Test; BEGIN { plan tests => 1; } END { ok(\$loaded) } use Conftest; \$loaded++; EOT close($cfile); } my $quote = $is_Win32 ? '"' : "'"; - xsystem("$^X Makefile.PL " - . join(' ', map { "${quote}$_=$config{$_}${quote}" } keys %config) + xsystem([$^X, 'Makefile.PL', + (map { "$_=$config{$_}" } keys %config), + ] ); my $def_opt = defined($opt) ? $opt : ''; - # I am not shure if OTHERLDFLAGS is really required - at least the + # I am not sure if OTHERLDFLAGS is really required - at least the # libraries to include do not belong here! # I would assume a user to set OTHERLDFLAGS in the %config if they are # really required. if done so, we don't have to pass them here ... - xsystem("$Config{make} test ${quote}OTHERLDFLAGS=${def_opt}${quote}"); + xsystem([$Config{make}, 'test', "OTHERLDFLAGS=${def_opt}"]); } # end try_link0 sub try_link { @@ -624,7 +626,7 @@ my $result = eval { try_link0(@_); }; - warn $@ if $DEBUG && $@; + warn $@ if $@; chdir($start_dir); rm_fr(".testlink"); return $result; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/docs/libxml.dbk new/XML-LibXML-1.92/docs/libxml.dbk --- old/XML-LibXML-1.90/docs/libxml.dbk 2012-01-08 19:57:10.000000000 +0100 +++ new/XML-LibXML-1.92/docs/libxml.dbk 2012-02-21 18:01:32.000000000 +0100 @@ -22,7 +22,7 @@ </authorgroup> - <edition>1.90</edition> + <edition>1.92</edition> <copyright> <year>2001-2007</year> <holder>AxKit.com Ltd</holder> @@ -4559,6 +4559,18 @@ </variablelist> </sect1> + <sect1> + <title>Overloading</title> + <para>XML::LibXML::Element overloads hash dereferencing to + provide access to the element's attributes. For non-namespaced + attributes, the attribute name is the hash key, and the attribute + value is the hash value. For namespaced attributes, the hash key + is qualified with the namespace URI, using Clark notation.</para> + <para>Perl's "tied hash" feature is used, which means that the + hash gives you read-write access to the element's attributes. + For more information, see <olink targetdoc="XML::LibXML::AttributeHash" + >XML::LibXML::AttributeHash</olink></para> + </sect1> </chapter> <chapter id="XML-LibXML-Text"> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/dom.c new/XML-LibXML-1.92/dom.c --- old/XML-LibXML-1.90/dom.c 2011-08-08 17:59:02.000000000 +0200 +++ new/XML-LibXML-1.92/dom.c 2012-02-20 19:38:14.000000000 +0100 @@ -329,7 +329,7 @@ * * this function is pretty neat, since you can read in well balanced * strings and get a list of nodes, which can be added to any other node. - * (shure - this should return a doucment_fragment, but still it doesn't) + * (sure - this should return a doucment_fragment, but still it doesn't) * * the code is pretty heavy i think, but deep in my heard i believe it's * worth it :) (e.g. if you like to read a chunk of well-balanced code diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/Attr.pod new/XML-LibXML-1.92/lib/XML/LibXML/Attr.pod --- old/XML-LibXML-1.90/lib/XML/LibXML/Attr.pod 2012-01-08 19:57:10.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/Attr.pod 2012-02-21 18:01:32.000000000 +0100 @@ -121,7 +121,7 @@ =head1 VERSION -1.90 +1.92 =head1 COPYRIGHT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/AttributeHash.pm new/XML-LibXML-1.92/lib/XML/LibXML/AttributeHash.pm --- old/XML-LibXML-1.90/lib/XML/LibXML/AttributeHash.pm 1970-01-01 01:00:00.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/AttributeHash.pm 2012-02-21 18:01:18.000000000 +0100 @@ -0,0 +1,215 @@ +package XML::LibXML::AttributeHash; + +use strict; +use warnings; +use Scalar::Util qw//; +use Tie::Hash; +our @ISA = qw/Tie::Hash/; + +use vars qw($VERSION); +$VERSION = "1.92"; # VERSION TEMPLATE: DO NOT CHANGE + +BEGIN +{ + *__HAS_WEAKEN = defined(&Scalar::Util::weaken) + ? sub () { 1 } + : sub () { 0 }; +}; + +sub element +{ + return $_[0][0]; +} + +sub from_clark +{ + my ($self, $str) = @_; + if ($str =~ m! \{ (.+) \} (.+) !x) + { + return ($1, $2); + } + return (undef, $str); +} + +sub to_clark +{ + my ($self, $ns, $local) = @_; + defined $ns ? "{$ns}$local" : $local; +} + +sub all_keys +{ + my ($self, @keys) = @_; + + my $elem = $self->element; + + foreach my $attr (defined($elem) ? $elem->attributes : ()) + { + if (! $attr->isa('XML::LibXML::Namespace')) + { + push @keys, $self->to_clark($attr->namespaceURI, $attr->localname); + } + } + + return sort @keys; +} + +sub TIEHASH +{ + my ($class, $element, %args) = @_; + my $self = bless [$element, undef, \%args], $class; + if (__HAS_WEAKEN and $args{weaken}) + { + Scalar::Util::weaken( $self->[0] ); + } + return $self; +} + +sub STORE +{ + my ($self, $key, $value) = @_; + my ($key_ns, $key_local) = $self->from_clark($key); + if (defined $key_ns) + { + return $self->element->setAttributeNS($key_ns, "xxx:$key_local", "$value"); + } + else + { + return $self->element->setAttribute($key_local, "$value"); + } +} + +sub FETCH +{ + my ($self, $key) = @_; + my ($key_ns, $key_local) = $self->from_clark($key); + if (defined $key_ns) + { + return $self->element->getAttributeNS($key_ns, "$key_local"); + } + else + { + return $self->element->getAttribute($key_local); + } +} + +sub EXISTS +{ + my ($self, $key) = @_; + my ($key_ns, $key_local) = $self->from_clark($key); + if (defined $key_ns) + { + return $self->element->hasAttributeNS($key_ns, "$key_local"); + } + else + { + return $self->element->hasAttribute($key_local); + } +} + +sub DELETE +{ + my ($self, $key) = @_; + my ($key_ns, $key_local) = $self->from_clark($key); + if (defined $key_ns) + { + return $self->element->removeAttributeNS($key_ns, "$key_local"); + } + else + { + return $self->element->removeAttribute($key_local); + } +} + +sub FIRSTKEY +{ + my ($self) = @_; + my @keys = $self->all_keys; + $self->[1] = \@keys; + if (wantarray) + { + return ($keys[0], $self->FETCH($keys[0])); + } + $keys[0]; +} + +sub NEXTKEY +{ + my ($self, $lastkey) = @_; + my @keys = defined $self->[1] ? @{ $self->[1] } : $self->all_keys; + my $found; + foreach my $k (@keys) + { + if ($k gt $lastkey) + { + $found = $k and last; + } + } + if (!defined $found) + { + $self->[1] = undef; + return; + } + if (wantarray) + { + return ($found, $self->FETCH($found)); + } + return $found; +} + +sub SCALAR +{ + my ($self) = @_; + return $self->element; +} + +sub CLEAR +{ + my ($self) = @_; + foreach my $k ($self->all_keys) + { + $self->DELETE($k); + } + return $self; +} + +__PACKAGE__ +__END__ + +=head1 NAME + +XML::LibXML::AttributeHash - tie an XML::LibXML::Element to a hash to access its attributes + +=head1 SYNOPSIS + + tie my %hash, 'XML::LibXML::AttributeHash', $element; + $hash{'href'} = 'http://example.com/'; + print $element->getAttribute('href') . "\n"; + +=head1 DESCRIPTION + +This class allows an element's attributes to be accessed as if they were a +plain old Perl hash. Attribute names become hash keys. Namespaced attributes +are keyed using Clark notation. + + my $XLINK = 'http://www.w3.org/1999/xlink'; + tie my %hash, 'XML::LibXML::AttributeHash', $element; + $hash{"{$XLINK}href"} = 'http://localhost/'; + print $element->getAttributeNS($XLINK, 'href') . "\n"; + +There is rarely any need to use XML::LibXML::AttributeHash directly. In +general, it is possible to take advantage of XML::LibXML::Element's +overloading. The example in the SYNOPSIS could have been written: + + $element->{'href'} = 'http://example.com/'; + print $element->getAttribute('href') . "\n"; + +The tie interface allows the passing of additional arguments to +XML::LibXML::AttributeHash: + + tie my %hash, 'XML::LibXML::AttributeHash', $element, %args; + +Currently only one argument is supported, the boolean "weaken" which (if +true) indicates that the tied object's reference to the element should be +a weak reference. This is used by XML::LibXML::Element's overloading. The +"weaken" argument is ignored if you don't have a working Scalar::Util::weaken. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/Boolean.pm new/XML-LibXML-1.92/lib/XML/LibXML/Boolean.pm --- old/XML-LibXML-1.90/lib/XML/LibXML/Boolean.pm 2012-01-08 19:56:33.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/Boolean.pm 2012-02-21 18:01:18.000000000 +0100 @@ -15,7 +15,7 @@ use vars qw ($VERSION); -$VERSION = "1.90"; # VERSION TEMPLATE: DO NOT CHANGE +$VERSION = "1.92"; # VERSION TEMPLATE: DO NOT CHANGE use overload '""' => \&value, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/CDATASection.pod new/XML-LibXML-1.92/lib/XML/LibXML/CDATASection.pod --- old/XML-LibXML-1.90/lib/XML/LibXML/CDATASection.pod 2012-01-08 19:57:10.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/CDATASection.pod 2012-02-21 18:01:32.000000000 +0100 @@ -45,7 +45,7 @@ =head1 VERSION -1.90 +1.92 =head1 COPYRIGHT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/Comment.pod new/XML-LibXML-1.92/lib/XML/LibXML/Comment.pod --- old/XML-LibXML-1.90/lib/XML/LibXML/Comment.pod 2012-01-08 19:57:10.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/Comment.pod 2012-02-21 18:01:32.000000000 +0100 @@ -46,7 +46,7 @@ =head1 VERSION -1.90 +1.92 =head1 COPYRIGHT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/Common.pm new/XML-LibXML-1.92/lib/XML/LibXML/Common.pm --- old/XML-LibXML-1.90/lib/XML/LibXML/Common.pm 2012-01-08 19:56:33.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/Common.pm 2012-02-21 18:01:18.000000000 +0100 @@ -23,7 +23,7 @@ @ISA = qw(Exporter); -$VERSION = "1.90"; # VERSION TEMPLATE: DO NOT CHANGE +$VERSION = "1.92"; # VERSION TEMPLATE: DO NOT CHANGE use XML::LibXML qw(:libxml); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/Common.pod new/XML-LibXML-1.92/lib/XML/LibXML/Common.pod --- old/XML-LibXML-1.90/lib/XML/LibXML/Common.pod 2012-01-08 19:57:10.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/Common.pod 2012-02-21 18:01:33.000000000 +0100 @@ -116,7 +116,7 @@ =head1 VERSION -1.90 +1.92 =head1 COPYRIGHT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/DOM.pod new/XML-LibXML-1.92/lib/XML/LibXML/DOM.pod --- old/XML-LibXML-1.90/lib/XML/LibXML/DOM.pod 2012-01-08 19:57:10.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/DOM.pod 2012-02-21 18:01:32.000000000 +0100 @@ -129,7 +129,7 @@ =head1 VERSION -1.90 +1.92 =head1 COPYRIGHT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/Devel.pm new/XML-LibXML-1.92/lib/XML/LibXML/Devel.pm --- old/XML-LibXML-1.90/lib/XML/LibXML/Devel.pm 2012-01-08 19:56:33.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/Devel.pm 2012-02-21 18:01:18.000000000 +0100 @@ -12,7 +12,7 @@ use XML::LibXML; use vars qw ($VERSION); -$VERSION = "1.90"; # VERSION TEMPLATE: DO NOT CHANGE +$VERSION = "1.92"; # VERSION TEMPLATE: DO NOT CHANGE use 5.008_000; @@ -46,10 +46,13 @@ =head1 SYNOPSIS - // C functions + /********************************************** + * C functions you want to access + */ xmlNode *return_node(); void receive_node(xmlNode *); + ############################################### # XS Code void * xs_return_node @@ -64,6 +67,7 @@ CODE: receive_node(n); + ############################################### # Perl code use XML::LibXML::Devel; @@ -92,14 +96,15 @@ To XS a library that uses libxml2 nodes the first step is to do this so that xmlNodePtr is passed as void *. These raw nodes -are then turned into libxml nodes by using this Devel functions. +are then turned into libxml nodes by using this C<Devel> functions. -Be aware that this is currently rather experimental. The function +Be aware that this module is currently rather experimental. The function names may change if I XS more functions and introduce a reasonable naming convention. -Be also aware that this is a great tool to cause segfaults and -introduce memory leaks. +Be also aware that this module is a great tool to cause segfaults and +introduce memory leaks. It does however provide a partial cure by making +C<xmlMemUsed> available as C<mem_used>. =head1 FUNCTIONS diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/Document.pod new/XML-LibXML-1.92/lib/XML/LibXML/Document.pod --- old/XML-LibXML-1.90/lib/XML/LibXML/Document.pod 2012-01-08 19:57:10.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/Document.pod 2012-02-21 18:01:32.000000000 +0100 @@ -683,7 +683,7 @@ =head1 VERSION -1.90 +1.92 =head1 COPYRIGHT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/DocumentFragment.pod new/XML-LibXML-1.92/lib/XML/LibXML/DocumentFragment.pod --- old/XML-LibXML-1.90/lib/XML/LibXML/DocumentFragment.pod 2012-01-08 19:57:10.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/DocumentFragment.pod 2012-02-21 18:01:32.000000000 +0100 @@ -27,7 +27,7 @@ =head1 VERSION -1.90 +1.92 =head1 COPYRIGHT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/Dtd.pod new/XML-LibXML-1.92/lib/XML/LibXML/Dtd.pod --- old/XML-LibXML-1.90/lib/XML/LibXML/Dtd.pod 2012-01-08 19:57:10.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/Dtd.pod 2012-02-21 18:01:32.000000000 +0100 @@ -89,7 +89,7 @@ =head1 VERSION -1.90 +1.92 =head1 COPYRIGHT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/Element.pod new/XML-LibXML-1.92/lib/XML/LibXML/Element.pod --- old/XML-LibXML-1.90/lib/XML/LibXML/Element.pod 2012-01-08 19:57:10.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/Element.pod 2012-02-21 18:01:32.000000000 +0100 @@ -362,6 +362,17 @@ =back + +=head1 OVERLOADING + +XML::LibXML::Element overloads hash dereferencing to provide access to the +element's attributes. For non-namespaced attributes, the attribute name is the +hash key, and the attribute value is the hash value. For namespaced attributes, +the hash key is qualified with the namespace URI, using Clark notation. + +Perl's "tied hash" feature is used, which means that the hash gives you +read-write access to the element's attributes. For more information, see L<<<<<< XML::LibXML::AttributeHash >>>>>> + =head1 AUTHORS Matt Sergeant, @@ -371,7 +382,7 @@ =head1 VERSION -1.90 +1.92 =head1 COPYRIGHT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/ErrNo.pm new/XML-LibXML-1.92/lib/XML/LibXML/ErrNo.pm --- old/XML-LibXML-1.90/lib/XML/LibXML/ErrNo.pm 2012-01-08 19:56:33.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/ErrNo.pm 2012-02-21 18:01:18.000000000 +0100 @@ -13,7 +13,7 @@ use strict; use vars qw($VERSION); -$VERSION = "1.90"; # VERSION TEMPLATE: DO NOT CHANGE +$VERSION = "1.92"; # VERSION TEMPLATE: DO NOT CHANGE use constant ERR_OK => 0; use constant ERR_INTERNAL_ERROR => 1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/ErrNo.pod new/XML-LibXML-1.92/lib/XML/LibXML/ErrNo.pod --- old/XML-LibXML-1.90/lib/XML/LibXML/ErrNo.pod 2012-01-08 19:57:10.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/ErrNo.pod 2012-02-21 18:01:33.000000000 +0100 @@ -14,7 +14,7 @@ =head1 VERSION -1.90 +1.92 =head1 COPYRIGHT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/Error.pm new/XML-LibXML-1.92/lib/XML/LibXML/Error.pm --- old/XML-LibXML-1.90/lib/XML/LibXML/Error.pm 2012-01-08 19:56:33.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/Error.pm 2012-02-21 18:01:18.000000000 +0100 @@ -29,7 +29,7 @@ fallback => 1; $WARNINGS = 0; # 0: supress, 1: report via warn, 2: report via die -$VERSION = "1.90"; # VERSION TEMPLATE: DO NOT CHANGE +$VERSION = "1.92"; # VERSION TEMPLATE: DO NOT CHANGE use constant XML_ERR_NONE => 0; use constant XML_ERR_WARNING => 1; # A simple warning diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/Error.pod new/XML-LibXML-1.92/lib/XML/LibXML/Error.pod --- old/XML-LibXML-1.90/lib/XML/LibXML/Error.pod 2012-01-08 19:57:10.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/Error.pod 2012-02-21 18:01:33.000000000 +0100 @@ -244,7 +244,7 @@ =head1 VERSION -1.90 +1.92 =head1 COPYRIGHT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/InputCallback.pod new/XML-LibXML-1.92/lib/XML/LibXML/InputCallback.pod --- old/XML-LibXML-1.90/lib/XML/LibXML/InputCallback.pod 2012-01-08 19:57:10.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/InputCallback.pod 2012-02-21 18:01:32.000000000 +0100 @@ -280,7 +280,7 @@ =head1 VERSION -1.90 +1.92 =head1 COPYRIGHT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/Literal.pm new/XML-LibXML-1.92/lib/XML/LibXML/Literal.pm --- old/XML-LibXML-1.90/lib/XML/LibXML/Literal.pm 2012-01-08 19:56:33.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/Literal.pm 2012-02-21 18:01:18.000000000 +0100 @@ -13,7 +13,7 @@ use strict; use vars qw ($VERSION); -$VERSION = "1.90"; # VERSION TEMPLATE: DO NOT CHANGE +$VERSION = "1.92"; # VERSION TEMPLATE: DO NOT CHANGE use overload '""' => \&value, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/Namespace.pod new/XML-LibXML-1.92/lib/XML/LibXML/Namespace.pod --- old/XML-LibXML-1.90/lib/XML/LibXML/Namespace.pod 2012-01-08 19:57:10.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/Namespace.pod 2012-02-21 18:01:32.000000000 +0100 @@ -130,7 +130,7 @@ =head1 VERSION -1.90 +1.92 =head1 COPYRIGHT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/Node.pod new/XML-LibXML-1.92/lib/XML/LibXML/Node.pod --- old/XML-LibXML-1.90/lib/XML/LibXML/Node.pod 2012-01-08 19:57:10.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/Node.pod 2012-02-21 18:01:32.000000000 +0100 @@ -739,7 +739,7 @@ =head1 VERSION -1.90 +1.92 =head1 COPYRIGHT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/NodeList.pm new/XML-LibXML-1.92/lib/XML/LibXML/NodeList.pm --- old/XML-LibXML-1.90/lib/XML/LibXML/NodeList.pm 2012-01-08 19:56:33.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/NodeList.pm 2012-02-21 18:01:18.000000000 +0100 @@ -17,7 +17,7 @@ use XML::LibXML::Number; use vars qw($VERSION); -$VERSION = "1.90"; # VERSION TEMPLATE: DO NOT CHANGE +$VERSION = "1.92"; # VERSION TEMPLATE: DO NOT CHANGE use overload '""' => \&to_literal, @@ -105,7 +105,7 @@ sub to_literal { my $self = CORE::shift; return XML::LibXML::Literal->new( - join('', grep {defined $_} map { $_->string_value } @$self) + join('', CORE::grep {defined $_} CORE::map { $_->string_value } @$self) ); } @@ -121,6 +121,88 @@ return undef; } +sub map { + my $self = CORE::shift; + my $sub = __is_code(CORE::shift); + local $_; + my @results = CORE::map { @{[ $sub->($_) ]} } @$self; + return unless defined wantarray; + return wantarray ? @results : (ref $self)->new(@results); +} + +sub grep { + my $self = CORE::shift; + my $sub = __is_code(CORE::shift); + local $_; + my @results = CORE::grep { $sub->($_) } @$self; + return unless defined wantarray; + return wantarray ? @results : (ref $self)->new(@results); +} + +sub sort { + my $self = CORE::shift; + my $sub = __is_code(CORE::shift); + my @results = CORE::sort { $sub->($a,$b) } @$self; + return wantarray ? @results : (ref $self)->new(@results); +} + +sub foreach { + my $self = CORE::shift; + my $sub = CORE::shift; + + foreach my $item (@$self) + { + local $_ = $item; + $sub->($item); + } + + return wantarray ? @$self : $self; +} + +sub reverse { + my $self = CORE::shift; + my @results = CORE::reverse @$self; + return wantarray ? @results : (ref $self)->new(@results); +} + +sub reduce { + my $self = CORE::shift; + my $sub = __is_code(CORE::shift); + + my @list = @$self; + CORE::unshift @list, $_[0] if @_; + + my $a = CORE::shift(@list); + foreach my $b (@list) + { + $a = $sub->($a, $b); + } + return $a; +} + +sub __is_code { + my ($code) = @_; + + if (ref $code eq 'CODE') { + return $code; + } + + # There are better ways of doing this, but here I've tried to + # avoid adding any additional external dependencies. + # + if (UNIVERSAL::can($code, 'can') # is blessed (sort of) + and overload::Overloaded($code) # is overloaded + and overload::Method($code, '&{}')) { # overloads '&{}' + return $code; + } + + # The other possibility is that $code is a coderef, but is + # blessed into a class that doesn't overload '&{}'. In which + # case... well, I'm stumped! + + die "Not a subroutine reference\n"; +} + 1; __END__ @@ -143,7 +225,7 @@ =head1 API -=head2 new() +=head2 new(@nodes) You will almost never have to create a new NodeList object, as it is all done for you by XPath. @@ -196,4 +278,37 @@ Given a nodelist, prepends the list of nodes in $nodelist to the front of the current list. +=head2 map($coderef) + +Equivalent to perl's map function. + +=head2 grep($coderef) + +Equivalent to perl's grep function. + +=head2 sort($coderef) + +Equivalent to perl's sort function. + +Caveat: Perl's magic C<$a> and C<$b> variables are not available in +C<$coderef>. Instead the two terms are passed to the coderef as arguments. + +=head2 reverse() + +Equivalent to perl's reverse function. + +=head2 foreach($coderef) + +Inspired by perl's foreach loop. Executes the coderef on each item in +the list. Similar to C<map>, but instead of returning the list of values +returned by $coderef, returns the original NodeList. + +=head2 reduce($coderef, $init) + +Equivalent to List::Util's reduce function. C<$init> is optional and +provides an initial value for the reduction. + +Caveat: Perl's magic C<$a> and C<$b> variables are not available in +C<$coderef>. Instead the two terms are passed to the coderef as arguments. + =cut diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/Number.pm new/XML-LibXML-1.92/lib/XML/LibXML/Number.pm --- old/XML-LibXML-1.90/lib/XML/LibXML/Number.pm 2012-01-08 19:56:33.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/Number.pm 2012-02-21 18:01:18.000000000 +0100 @@ -13,7 +13,7 @@ use strict; use vars qw ($VERSION); -$VERSION = "1.90"; # VERSION TEMPLATE: DO NOT CHANGE +$VERSION = "1.92"; # VERSION TEMPLATE: DO NOT CHANGE use overload '""' => \&value, diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/PI.pod new/XML-LibXML-1.92/lib/XML/LibXML/PI.pod --- old/XML-LibXML-1.90/lib/XML/LibXML/PI.pod 2012-01-08 19:57:10.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/PI.pod 2012-02-21 18:01:32.000000000 +0100 @@ -74,7 +74,7 @@ =head1 VERSION -1.90 +1.92 =head1 COPYRIGHT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/Parser.pod new/XML-LibXML-1.92/lib/XML/LibXML/Parser.pod --- old/XML-LibXML-1.90/lib/XML/LibXML/Parser.pod 2012-01-08 19:57:10.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/Parser.pod 2012-02-21 18:01:32.000000000 +0100 @@ -969,7 +969,7 @@ =head1 VERSION -1.90 +1.92 =head1 COPYRIGHT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/Pattern.pod new/XML-LibXML-1.92/lib/XML/LibXML/Pattern.pod --- old/XML-LibXML-1.90/lib/XML/LibXML/Pattern.pod 2012-01-08 19:57:10.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/Pattern.pod 2012-02-21 18:01:33.000000000 +0100 @@ -94,7 +94,7 @@ =head1 VERSION -1.90 +1.92 =head1 COPYRIGHT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/Reader.pm new/XML-LibXML-1.92/lib/XML/LibXML/Reader.pm --- old/XML-LibXML-1.90/lib/XML/LibXML/Reader.pm 2012-01-08 19:56:33.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/Reader.pm 2012-02-21 18:01:18.000000000 +0100 @@ -14,7 +14,7 @@ use warnings; use vars qw ($VERSION); -$VERSION = "1.90"; # VERSION TEMPLATE: DO NOT CHANGE +$VERSION = "1.92"; # VERSION TEMPLATE: DO NOT CHANGE use 5.008_000; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/Reader.pod new/XML-LibXML-1.92/lib/XML/LibXML/Reader.pod --- old/XML-LibXML-1.90/lib/XML/LibXML/Reader.pod 2012-01-08 19:57:10.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/Reader.pod 2012-02-21 18:01:33.000000000 +0100 @@ -656,7 +656,7 @@ =head1 VERSION -1.90 +1.92 =head1 COPYRIGHT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/RegExp.pod new/XML-LibXML-1.92/lib/XML/LibXML/RegExp.pod --- old/XML-LibXML-1.90/lib/XML/LibXML/RegExp.pod 2012-01-08 19:57:10.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/RegExp.pod 2012-02-21 18:01:33.000000000 +0100 @@ -58,7 +58,7 @@ =head1 VERSION -1.90 +1.92 =head1 COPYRIGHT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/RelaxNG.pod new/XML-LibXML-1.92/lib/XML/LibXML/RelaxNG.pod --- old/XML-LibXML-1.90/lib/XML/LibXML/RelaxNG.pod 2012-01-08 19:57:10.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/RelaxNG.pod 2012-02-21 18:01:32.000000000 +0100 @@ -69,7 +69,7 @@ =head1 VERSION -1.90 +1.92 =head1 COPYRIGHT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/SAX/Builder.pm new/XML-LibXML-1.92/lib/XML/LibXML/SAX/Builder.pm --- old/XML-LibXML-1.90/lib/XML/LibXML/SAX/Builder.pm 2012-01-08 19:56:33.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/SAX/Builder.pm 2012-02-21 18:01:18.000000000 +0100 @@ -18,7 +18,7 @@ return $XML::LibXML::__threads_shared ? 0 : 1; } -$VERSION = "1.90"; # VERSION TEMPLATE: DO NOT CHANGE +$VERSION = "1.92"; # VERSION TEMPLATE: DO NOT CHANGE sub new { my $class = shift; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/SAX/Builder.pod new/XML-LibXML-1.92/lib/XML/LibXML/SAX/Builder.pod --- old/XML-LibXML-1.90/lib/XML/LibXML/SAX/Builder.pod 2012-01-08 19:57:10.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/SAX/Builder.pod 2012-02-21 18:01:32.000000000 +0100 @@ -38,7 +38,7 @@ =head1 VERSION -1.90 +1.92 =head1 COPYRIGHT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/SAX/Generator.pm new/XML-LibXML-1.92/lib/XML/LibXML/SAX/Generator.pm --- old/XML-LibXML-1.90/lib/XML/LibXML/SAX/Generator.pm 2012-01-08 19:56:33.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/SAX/Generator.pm 2012-02-21 18:01:18.000000000 +0100 @@ -14,7 +14,7 @@ use XML::LibXML; use vars qw ($VERSION); -$VERSION = "1.90"; # VERSION TEMPLATE: DO NOT CHANGE +$VERSION = "1.92"; # VERSION TEMPLATE: DO NOT CHANGE sub CLONE_SKIP { return $XML::LibXML::__threads_shared ? 0 : 1; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/SAX/Parser.pm new/XML-LibXML-1.92/lib/XML/LibXML/SAX/Parser.pm --- old/XML-LibXML-1.90/lib/XML/LibXML/SAX/Parser.pm 2012-01-08 19:56:33.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/SAX/Parser.pm 2012-02-21 18:01:18.000000000 +0100 @@ -17,7 +17,7 @@ use XML::SAX::Base; use XML::SAX::DocumentLocator; -$VERSION = "1.90"; # VERSION TEMPLATE: DO NOT CHANGE +$VERSION = "1.92"; # VERSION TEMPLATE: DO NOT CHANGE @ISA = ('XML::SAX::Base'); sub CLONE_SKIP { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/SAX.pm new/XML-LibXML-1.92/lib/XML/LibXML/SAX.pm --- old/XML-LibXML-1.90/lib/XML/LibXML/SAX.pm 2012-01-08 19:56:33.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/SAX.pm 2012-02-21 18:01:18.000000000 +0100 @@ -12,7 +12,7 @@ use strict; use vars qw($VERSION @ISA); -$VERSION = "1.90"; # VERSION TEMPLATE: DO NOT CHANGE +$VERSION = "1.92"; # VERSION TEMPLATE: DO NOT CHANGE use XML::LibXML; use XML::SAX::Base; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/SAX.pod new/XML-LibXML-1.92/lib/XML/LibXML/SAX.pod --- old/XML-LibXML-1.90/lib/XML/LibXML/SAX.pod 2012-01-08 19:57:10.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/SAX.pod 2012-02-21 18:01:32.000000000 +0100 @@ -47,7 +47,7 @@ =head1 VERSION -1.90 +1.92 =head1 COPYRIGHT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/Schema.pod new/XML-LibXML-1.92/lib/XML/LibXML/Schema.pod --- old/XML-LibXML-1.90/lib/XML/LibXML/Schema.pod 2012-01-08 19:57:10.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/Schema.pod 2012-02-21 18:01:32.000000000 +0100 @@ -65,7 +65,7 @@ =head1 VERSION -1.90 +1.92 =head1 COPYRIGHT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/Text.pod new/XML-LibXML-1.92/lib/XML/LibXML/Text.pod --- old/XML-LibXML-1.90/lib/XML/LibXML/Text.pod 2012-01-08 19:57:10.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/Text.pod 2012-02-21 18:01:32.000000000 +0100 @@ -170,7 +170,7 @@ =head1 VERSION -1.90 +1.92 =head1 COPYRIGHT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/XPathContext.pm new/XML-LibXML-1.92/lib/XML/LibXML/XPathContext.pm --- old/XML-LibXML-1.90/lib/XML/LibXML/XPathContext.pm 2012-01-08 19:56:33.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/XPathContext.pm 2012-02-21 18:01:18.000000000 +0100 @@ -16,7 +16,7 @@ use XML::LibXML; use XML::LibXML::NodeList; -$VERSION = "1.90"; # VERSION TEMPLATE: DO NOT CHANGE +$VERSION = "1.92"; # VERSION TEMPLATE: DO NOT CHANGE # should LibXML XPath data types be used for simple objects # when passing parameters to extension functions (default: no) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/XPathContext.pod new/XML-LibXML-1.92/lib/XML/LibXML/XPathContext.pod --- old/XML-LibXML-1.90/lib/XML/LibXML/XPathContext.pod 2012-01-08 19:57:10.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/XPathContext.pod 2012-02-21 18:01:32.000000000 +0100 @@ -359,7 +359,7 @@ =head1 VERSION -1.90 +1.92 =head1 COPYRIGHT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/lib/XML/LibXML/XPathExpression.pod new/XML-LibXML-1.92/lib/XML/LibXML/XPathExpression.pod --- old/XML-LibXML-1.90/lib/XML/LibXML/XPathExpression.pod 2012-01-08 19:57:10.000000000 +0100 +++ new/XML-LibXML-1.92/lib/XML/LibXML/XPathExpression.pod 2012-02-21 18:01:33.000000000 +0100 @@ -52,7 +52,7 @@ =head1 VERSION -1.90 +1.92 =head1 COPYRIGHT diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/perl-libxml-mm.h new/XML-LibXML-1.92/perl-libxml-mm.h --- old/XML-LibXML-1.90/perl-libxml-mm.h 2011-10-03 08:12:15.000000000 +0200 +++ new/XML-LibXML-1.92/perl-libxml-mm.h 2012-02-20 19:38:05.000000000 +0100 @@ -53,7 +53,7 @@ * @encoding: this value is missing in libxml2's doc structure * * Since XML::LibXML will not know, is a certain node is already - * defined in the perl layer, it can't shurely tell when a node can be + * defined in the perl layer, it can't surely tell when a node can be * safely be removed from the memory. This structure helps to keep * track how intense the nodes of a document are used and will not * delete the nodes unless they are not refered from somewhere else. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/t/15nodelist.t new/XML-LibXML-1.92/t/15nodelist.t --- old/XML-LibXML-1.90/t/15nodelist.t 2011-07-01 23:08:14.000000000 +0200 +++ new/XML-LibXML-1.92/t/15nodelist.t 2012-01-18 18:19:20.000000000 +0100 @@ -2,7 +2,7 @@ use strict; use warnings; -use Test::More tests => 13; +use Test::More tests => 26; use XML::LibXML; use IO::Handle; @@ -62,6 +62,87 @@ # TEST is(ref($dom->find("//CCC")), "XML::LibXML::NodeList", ' TODO : Add test name'); +my $numbers = XML::LibXML::NodeList->new(1..10); +my $oddify = sub { $_ + ($_%2?0:9) }; # add 9 to even numbers +my @map = $numbers->map($oddify); + +# TEST +is(scalar(@map), 10, 'map called in list context returns list'); + +# TEST +is(join('|',@map), '1|11|3|13|5|15|7|17|9|19', 'mapped data correct'); + +my $map = $numbers->map($oddify); + +# TEST +isa_ok($map => 'XML::LibXML::NodeList', '$map'); + +my @map2 = $map->map(sub { $_ > 10 ? () : ($_,$_,$_) }); + +# TEST +is(join('|',@map2), '1|1|1|3|3|3|5|5|5|7|7|7|9|9|9', 'mapping can add/remove nodes'); + +my @grep = $numbers->grep(sub {$_%2}); +my $grep = $numbers->grep(sub {$_%2}); + +# TEST +is(join('|',@grep), '1|3|5|7|9', 'grep works'); + +# TEST +isa_ok($grep => 'XML::LibXML::NodeList', '$grep'); + +my $shuffled = XML::LibXML::NodeList->new(qw/1 4 2 3 6 5 9 7 8 10/); +my @alphabetical = $shuffled->sort(sub { my ($a, $b) = @_; $a cmp $b }); +my @numeric = $shuffled->sort(sub { my ($a, $b) = @_; $a <=> $b }); + +# TEST +is(join('|',@alphabetical), '1|10|2|3|4|5|6|7|8|9', 'sort works 1'); + +# TEST +is(join('|',@numeric), '1|2|3|4|5|6|7|8|9|10', 'sort works 2'); + +my $reverse = XML::LibXML::NodeList->new; +my $return = $numbers->foreach( sub { $reverse->unshift($_) } ); + +# TEST +is( + blessed_refaddr($return), + blessed_refaddr($numbers), + 'foreach returns $self', + ); + +# TEST +is(join('|',@$reverse), '10|9|8|7|6|5|4|3|2|1', 'foreach works'); + +my $biggest = $shuffled->reduce(sub { $_[0] > $_[1] ? $_[0] : $_[1] }, -1); +my $smallest = $shuffled->reduce(sub { $_[0] < $_[1] ? $_[0] : $_[1] }, 9999); + +# TEST +is($biggest, 10, 'reduce works 1'); + +# TEST +is($smallest, 1, 'reduce works 2'); + +my @reverse = $numbers->reverse; + +# TEST +is(join('|',@reverse), '10|9|8|7|6|5|4|3|2|1', 'reverse works'); + +# modified version of Scalar::Util::PP::refaddr +# only works with blessed references +sub blessed_refaddr { + return undef unless length(ref($_[0])); + my $addr; + if(defined(my $pkg = ref($_[0]))) { + $addr .= bless $_[0], 'Scalar::Util::Fake'; + bless $_[0], $pkg; + } + $addr =~ /0x(\w+)/; + local $^W; + hex($1); +} + + __DATA__ <AAA> <BBB>OK</BBB> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/t/71overloads.t new/XML-LibXML-1.92/t/71overloads.t --- old/XML-LibXML-1.90/t/71overloads.t 1970-01-01 01:00:00.000000000 +0100 +++ new/XML-LibXML-1.92/t/71overloads.t 2012-02-21 12:57:06.000000000 +0100 @@ -0,0 +1,141 @@ +use strict; +use warnings; +use Test::More tests => 16; +use XML::LibXML; + +my $root = XML::LibXML->load_xml( IO => \*DATA )->documentElement; + +# TEST +ok( + tied %$root, + 'elements can be hash dereffed to a tied hash', + ); + +# TEST +isa_ok( + tied %$root, + 'XML::LibXML::AttributeHash', + 'tied %$element', + ); + +# TEST +ok( + exists $root->{'attr1'}, + 'EXISTS non-namespaced', + ); + +# TEST +is( + $root->{'attr1'}, + 'foo', + 'FETCH non-namespaced', + ); + +$root->{attr1} = 'bar'; +# TEST +is( + $root->getAttribute('attr1'), + 'bar', + 'STORE non-namespaced', + ); + +$root->{attr11} = 'baz'; +# TEST +is( + $root->getAttribute('attr11'), + 'baz', + 'STORE (and create) non-namespaced', + ); + +delete $root->{attr11}; +# TEST +ok( + !$root->hasAttribute('attr11'), + 'DELETE non-namespaced', + ); + +my $fail = 1; +while (my ($k, $v) = each %$root) +{ + if ($k eq 'attr1') + { + $fail = 0; + # TEST + pass('FIRSTKEY/NEXTKEY non-namespaced'); + } +} + +if ($fail) +{ + fail('FIRSTKEY/NEXTKEY non-namespaced'); +} + +# TEST +ok( + exists $root->{'{http://localhost/}attr2'}, + 'EXISTS namespaced', + ); + +# TEST +is( + $root->{'{http://localhost/}attr2'}, + 'bar', + 'FETCH namespaced', + ); + +$root->{'{http://localhost/}attr2'} = 'quux'; +# TEST +is( + $root->getAttributeNS('http://localhost/', 'attr2'), + 'quux', + 'STORE namespaced', + ); + +$root->{'{http://localhost/}attr22'} = 'quuux'; +# TEST +is( + $root->getAttributeNS('http://localhost/', 'attr22'), + 'quuux', + 'STORE (and create) namespaced', + ); + +$root->{'{http://localhost/another}attr22'} = 'xyzzy'; +# TEST +is( + $root->getAttributeNS('http://localhost/another', 'attr22'), + 'xyzzy', + 'STORE (and create) namespaced, in new namespace', + ); + +delete $root->{'{http://localhost/another}attr22'}; +# TEST +ok( + !$root->hasAttributeNS('http://localhost/another', 'attr22'), + 'DELETE namespaced', + ); + +my $fail2 = 1; +while (my ($k, $v) = each %$root) +{ + if ($k eq '{http://localhost/}attr22') + { + $fail2 = 0; + # TEST + pass('FIRSTKEY/NEXTKEY namespaced'); + } +} + +if ($fail2) +{ + fail('FIRSTKEY/NEXTKEY namespaced'); +} + +# TEST +like( + $root->toStringEC14N, + qr{<root xmlns:x="http://localhost/" attr1="bar" x:attr2="quux" x:attr22="quuux"></root>}, + '!!! toStringEC14N', + ); + +__DATA__ +<root attr1="foo" xmlns:x="http://localhost/" x:attr2="bar" /> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/XML-LibXML-1.90/t/72destruction.t new/XML-LibXML-1.92/t/72destruction.t --- old/XML-LibXML-1.90/t/72destruction.t 1970-01-01 01:00:00.000000000 +0100 +++ new/XML-LibXML-1.92/t/72destruction.t 2012-02-21 12:57:06.000000000 +0100 @@ -0,0 +1,48 @@ +use strict; +use warnings; +use Test::More; +use Scalar::Util; +use XML::LibXML; + +if (defined (&Scalar::Util::weaken)) +{ + plan tests => 1; +} +else +{ + plan skip_all => 'Need Scalar::Util::weaken'; +} + +my $is_destroyed; +BEGIN +{ + no warnings 'once', 'redefine'; + my $old = \&XML::LibXML::Element::DESTROY; + *XML::LibXML::Element::DESTROY = sub + { + $is_destroyed++; + $old->(@_); + }; +} + +# Create element... +my $root = XML::LibXML->load_xml( IO => \*DATA )->documentElement; + +# allow %hash to go out of scope quickly. +{ + my %hash = %$root; + # assignment to ensure block is not optimized away + $hash{foo} = 'phooey'; +} + +# Destroy element... +undef($root); + +# Touch the fieldhash... +my %other = %{ XML::LibXML->load_xml( string => '<foo/>' )->documentElement }; + +# TEST +ok($is_destroyed, "does not leak memory"); + +__DATA__ +<root attr1="foo" xmlns:x="http://localhost/" x:attr2="bar" /> -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
