Hello community,
here is the log from the commit of package perl-XML-LibXML-Simple for
openSUSE:Factory checked in at 2016-03-18 21:31:00
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/perl-XML-LibXML-Simple (Old)
and /work/SRC/openSUSE:Factory/.perl-XML-LibXML-Simple.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "perl-XML-LibXML-Simple"
Changes:
--------
---
/work/SRC/openSUSE:Factory/perl-XML-LibXML-Simple/perl-XML-LibXML-Simple.changes
2015-04-22 01:10:04.000000000 +0200
+++
/work/SRC/openSUSE:Factory/.perl-XML-LibXML-Simple.new/perl-XML-LibXML-Simple.changes
2016-03-18 21:31:17.000000000 +0100
@@ -1,0 +2,13 @@
+Sun Mar 13 10:46:13 UTC 2016 - [email protected]
+
+- updated to 0.96
+ see /usr/share/doc/packages/perl-XML-LibXML-Simple/ChangeLog
+
+ version 0.96: Fri 11 Mar 15:09:43 CET 2016
+
+ Improvements:
+ - deprecate XML input from 'undef'
+ - rewrite UNIVERSAL::isa into blessed ->isa
+ - implement hooks on nodes
+
+-------------------------------------------------------------------
Old:
----
XML-LibXML-Simple-0.95.tar.gz
New:
----
XML-LibXML-Simple-0.96.tar.gz
cpanspec.yml
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ perl-XML-LibXML-Simple.spec ++++++
--- /var/tmp/diff_new_pack.nsyDgc/_old 2016-03-18 21:31:18.000000000 +0100
+++ /var/tmp/diff_new_pack.nsyDgc/_new 2016-03-18 21:31:18.000000000 +0100
@@ -1,7 +1,7 @@
#
# spec file for package perl-XML-LibXML-Simple
#
-# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -17,14 +17,15 @@
Name: perl-XML-LibXML-Simple
-Version: 0.95
+Version: 0.96
Release: 0
%define cpan_name XML-LibXML-Simple
Summary: XML::LibXML clone of XML::Simple::XMLin()
License: Artistic-1.0 or GPL-1.0+
Group: Development/Libraries/Perl
Url: http://search.cpan.org/dist/XML-LibXML-Simple/
-Source:
http://www.cpan.org/authors/id/M/MA/MARKOV/%{cpan_name}-%{version}.tar.gz
+Source0:
http://www.cpan.org/authors/id/M/MA/MARKOV/%{cpan_name}-%{version}.tar.gz
+Source1: cpanspec.yml
BuildArch: noarch
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildRequires: perl
++++++ XML-LibXML-Simple-0.95.tar.gz -> XML-LibXML-Simple-0.96.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/XML-LibXML-Simple-0.95/ChangeLog
new/XML-LibXML-Simple-0.96/ChangeLog
--- old/XML-LibXML-Simple-0.95/ChangeLog 2014-12-22 08:20:35.000000000
+0100
+++ new/XML-LibXML-Simple-0.96/ChangeLog 2016-03-11 15:09:51.000000000
+0100
@@ -1,6 +1,13 @@
=== version history for XML::LibXML::Simple
+version 0.96: Fri 11 Mar 15:09:43 CET 2016
+
+ Improvements:
+ - deprecate XML input from 'undef'
+ - rewrite UNIVERSAL::isa into blessed ->isa
+ - implement hooks on nodes
+
version 0.95: Mon Dec 22 08:19:53 CET 2014
Fixes:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/XML-LibXML-Simple-0.95/META.json
new/XML-LibXML-Simple-0.96/META.json
--- old/XML-LibXML-Simple-0.95/META.json 2014-12-22 08:20:36.000000000
+0100
+++ new/XML-LibXML-Simple-0.96/META.json 2016-03-11 15:09:52.000000000
+0100
@@ -33,11 +33,12 @@
"runtime" : {
"requires" : {
"File::Slurp::Tiny" : "0",
+ "Scalar::Util" : "0",
"Test::More" : "0.54",
"XML::LibXML" : "1.64"
}
}
},
"release_status" : "stable",
- "version" : "0.95"
+ "version" : "0.96"
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/XML-LibXML-Simple-0.95/META.yml
new/XML-LibXML-Simple-0.96/META.yml
--- old/XML-LibXML-Simple-0.95/META.yml 2014-12-22 08:20:35.000000000 +0100
+++ new/XML-LibXML-Simple-0.96/META.yml 2016-03-11 15:09:52.000000000 +0100
@@ -19,6 +19,7 @@
- inc
requires:
File::Slurp::Tiny: 0
+ Scalar::Util: 0
Test::More: 0.54
XML::LibXML: 1.64
-version: 0.95
+version: 0.96
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/XML-LibXML-Simple-0.95/Makefile.PL
new/XML-LibXML-Simple-0.96/Makefile.PL
--- old/XML-LibXML-Simple-0.95/Makefile.PL 2014-12-22 08:19:40.000000000
+0100
+++ new/XML-LibXML-Simple-0.96/Makefile.PL 2016-03-11 15:09:51.000000000
+0100
@@ -4,11 +4,12 @@
WriteMakefile
( NAME => 'XML::LibXML::Simple'
- , VERSION => '0.95'
+ , VERSION => '0.96'
, PREREQ_PM =>
{ XML::LibXML => 1.64
, Test::More => 0.54
, File::Slurp::Tiny => 0
+ , Scalar::Util => 0
}
, AUTHOR => 'Mark Overmeer'
, ABSTRACT => 'XML::LibXML based XML::Simple clone'
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/XML-LibXML-Simple-0.95/README
new/XML-LibXML-Simple-0.96/README
--- old/XML-LibXML-Simple-0.95/README 2014-12-22 08:19:40.000000000 +0100
+++ new/XML-LibXML-Simple-0.96/README 2016-03-11 15:09:51.000000000 +0100
@@ -1,5 +1,5 @@
-=== README for XML-LibXML-Simple version 0.95
-= Generated on Mon Dec 22 08:19:40 2014 by OODoc 2.01
+=== README for XML-LibXML-Simple version 0.96
+= Generated on Fri Mar 11 15:09:51 2016 by OODoc 2.02
There are various ways to install this module:
@@ -9,16 +9,16 @@
(2) if you use Windows, have a look at http://ppm.activestate.com/
(3) if you have downloaded this module manually (as root/administrator)
- gzip -d XML-LibXML-Simple-0.95.tar.gz
- tar -xf XML-LibXML-Simple-0.95.tar
- cd XML-LibXML-Simple-0.95
+ gzip -d XML-LibXML-Simple-0.96.tar.gz
+ tar -xf XML-LibXML-Simple-0.96.tar
+ cd XML-LibXML-Simple-0.96
perl Makefile.PL
make # optional
make test # optional
make install
For usage, see the included manual-pages or
- http://search.cpan.org/dist/XML-LibXML-Simple-0.95/
+ http://search.cpan.org/dist/XML-LibXML-Simple-0.96/
Please report problems to
http://rt.cpan.org/Dist/Display.html?Queue=XML-LibXML-Simple
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/XML-LibXML-Simple-0.95/lib/XML/LibXML/Simple.pm
new/XML-LibXML-Simple-0.96/lib/XML/LibXML/Simple.pm
--- old/XML-LibXML-Simple-0.95/lib/XML/LibXML/Simple.pm 2014-12-22
08:20:35.000000000 +0100
+++ new/XML-LibXML-Simple-0.96/lib/XML/LibXML/Simple.pm 2016-03-11
15:09:51.000000000 +0100
@@ -1,10 +1,10 @@
-# Copyrights 2008-2014 by [Mark Overmeer].
+# Copyrights 2008-2016 by [Mark Overmeer].
# For other contributors see ChangeLog.
# See the manual pages for details on the licensing terms.
-# Pod stripped from pm file by OODoc 2.01.
+# Pod stripped from pm file by OODoc 2.02.
package XML::LibXML::Simple;
use vars '$VERSION';
-$VERSION = '0.95';
+$VERSION = '0.96';
use base 'Exporter';
@@ -19,6 +19,7 @@
use File::Basename qw/fileparse/;
use File::Spec ();
use Carp;
+use Scalar::Util qw/blessed/;
use Data::Dumper; #to be removed
@@ -28,8 +29,8 @@
forcearray grouptags nsexpand normalisespace normalizespace
valueattr nsstrip parser parseropts);
-my @DefKeyAttr = qw(name key id);
-my $DefContentKey = qq(content);
+my @default_attributes = qw(name key id);
+my $default_content_key = 'content';
#-------------
@@ -48,21 +49,25 @@
#-------------
sub XMLin
-{ my $self = @_ > 1 && UNIVERSAL::isa($_[0], __PACKAGE__) ? shift
+{ my $self = @_ > 1 && blessed $_[0] && $_[0]->isa(__PACKAGE__) ? shift
: __PACKAGE__->new;
my $target = shift;
- my $this = $self->_take_opts(@_);
- my $opts = $self->_init($self->{opts}, $this);
+ my $this = $self->_take_opts(@_);
+ my $opts = $self->_init($self->{opts}, $this);
- my $xml = $self->_get_xml($target, $opts)
+ my $xml = $self->_get_xml($target, $opts)
or return;
+ if(my $cb = $opts->{hooknodes})
+ { $self->{XCS_hooks} = $cb->($self, $xml);
+ }
+
my $top = $self->collapse($xml, $opts);
if($opts->{keeproot})
- { my $subtop
- = $opts->{forcearray_always} && ref $top ne 'ARRAY' ? [$top] : $top;
- $top = { $xml->localName => $subtop };
+ { my $subtop
+ = $opts->{forcearray_always} && ref $top ne 'ARRAY' ? [$top] : $top;
+ $top = +{ $xml->localName => $subtop };
}
$top;
@@ -82,8 +87,9 @@
|| $self->_create_parser($opts->{parseropts});
my $xml
- = UNIVERSAL::isa($source,'XML::LibXML::Document') ? $source
- : UNIVERSAL::isa($source,'XML::LibXML::Element' ) ? $source
+ = blessed $source &&
+ ( $source->isa('XML::LibXML::Document')
+ || $source->isa('XML::LibXML::Element' )) ? $source
: ref $source eq 'SCALAR' ? $parser->parse_string($$source)
: ref $source ? $parser->parse_fh($source)
: $source =~ m{^\s*\<.*?\>\s*$}s ? $parser->parse_string($source)
@@ -151,7 +157,7 @@
if(defined $opt{contentkey})
{ $opt{collapseagain} = $opt{contentkey} =~ s/^\-// }
- else { $opt{contentkey} = $DefContentKey }
+ else { $opt{contentkey} = $default_content_key }
$opt{normalisespace} ||= $opt{normalizespace} || 0;
@@ -174,7 +180,7 @@
# Special cleanup for {keyattr} which could be arrayref or hashref,
# which behave differently.
- my $ka = $opt{keyattr} || \@DefKeyAttr;
+ my $ka = $opt{keyattr} || \@default_attributes;
$ka = [ $ka ] unless ref $ka;
if(ref $ka eq 'ARRAY')
@@ -261,19 +267,32 @@
$xml->isa('XML::LibXML::Element') or return;
my (%data, $text);
+ my $hooks = $self->{XCS_hooks};
unless($opts->{noattr})
- { foreach my $attr ($xml->attributes)
- { my $value = $attr->value;
+ {
+ ATTR:
+ foreach my $attr ($xml->attributes)
+ {
+ my $value;
+ if($hooks && (my $hook = $hooks->{$attr->unique_key}))
+ { $value = $hook->($attr);
+ defined $value or next ATTR;
+ }
+ else
+ { $value = $attr->value;
+ }
+
$value = $self->normalise_space($value)
- if $opts->{normalisespace}==2;
+ if !ref $value && $opts->{normalisespace}==2;
- my $n = !$attr->isa('XML::LibXML::Attr') ? $attr->nodeName
- : $opts->{nsexpand} ? _expand_name($attr)
- : $opts->{nsstrip} ? $attr->localName
- : $attr->nodeName;
+ my $name
+ = !$attr->isa('XML::LibXML::Attr') ? $attr->nodeName
+ : $opts->{nsexpand} ? _expand_name($attr)
+ : $opts->{nsstrip} ? $attr->localName
+ : $attr->nodeName;
- _add_kv \%data, $n, $value, $opts;
+ _add_kv \%data, $name => $value, $opts;
}
}
my $nr_attrs = keys %data;
@@ -282,17 +301,28 @@
CHILD:
foreach my $child ($xml->childNodes)
{
- if($child->isa('XML::LibXML::Element'))
- { $nr_elems++;
- my $v = $self->collapse($child, $opts);
- my $n = $opts->{nsexpand} ? _expand_name($child)
- : $opts->{nsstrip} ? $child->localName
- : $child->nodeName;
- _add_kv \%data, $n, $v, $opts if defined $v;
- }
- elsif($child->isa('XML::LibXML::Text'))
+ if($child->isa('XML::LibXML::Text'))
{ $text .= $child->data;
+ next CHILD;
}
+
+ $child->isa('XML::LibXML::Element')
+ or next CHILD;
+
+ $nr_elems++;
+
+ my $v;
+ if($hooks && (my $hook = $hooks->{$child->unique_key}))
+ { $v = $hook->($child) }
+ else { $v = $self->collapse($child, $opts) }
+ defined $v or next CHILD;
+
+ my $name
+ = $opts->{nsexpand} ? _expand_name($child)
+ : $opts->{nsstrip} ? $child->localName
+ : $child->nodeName;
+
+ _add_kv \%data, $name => $v, $opts;
}
$text = $self->normalise_space($text)
@@ -307,8 +337,8 @@
# Roll up 'value' attributes (but only if no nested elements)
if(keys %data==1)
- { my ($k) = keys %data;
- return $data{$k} if $opts->{valueattrlist}{$k};
+ { my ($k) = keys %data;
+ return $data{$k} if $opts->{valueattrlist}{$k};
}
# Turn arrayrefs into hashrefs if key fields present
@@ -382,7 +412,7 @@
my $ka = $opts->{keyattr} or return $in;
if(ref $ka eq 'HASH')
- { my $newkey = $ka->{$name} or return $in;
+ { my $newkey = $ka->{$name} or return $in;
my ($key, $flag) = @$newkey;
foreach my $h (@$in)
@@ -410,7 +440,7 @@
}
else # Arrayref
- { my $default_keys = "@DefKeyAttr" eq "@$ka";
+ { my $default_keys = "@default_attributes" eq "@$ka";
ELEMENT:
foreach my $h (@$in)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/XML-LibXML-Simple-0.95/lib/XML/LibXML/Simple.pod
new/XML-LibXML-Simple-0.96/lib/XML/LibXML/Simple.pod
--- old/XML-LibXML-Simple-0.95/lib/XML/LibXML/Simple.pod 2014-12-22
08:20:35.000000000 +0100
+++ new/XML-LibXML-Simple-0.96/lib/XML/LibXML/Simple.pod 2016-03-11
15:09:51.000000000 +0100
@@ -81,10 +81,15 @@
$data = XMLin('/etc/params.xml', %options);
-Note, the filename C<< - >> (dash) can be used to parse from STDIN.
+=item A dash (-)
+
+Parse from STDIN.
+
+ $data = XMLin('-', %options);
=item undef
+[deprecated]
If there is no XML specifier, C<XMLin()> will check the script directory and
each of the SearchPath directories for a file with the same name as the script
but with the extension '.xml'. Note: if you wish to specify options, you
@@ -92,6 +97,10 @@
$data = XMLin(undef, ForceArray => 1);
+This feature is available for backwards compatibility with XML::Simple,
+but quite sensitive. You can easily hit the wrong xml file as input.
+Please do not use it: always use an explicit filename.
+
=item A string of XML
A string containing XML (recognised by the presence of '<' and '>' characters)
@@ -104,7 +113,9 @@
In this case, XML::LibXML::Parser will read the XML data directly from
the provided file.
- $fh = IO::File->new('/etc/params.xml');
+ # $fh = IO::File->new('/etc/params.xml') or die;
+ open my $fh, '<:encoding(utf8)', '/etc/params.xml' or die;
+
$data = XMLin($fh, %options);
=item An XML::LibXML::Document or ::Element
@@ -290,6 +301,51 @@
the same hashref. If this option is combined with C<KeyAttr>, the array
folding will occur first and then the grouped element names will be eliminated.
+=item HookNodes => CODE
+
+Select document nodes to apply special tricks.
+Introduced in [0.96], not available in XML::Simple.
+
+When this option is provided, the CODE will be called once the XML DOM
+tree is ready to get transformed into Perl. Your CODE should return
+either C<undef> (nothing to do) or a HASH which maps values of
+unique_key (see XML::LibXML::Node method C<unique_key> onto CODE
+references to be called.
+
+Once the translater from XML into Perl reaches a selected node, it will
+call your routine specific for that node. That triggering node found
+is the only parameter. When you return C<undef>, the node will not be
+found in the final result. You may return any data (even the node itself)
+which will be included in the final result as is, under the name of the
+original node.
+
+Example:
+
+ my $out = XMLin $file, HookNodes => \&protect_html;
+
+ sub protect_html($$)
+ { # $obj is the instantated XML::Compile::Simple object
+ # $xml is a XML::LibXML::Element to get transformed
+ my ($obj, $xml) = @_;
+
+ my %hooks; # collects the table of hooks
+
+ # do an xpath search for HTML
+ my $xpc = XML::LibXML::XPathContext->new($xml);
+ my @nodes = $xpc->findNodes(...); #XXX
+ @nodes or return undef;
+
+ my $as_text = sub { $_[0]->toString(0) }; # as text
+ # $as_node = sub { $_[0] }; # as node
+ # $skip = sub { undef }; # not at all
+
+ # the same behavior for all xpath nodes, in this example
+ $hook{$_->unique_key} = $as_text
+ for @nodes;
+
+ \%hook;
+ }
+
=item KeepRoot => 1 I<# handy>
In its attempt to return a data structure free of superfluous detail and
@@ -693,6 +749,10 @@
There are a few small differences in the result of the C<forcearray> option,
because XML::Simple seems to behave inconsequently.
+=item hooks
+
+XML::Simple does not support hooks.
+
=back
=head1 SEE ALSO
@@ -710,7 +770,7 @@
Grant McLean E<lt>[email protected]<gt>
Copyrights of the perl code and the related documentation by
-2008-2014 by [Mark Overmeer]. For other contributors see ChangeLog.
+2008-2016 by [Mark Overmeer]. For other contributors see ChangeLog.
This program is free software; you can redistribute it and/or modify it
under the same terms as Perl itself.
++++++ cpanspec.yml ++++++
---
#description_paragraphs: 3
#description: |-
# override description from CPAN
#summary: override summary from CPAN
#no_testing: broken upstream
#sources:
# - source1
# - source2
#patches:
# foo.patch: -p1
# bar.patch:
#preamble: |-
# BuildRequires: gcc-c++
#post_prep: |-
# hunspell=`pkg-config --libs hunspell | sed -e 's,-l,,; s, *,,g'`
# sed -i -e "s,hunspell-X,$hunspell," t/00-prereq.t Makefile.PL
#post_build: |-
# rm unused.files
#post_install: |-
# sed on %{name}.files
#license: SUSE-NonFree
#skip_noarch: 1
#custom_build: |-
#./Build build flags=%{?_smp_mflags} --myflag
#custom_test: |-
#startserver && make test
#ignore_requires: Bizarre::Module