You can subscribe to this list here.
2002 |
Jan
(8) |
Feb
(22) |
Mar
(3) |
Apr
(13) |
May
(1) |
Jun
(4) |
Jul
|
Aug
(5) |
Sep
(9) |
Oct
(36) |
Nov
(7) |
Dec
(15) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2003 |
Jan
(4) |
Feb
(1) |
Mar
(55) |
Apr
(25) |
May
(25) |
Jun
(4) |
Jul
(2) |
Aug
|
Sep
(12) |
Oct
(6) |
Nov
(14) |
Dec
(1) |
2004 |
Jan
(1) |
Feb
(8) |
Mar
(6) |
Apr
(5) |
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
(1) |
Oct
(3) |
Nov
(11) |
Dec
|
2005 |
Jan
(14) |
Feb
(3) |
Mar
(4) |
Apr
(14) |
May
(1) |
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
(2) |
Nov
(2) |
Dec
(1) |
2006 |
Jan
|
Feb
|
Mar
|
Apr
(3) |
May
|
Jun
|
Jul
|
Aug
(1) |
Sep
(8) |
Oct
(19) |
Nov
(5) |
Dec
|
2007 |
Jan
(5) |
Feb
(1) |
Mar
|
Apr
(4) |
May
|
Jun
|
Jul
|
Aug
(8) |
Sep
|
Oct
|
Nov
|
Dec
|
2008 |
Jan
|
Feb
|
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Ilya M. <m_...@us...> - 2003-04-30 20:45:21
|
Update of /cvsroot/perl-xml/XML-LibXML-XPathContext In directory sc8-pr-cvs1:/tmp/cvs-serv5228 Modified Files: README Log Message: Updated Index: README =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/README,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- README 4 Apr 2003 09:05:48 -0000 1.3 +++ README 30 Apr 2003 20:45:15 -0000 1.4 @@ -21,9 +21,13 @@ $xc->unregisterVarLookupFunc($name); my @nodes = $xc->findnodes($xpath); + my @nodes = $xc->findnodes($xpath, $context_node); my $nodelist = $xc->findnodes($xpath); + my $nodelist = $xc->findnodes($xpath, $context_node); my $result = $xc->find($xpath); + my $result = $xc->find($xpath, $context_node); my $value = $xc->findvalue($xpath); + my $value = $xc->findvalue($xpath, $context_node); DESCRIPTION This module augments XML::LibXML by providing Perl interface to @@ -88,7 +92,7 @@ ); # get names of employees from $A woring in an area listed in $B - $xc->registerVarLookupFunc(\&var_lookup,\%results); + $xc->registerVarLookupFunc(\&var_lookup, \%results); my @nodes = $xc->findnodes('$A[work_area/street = $B]/name'); METHODS @@ -146,12 +150,13 @@ unregisterFunction($name) Same as *unregisterFunctionNS* but without a namespace. - findnodes($xpath) + findnodes($xpath, [ $context_node ]) Performs the xpath statement on the current node and returns the result as an array. In scalar context returns a - XML::LibXML::NodeList object. + XML::LibXML::NodeList object. Optionally, a node may be passed as a + second argument to set the context node for the query. - find($xpath) + find($xpath, [ $context_node ]) Performs the xpath expression using the current node as the context of the expression, and returns the result depending on what type of result the XPath expression had. For example, the XPath "1 * 3 + 52" @@ -159,9 +164,10 @@ expressions might return a XML::LibXML::Boolean object, or a XML::LibXML::Literal object (a string). Each of those objects uses Perl's overload feature to "do the right thing" in different - contexts. + contexts. Optionally, a node may be passed as a second argument to + set the context node for the query. - findvalue($xpath) + findvalue($xpath, [ $context_node ]) Is exactly equivalent to: $node->find( $xpath )->to_literal; @@ -169,7 +175,8 @@ That is, it returns the literal value of the results. This enables you to ensure that you get a string back from your search, allowing certain shortcuts. This could be used as the equivalent of - <xsl:value-of select="some_xpath"/>. + <xsl:value-of select="some_xpath"/>. Optionally, a node may be + passed in the second argument to set the context node for the query. getContextNode() Get the current context node. |
From: Ilya M. <m_...@us...> - 2003-04-30 20:31:51
|
Update of /cvsroot/perl-xml/XML-LibXML-XPathContext In directory sc8-pr-cvs1:/tmp/cvs-serv32576 Modified Files: XPathContext.pm Log Message: Minor style fixes - be consistent in usage of space chars Index: XPathContext.pm =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/XPathContext.pm,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- XPathContext.pm 30 Apr 2003 20:27:28 -0000 1.22 +++ XPathContext.pm 30 Apr 2003 20:31:46 -0000 1.23 @@ -162,13 +162,13 @@ $xc->unregisterVarLookupFunc($name); my @nodes = $xc->findnodes($xpath); - my @nodes = $xc->findnodes($xpath,$context_node); + my @nodes = $xc->findnodes($xpath, $context_node); my $nodelist = $xc->findnodes($xpath); - my $nodelist = $xc->findnodes($xpath,$context_node); + my $nodelist = $xc->findnodes($xpath, $context_node); my $result = $xc->find($xpath); - my $result = $xc->find($xpath,$context_node); + my $result = $xc->find($xpath, $context_node); my $value = $xc->findvalue($xpath); - my $value = $xc->findvalue($xpath,$context_node); + my $value = $xc->findvalue($xpath, $context_node); =head1 DESCRIPTION @@ -249,7 +249,7 @@ ); # get names of employees from $A woring in an area listed in $B - $xc->registerVarLookupFunc(\&var_lookup,\%results); + $xc->registerVarLookupFunc(\&var_lookup, \%results); my @nodes = $xc->findnodes('$A[work_area/street = $B]/name'); =head1 METHODS @@ -343,7 +343,6 @@ of those objects uses Perl's overload feature to "do the right thing" in different contexts. Optionally, a node may be passed as a second argument to set the context node for the query. - =item B<findvalue($xpath, [ $context_node ])> |
From: Ilya M. <m_...@us...> - 2003-04-30 20:27:32
|
Update of /cvsroot/perl-xml/XML-LibXML-XPathContext In directory sc8-pr-cvs1:/tmp/cvs-serv30259 Modified Files: XPathContext.pm Log Message: Update version number Index: XPathContext.pm =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/XPathContext.pm,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- XPathContext.pm 11 Apr 2003 16:39:32 -0000 1.21 +++ XPathContext.pm 30 Apr 2003 20:27:28 -0000 1.22 @@ -7,7 +7,7 @@ use XML::LibXML::NodeList; -$VERSION = '0.02'; +$VERSION = '0.03'; require DynaLoader; @ISA = qw(DynaLoader); |
From: Ilya M. <m_...@us...> - 2003-04-30 20:24:31
|
Update of /cvsroot/perl-xml/XML-LibXML-XPathContext In directory sc8-pr-cvs1:/tmp/cvs-serv29036 Modified Files: Changes Log Message: Updated Index: Changes =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/Changes,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- Changes 11 Apr 2003 16:39:32 -0000 1.7 +++ Changes 30 Apr 2003 20:24:24 -0000 1.8 @@ -2,7 +2,7 @@ Revision history for Perl module XML::LibXML::XPathContext. -Not in CVS +0.03 Thu May 1 2003 * added optional $context_node argument to findnodes(), find(), and findvalue() to simplify temporarily setting the context node. |
From: Grant M. <gr...@us...> - 2003-04-16 10:24:00
|
Update of /cvsroot/perl-xml/xml-simple In directory sc8-pr-cvs1:/tmp/cvs-serv15758 Modified Files: Changes README Log Message: - for release 2.05 Index: Changes =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/Changes,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- Changes 10 Apr 2003 10:21:29 -0000 1.9 +++ Changes 16 Apr 2003 10:23:55 -0000 1.10 @@ -1,6 +1,15 @@ Revision history for Perl module XML::Simple -2.04 Mar 10 2004 +2.05 Apr 16 2003 + - fixed warnings when NormaliseSpace undefined (reported by Peter + Scott and others) + - added support for specifying ForceArray using regular expressions + (patch from Jim Cromie) + - added check to escape_value to guard against undefined argument + (reported by Henrik Gemal) + - added NoIndent option (requested by Afroze Husain Zubairi) + +2.04 Apr 10 2003 - integrated a patch from Michel Rodriguez + new facility for removing extra levels of indirection (using the new 'GroupTags' option) Index: README =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/README,v retrieving revision 1.9 retrieving revision 1.10 diff -u -d -r1.9 -r1.10 --- README 10 Apr 2003 10:21:29 -0000 1.9 +++ README 16 Apr 2003 10:23:55 -0000 1.10 @@ -56,12 +56,22 @@ STATUS - This version (2.04) is the current stable release. + This version (2.05) is the current stable release. Please send any feedback to the author: gr...@cp... NEW IN THIS RELEASE + - fixed warnings when NormaliseSpace undefined (reported by Peter + Scott and others) + - added support for specifying ForceArray using regular expressions + (patch from Jim Cromie) + - added check to escape_value to guard against undefined argument + (reported by Henrik Gemal) + - added NoIndent option (requested by Afroze Husain Zubairi) + + + New in Version 2.04 - new 'GroupTags' option (patch from Michel Rodriguez) - optionally collapse 'content' hashes to scalars after folding (also from Michel) |
From: Grant M. <gr...@us...> - 2003-04-16 10:19:27
|
Update of /cvsroot/perl-xml/xml-simple/t In directory sc8-pr-cvs1:/tmp/cvs-serv13035/t Modified Files: 2_XMLout.t Log Message: - adjusted uninitialised value warning test to enable warnings first - added test for NoIndent option Index: 2_XMLout.t =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/t/2_XMLout.t,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- 2_XMLout.t 10 Apr 2003 10:20:07 -0000 1.6 +++ 2_XMLout.t 16 Apr 2003 10:19:24 -0000 1.7 @@ -5,7 +5,7 @@ use Test::More; use IO::File; -plan tests => 190; +plan tests => 192; ############################################################################## # S U P P O R T R O U T I N E S @@ -628,6 +628,7 @@ # Check undefined values generate warnings { + $^W = 1; my $warn = ''; local $SIG{__WARN__} = sub { $warn = $_[0] }; $_ = eval { @@ -878,6 +879,24 @@ </dirs>\s* </\1>$ }x, 'Failed to unwrap/group stripped content - as expected'); + + +# Check 'NoIndent' option + +$ref = { + nest => [ qw(one two three) ] +}; + +# Expect: +# +# <opt><nest>one</nest><nest>two</nest><nest>three</nest></opt> +# + +$_ = XMLout($ref, NoIndent => 1); + +is_deeply(XMLin($_), $ref, 'parses ok'); +is($_, '<opt><nest>one</nest><nest>two</nest><nest>three</nest></opt>', +'NoIndent worked ok'); # 'Stress test' with a data structure that maps to several thousand elements. |
From: Grant M. <gr...@us...> - 2003-04-16 10:17:44
|
Update of /cvsroot/perl-xml/xml-simple/t In directory sc8-pr-cvs1:/tmp/cvs-serv12018/t Modified Files: 1_XMLin.t Log Message: - added tests for regexes in ForceArray Index: 1_XMLin.t =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/t/1_XMLin.t,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- 1_XMLin.t 10 Apr 2003 10:20:06 -0000 1.11 +++ 1_XMLin.t 16 Apr 2003 10:17:29 -0000 1.12 @@ -15,14 +15,14 @@ plan skip_all => 'Test data missing'; } -plan tests => 93; +plan tests => 95; $@ = ''; eval "use XML::Simple;"; is($@, '', 'Module compiled OK'); -unless($XML::Simple::VERSION eq '2.04') { - diag("Warning: XML::Simple::VERSION = $XML::Simple::VERSION (expected 2.04)"); +unless($XML::Simple::VERSION eq '2.05') { + diag("Warning: XML::Simple::VERSION = $XML::Simple::VERSION (expected 2.05)"); } @@ -670,6 +670,41 @@ 'two' => [ 'ii' ], 'three' => [ 'iii', 3, 'c' ] }, 'selective application of forcearray successful'); + + +# Test forcearray regexes + +$xml = q(<opt zero="0"> + <one>i</one> + <two>ii</two> + <three>iii</three> + <four>iv</four> + <five>v</five> +</opt> +); + +$opt = XMLin($xml, forcearray => [ qr/^f/, 'two', qr/n/ ], @cont_key); +is_deeply($opt, { + 'zero' => '0', + 'one' => [ 'i' ], + 'two' => [ 'ii' ], + 'three' => 'iii', + 'four' => [ 'iv' ], + 'five' => [ 'v' ], +}, 'forcearray using regex successful'); + + +# Same again but a single regexp rather than in an arrayref + +$opt = XMLin($xml, forcearray => qr/^f|e$/, @cont_key); +is_deeply($opt, { + 'zero' => '0', + 'one' => [ 'i' ], + 'two' => 'ii', + 'three' => [ 'iii'], + 'four' => [ 'iv' ], + 'five' => [ 'v' ], +}, 'forcearray using a single regex successful'); # Test 'noattr' option |
From: Grant M. <gr...@us...> - 2003-04-16 10:16:35
|
Update of /cvsroot/perl-xml/xml-simple/lib/XML In directory sc8-pr-cvs1:/tmp/cvs-serv11335/lib/XML Modified Files: Simple.pm Log Message: - fixed warnings when NormaliseSpace undefined - added support for specifying ForceArray using regular expressions - added check to escape_value to guard against undefined argument - added NoIndent option (requested by Afroze Husain Zubairi) Index: Simple.pm =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/lib/XML/Simple.pm,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- Simple.pm 10 Apr 2003 10:19:02 -0000 1.11 +++ Simple.pm 16 Apr 2003 10:16:28 -0000 1.12 @@ -53,7 +53,7 @@ @ISA = qw(Exporter); @EXPORT = qw(XMLin XMLout); @EXPORT_OK = qw(xml_in xml_out); -$VERSION = '2.04'; +$VERSION = '2.05'; $PREFERRED_PARSER = undef; my $StrictMode = 0; @@ -70,7 +70,7 @@ my @KnownOptOut = qw(keyattr keeproot contentkey noattr rootname xmldecl outputfile noescape suppressempty - grouptags nsexpand handler); + grouptags nsexpand handler noindent); my @DefKeyAttr = qw(name key id); my $DefRootName = qq(opt); @@ -650,8 +650,9 @@ } unless(exists($opt->{normalisespace})) { - $opt->{normalisespace} = $opt->{normalizespace} + $opt->{normalisespace} = $opt->{normalizespace}; } + $opt->{normalisespace} = 0 unless(defined($opt->{normalisespace})); # Cleanups for values assumed to be arrays later @@ -682,15 +683,26 @@ } - # Special cleanup for {forcearray} which could be arrayref or boolean + # Special cleanup for {forcearray} which could be regex, arrayref or boolean # or left to default to 0 if(exists($opt->{forcearray})) { + if(ref($opt->{forcearray}) eq 'Regexp') { + $opt->{forcearray} = [ $opt->{forcearray} ]; + } + if(ref($opt->{forcearray}) eq 'ARRAY') { - if(@{$opt->{forcearray}}) { - $opt->{forcearray} = { ( - map { $_ => 1 } @{$opt->{forcearray}} - ) }; + my @force_list = @{$opt->{forcearray}}; + if(@force_list) { + $opt->{forcearray} = {}; + foreach my $tag (@force_list) { + if(ref($tag) eq 'Regexp') { + push @{$opt->{forcearray}->{_regex}}, $tag; + } + else { + $opt->{forcearray}->{$tag} = 1; + } + } } else { $opt->{forcearray} = 0; @@ -849,7 +861,7 @@ # sub collapse { - my $self = shift;; + my $self = shift; # Start with the hash of attributes @@ -896,10 +908,12 @@ } - if(!%$attr and !@_) { # Short circuit text in tag with no attr - return($self->{opt}->{forcecontent} ? - { $self->{opt}->{contentkey} => $val } : $val - ); + # Collapse text content in element with no attributes to a string + + if(!%$attr and !@_) { + return($self->{opt}->{forcecontent} ? + { $self->{opt}->{contentkey} => $val } : $val + ); } $key = $self->{opt}->{contentkey}; } @@ -919,12 +933,15 @@ $attr->{$key} = [ $val ]; } else { - if( $key ne $self->{opt}->{contentkey} and - ( - ($self->{opt}->{forcearray} == 1) or - ( - (ref($self->{opt}->{forcearray}) eq 'HASH') and - ($self->{opt}->{forcearray}->{$key}) + if( $key ne $self->{opt}->{contentkey} + and ( + ($self->{opt}->{forcearray} == 1) + or ( + (ref($self->{opt}->{forcearray}) eq 'HASH') + and ( + $self->{opt}->{forcearray}->{$key} + or (grep $key =~ $_, @{$self->{opt}->{forcearray}->{_regex}}) + ) ) ) ) { @@ -1188,6 +1205,12 @@ my $nl = "\n"; + if($self->{opt}->{noindent}) { + $indent = ''; + $nl = ''; + } + + # Convert to XML @@ -1310,7 +1333,7 @@ unless(exists($self->{opt}->{suppressempty}) and !defined($self->{opt}->{suppressempty}) ) { - carp 'Use of uninitialized value'; + carp 'Use of uninitialized value' if($^W); } $value = {}; } @@ -1367,16 +1390,16 @@ push @result, $indent, '<', $name, '>', ($self->{opt}->{noescape} ? $value : $self->escape_value($value)), - '</', $name, ">\n"; + '</', $name, ">$nl"; } elsif(UNIVERSAL::isa($value, 'HASH')) { push @result, $self->value_to_xml($value, $name, $indent); } else { push @result, - $indent, '<', $name, ">\n", + $indent, '<', $name, ">$nl", $self->value_to_xml($value, 'anon', "$indent "), - $indent, '</', $name, ">\n"; + $indent, '</', $name, ">$nl"; } } } @@ -1400,9 +1423,9 @@ # sub escape_value { - my $self = shift; + my($self, $data) = @_; - my($data) = @_; + return '' unless(defined($data)); $data =~ s/&/&/sg; $data =~ s/</</sg; @@ -1939,7 +1962,14 @@ specify a list of element names which should always be forced into an array representation, rather than the 'all or nothing' approach above. -=item ForceContent (B<in>) (B<seldom used>) +It is also possible (since version 2.05) to include compiled regular +expressions in the list - any element names which match the pattern will be +forced to arrays. If the list contains only a single regex, then it is not +necessary to enclose it in an arrayref. Eg: + + ForceArray => qr/_list$/ + +=item ForceContent => 1 (B<in>) (B<seldom used>) When C<XMLin()> parses elements which have text content as well as attributes, the text content must be represented as a hash value rather than a simple @@ -2197,6 +2227,12 @@ suppress escaping (presumably because you've already escaped the data in some more sophisticated manner). +=item NoIndent => 1 (B<out>) (B<seldom used>) + +Set this option to 1 to disable C<XMLout()>'s default 'pretty printing' mode. +With this option enabled, the XML output will all be on one line (unless there +are newlines in the data) - this may be easier for downstream processing. + =item NSExpand => 1 (B<in+out>) (B<handy - SAX only>) This option controls namespace expansion - the translation of element and @@ -2756,7 +2792,7 @@ =head1 STATUS -This version (2.04) is the current stable version. +This version (2.05) is the current stable version. =head1 SEE ALSO |
From: Petr P. <pa...@us...> - 2003-04-11 16:39:37
|
Update of /cvsroot/perl-xml/XML-LibXML-XPathContext In directory sc8-pr-cvs1:/tmp/cvs-serv2279 Modified Files: XPathContext.pm Changes Log Message: Index: XPathContext.pm =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/XPathContext.pm,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- XPathContext.pm 4 Apr 2003 09:08:46 -0000 1.20 +++ XPathContext.pm 11 Apr 2003 16:39:32 -0000 1.21 @@ -19,13 +19,20 @@ $USE_LIBXML_DATA_TYPES = 0; sub findnodes { - my ($self, $xpath) = @_; + my ($self, $xpath, $node) = @_; my @nodes; + my $prev_node; + if (ref($node)) { + $prev_node=$self->getContextNode(); + $self->setContextNode($node); + } $self->_enter; eval { @nodes = $self->_findnodes($xpath); }; $self->_leave; + $self->setContextNode($prev_node) if ref($node); + if ($@) { die $@; } if (wantarray) { @@ -37,19 +44,26 @@ } sub findvalue { - my ($self, $xpath) = @_; - return $self->find($xpath)->to_literal->value; + my $self = shift; + return $self->find(@_)->to_literal->value; } sub find { - my ($self, $xpath) = @_; + my ($self, $xpath, $node) = @_; my ($type, @params); + my $prev_node; + if (ref($node)) { + $prev_node=$self->getContextNode(); + $self->setContextNode($node); + } $self->_enter; eval { ($type, @params) = $self->_find($xpath); }; $self->_leave; + $self->setContextNode($prev_node) if ref($node); + if ($@) { die $@; } if ($type) { @@ -148,9 +162,13 @@ $xc->unregisterVarLookupFunc($name); my @nodes = $xc->findnodes($xpath); + my @nodes = $xc->findnodes($xpath,$context_node); my $nodelist = $xc->findnodes($xpath); + my $nodelist = $xc->findnodes($xpath,$context_node); my $result = $xc->find($xpath); + my $result = $xc->find($xpath,$context_node); my $value = $xc->findvalue($xpath); + my $value = $xc->findvalue($xpath,$context_node); =head1 DESCRIPTION @@ -305,13 +323,15 @@ Same as I<unregisterFunctionNS> but without a namespace. -=item B<findnodes($xpath)> +=item B<findnodes($xpath, [ $context_node ])> Performs the xpath statement on the current node and returns the result as an array. In scalar context returns a -L<XML::LibXML::NodeList|XML::LibXML::NodeList> object. +L<XML::LibXML::NodeList|XML::LibXML::NodeList> object. Optionally, a +node may be passed as a second argument to set the context node for +the query. -=item B<find($xpath)> +=item B<find($xpath, [ $context_node ])> Performs the xpath expression using the current node as the context of the expression, and returns the result depending on what type of @@ -321,9 +341,12 @@ L<XML::LibXML::Boolean|XML::LibXML::Boolean> object, or a L<XML::LibXML::Literal|XML::LibXML::Literal> object (a string). Each of those objects uses Perl's overload feature to "do the right thing" -in different contexts. +in different contexts. Optionally, a node may be passed as a second +argument to set the context node for the query. + -=item B<findvalue($xpath)> + +=item B<findvalue($xpath, [ $context_node ])> Is exactly equivalent to: @@ -332,7 +355,8 @@ That is, it returns the literal value of the results. This enables you to ensure that you get a string back from your search, allowing certain shortcuts. This could be used as the equivalent of -<xsl:value-of select="some_xpath"/>. +<xsl:value-of select="some_xpath"/>. Optionally, a node may be passed +in the second argument to set the context node for the query. =item B<getContextNode()> Index: Changes =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/Changes,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- Changes 4 Apr 2003 18:43:02 -0000 1.6 +++ Changes 11 Apr 2003 16:39:32 -0000 1.7 @@ -4,6 +4,9 @@ Not in CVS +* added optional $context_node argument to findnodes(), find(), and +findvalue() to simplify temporarily setting the context node. + * fixed bugs in new(), setContextNode(), and register* causing loosing stored context data passed from a variable if the variable itself gets changed |
From: Petr P. <pa...@us...> - 2003-04-11 16:39:36
|
Update of /cvsroot/perl-xml/XML-LibXML-XPathContext/t In directory sc8-pr-cvs1:/tmp/cvs-serv2279/t Modified Files: 00-xpathcontext.t Log Message: Index: 00-xpathcontext.t =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/t/00-xpathcontext.t,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- 00-xpathcontext.t 4 Apr 2003 18:42:58 -0000 1.6 +++ 00-xpathcontext.t 11 Apr 2003 16:39:31 -0000 1.7 @@ -1,5 +1,5 @@ use Test; -BEGIN { plan tests => 23 }; +BEGIN { plan tests => 27 }; use XML::LibXML; use XML::LibXML::XPathContext; @@ -76,4 +76,12 @@ ok($xc4->getContextNode->isSameNode($doc2->getDocumentElement)); $cn=undef; ok($xc4->getContextNode); +ok($xc4->getContextNode->isSameNode($doc2->getDocumentElement)); + +# check temporarily changed context node +my ($bar)=$xc4->findnodes('foo/bar',$doc2); +ok($bar->nodeName eq 'bar'); +ok($xc4->getContextNode->isSameNode($doc2->getDocumentElement)); + +ok($xc4->findnodes('parent::*',$bar)->pop->nodeName eq 'foo'); ok($xc4->getContextNode->isSameNode($doc2->getDocumentElement)); |
From: Grant M. <gr...@us...> - 2003-04-10 10:21:33
|
Update of /cvsroot/perl-xml/xml-simple In directory sc8-pr-cvs1:/tmp/cvs-serv19607 Modified Files: Changes README Log Message: - Updated for 2.04 release Index: Changes =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/Changes,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- Changes 20 Jan 2003 07:48:59 -0000 1.8 +++ Changes 10 Apr 2003 10:21:29 -0000 1.9 @@ -1,159 +1,175 @@ Revision history for Perl module XML::Simple +2.04 Mar 10 2004 + - integrated a patch from Michel Rodriguez + + new facility for removing extra levels of indirection (using + the new 'GroupTags' option) + + new facility for rolling the dreaded 'content' hash up into a + scalar if there are no keys left after array folding (using the + '-' prefix mode on the ContentKey option) + + new facility for doing variable substitution in the XML; variables + can be defined in Perl (using the new 'Variables' option) or in + the XML document (using the new 'VarAttr' option) + - added 'NormaliseSpace' option for tidying up hash keys and other + text content if required (feature requested by Alex Manoussakis) + - option names are now case-insensitive and can include underscores + - XMLin() and XMLout() are now aliased to xml_in() and xml_out() when + called as methods or imported explicitly + - option names passed to XML::Simple->new() are now validated + 2.03 Jan 20 2003 - - fixed circular reference check which was incorrectly catching - 'parallel' references (patch from Theo Lengyel) + - fixed circular reference check which was incorrectly catching + 'parallel' references (patch from Theo Lengyel) 2.02 Dec 15 2002 - - changed Storable calls to use locking (reported by Randal - Schwarz) + - changed Storable calls to use locking (reported by Randal Schwarz) 2.01 Dec 11 2002 - - fixed bug whereby :strict mode required forcearray on - XMLout() (reported by Ville Skytta) + - fixed bug whereby :strict mode required forcearray on + XMLout() (reported by Ville Skytta) 2.00 Dec 08 2002 - - first production release with SAX support - - added support for 'strict mode' using :strict import tag - - removed locking code (as it was incompatible with iThreads) - - integrated patch for test failures from Sean Campbell - - fixed stringification of references during folding (reported - by Trond Michelsen) - - fixed incompatability with Tie::IxHash (reported by - Venkataramana Mokkapati) - - POD: alphabetised options (patch from John Borwick) - - POD: updated suppressempty (patch from Kjetil Kjernsmo) - - added FAQ.pod to distribution and added new questions + - first production release with SAX support + - added support for 'strict mode' using :strict import tag + - removed locking code (as it was incompatible with iThreads) + - integrated patch for test failures from Sean Campbell + - fixed stringification of references during folding (reported + by Trond Michelsen) + - fixed incompatability with Tie::IxHash (reported by + Venkataramana Mokkapati) + - POD: alphabetised options (patch from John Borwick) + - POD: updated suppressempty (patch from Kjetil Kjernsmo) + - added FAQ.pod to distribution and added new questions 1.08_01 Feb 14 2002 - beta release for testing SAX support - - fixed errors with default namespace handling - - minor POD updates + - fixed errors with default namespace handling + - minor POD updates 1.08 Feb 09 2002 - - re-release of 1.06 (stable) with minor updates ... - - searchpath option now defaults to current directory if not set - - fix to Storable test routine for test failures on Win32 - - removed obselete 'convert' script from distribution + - re-release of 1.06 (stable) with minor updates ... + - searchpath option now defaults to current directory if not set + - fix to Storable test routine for test failures on Win32 + - removed obselete 'convert' script from distribution 1.07b Feb 05 2002 - beta release for testing SAX support - - added SAX support including: - + using SAX parsers - + acting as a SAX handler - + generating SAX events from XMLout() with new Handler option - + acting as a SAX filter (via new DataHandler option) - - added $ENV{XML_SIMPLE_PREFERRED_PARSER} and - $XML::Simple::PREFERRED_PARSER for selecting a parser module - - added namespace support (SAX only) with nsexpand option for both - XMLin() and XMLout() - - searchpath now defaults to current directory - - parseropts option now officially deprecated - - removed obselete 'convert' script from distribution - - many POD updates (more to come) + - added SAX support including: + + using SAX parsers + + acting as a SAX handler + + generating SAX events from XMLout() with new Handler option + + acting as a SAX filter (via new DataHandler option) + - added $ENV{XML_SIMPLE_PREFERRED_PARSER} and + $XML::Simple::PREFERRED_PARSER for selecting a parser module + - added namespace support (SAX only) with nsexpand option for both + XMLin() and XMLout() + - searchpath now defaults to current directory + - parseropts option now officially deprecated + - removed obselete 'convert' script from distribution + - many POD updates (more to come) 1.06 Nov 19 2001 - - fixed version number in default xmldecl (thanks to Matt Sergeant for - bug report and patch) - - updated contact email address for author + - fixed version number in default xmldecl (thanks to Matt Sergeant for + bug report and patch) + - updated contact email address for author 1.05 Aug 31 2000 - - code re-org to make internals all OO for easier extending - - added 'noattr' option to tell XMLout() not to use attributes (only - nested elements) and XMLin() to discard attributes - - added 'suppressempty' option to tell XMLin what to do with elements - with no attributes and no content - - added 'parseropts' option for specifying options which should be - passed to the underlying XML::Parser object - - added 'forcecontent' option to force text content to parse to a - hash value even if the element has no attributes - - fix for forcearray getting applied to text content - - integrated patch from Paul Lindner to work around filenames sometimes - being seen as XML when running under mod_perl - - integrated patch from Edward Avis: filename '-' means stdin - - fixed bug where a missing key attribute could cause a crash - - added a warning message for above situation - - added 'support' for CDATA sections - they always worked, but now - they're in the test suite which should ensure they keep working - - fixed error message when caching enabled but parsing from filehandle - - fixed empty elements being skipped by XMLout() when folding enabled - - fixed text content of '0' being skipped by XMLout() + - code re-org to make internals all OO for easier extending + - added 'noattr' option to tell XMLout() not to use attributes (only + nested elements) and XMLin() to discard attributes + - added 'suppressempty' option to tell XMLin what to do with elements + with no attributes and no content + - added 'parseropts' option for specifying options which should be + passed to the underlying XML::Parser object + - added 'forcecontent' option to force text content to parse to a + hash value even if the element has no attributes + - fix for forcearray getting applied to text content + - integrated patch from Paul Lindner to work around filenames sometimes + being seen as XML when running under mod_perl + - integrated patch from Edward Avis: filename '-' means stdin + - fixed bug where a missing key attribute could cause a crash + - added a warning message for above situation + - added 'support' for CDATA sections - they always worked, but now + they're in the test suite which should ensure they keep working + - fixed error message when caching enabled but parsing from filehandle + - fixed empty elements being skipped by XMLout() when folding enabled + - fixed text content of '0' being skipped by XMLout() 1.04 Apr 03 2000 - - fix for text content being skipped by XMLout - - added (optional) OO interface for changing default options - - added 'keeproot' option (requested by Mark D. Anderson - MDA) - - added 'contentkey' option (also requested by MDA) - - incorporated 'forcearray' as arrayref patch from Andrew McNaughton + - fix for text content being skipped by XMLout + - added (optional) OO interface for changing default options + - added 'keeproot' option (requested by Mark D. Anderson - MDA) + - added 'contentkey' option (also requested by MDA) + - incorporated 'forcearray' as arrayref patch from Andrew McNaughton 1.03 Mar 05 2000 - - added 'maketest' script for make impaired platforms - - yet more cross platform robustness added to test scripts incl - workaround for Win32 problem where writing to file changed contents - but not timestamp(!) - - backed out one overzealous use of File::Spec in test script - - POD updates including XML::Twig description contributed by Michel - Rodriguez + - added 'maketest' script for make impaired platforms + - yet more cross platform robustness added to test scripts incl + workaround for Win32 problem where writing to file changed contents + but not timestamp(!) + - backed out one overzealous use of File::Spec in test script + - POD updates including XML::Twig description contributed by Michel + Rodriguez 1.02b Feb 16 2000 - limited distribution beta - - reinstated locking with new backwards compatibility code - - fixed platform dependant pathname handling to use File::Basename & - File::Spec in XML::Simple.pm and test scripts - - fixed bug causing XMLout() to incorrectly barf on what it thought was - a recursive data structure - - removed spurious checking code which stopped XMLout unfolding a - single nested hash - - fixed t/4_MemShare.t to gracefully cope with the absense of utime() - - changed t/3_Storable.t and t/5_MemCopy.t to skip gracefully if no - Storable.pm - - removed superflous eval blocks around requires + - reinstated locking with new backwards compatibility code + - fixed platform dependant pathname handling to use File::Basename & + File::Spec in XML::Simple.pm and test scripts + - fixed bug causing XMLout() to incorrectly barf on what it thought was + a recursive data structure + - removed spurious checking code which stopped XMLout unfolding a + single nested hash + - fixed t/4_MemShare.t to gracefully cope with the absense of utime() + - changed t/3_Storable.t and t/5_MemCopy.t to skip gracefully if no + Storable.pm + - removed superflous eval blocks around requires 1.01 Dec 1 1999 - - removed faulty locking code pending a fix + - removed faulty locking code pending a fix 1.00 Nov 25 1999 - - added escaping feature + noescape option - - added xmldecl option - - further tidy ups for thread safing - - more POD revisions (incl: pointers to other modules) + - added escaping feature + noescape option + - added xmldecl option + - further tidy ups for thread safing + - more POD revisions (incl: pointers to other modules) 0.95 Nov 2 1999 - - added rootname option - - added outputfile option - - lots of internal tidy ups for thread safing - - fixed bug in check for XML string to XMLin() - - extra tests (esp option handling) + - added rootname option + - added outputfile option + - lots of internal tidy ups for thread safing + - fixed bug in check for XML string to XMLin() + - extra tests (esp option handling) 0.90 Oct 14 1999 (first beta release) - - module renamed to XML::Simple ready for CPAN upload - - XMLToOpt() renamed to XMLin() - - OptToXML() renamed to XMLout() - - added 'convert' script + - module renamed to XML::Simple ready for CPAN upload + - XMLToOpt() renamed to XMLin() + - OptToXML() renamed to XMLout() + - added 'convert' script 0.05 Sep 18 1999 - - fixed location of XML.pm in distribution (make install didn't work) - - added tests for MemCopy - - fixed ABSTRACT_FROM in Makefile.PL - - fixed PREREQ_PM in Makefile.PL + - fixed location of XML.pm in distribution (make install didn't work) + - added tests for MemCopy + - fixed ABSTRACT_FROM in Makefile.PL + - fixed PREREQ_PM in Makefile.PL 0.04 Aug 10 1999 - - added caching using Storable.pm - - updated MANIFEST to include missing test files + - added caching using Storable.pm + - updated MANIFEST to include missing test files 0.03 Jun 20 1999 - - rewrite of OptToXML - - anonymous array support - - more and better test routines - - POD updates + - rewrite of OptToXML + - anonymous array support + - more and better test routines + - POD updates 0.02 Jun 10 1999 - - added support for OptToXML - - fixed searchpath inconsistencies - - added 'forcearray' option - - POD improvements - - much improved test routines + - added support for OptToXML + - fixed searchpath inconsistencies + - added 'forcearray' option + - POD improvements + - much improved test routines 0.01 May 27 1999 - - original version; created by h2xs 1.18 - - module called 'Getopt::XML' - - included basic XMLToOpt routine + - original version; created by h2xs 1.18 + - module called 'Getopt::XML' + - included basic XMLToOpt routine Index: README =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/README,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- README 20 Jan 2003 07:48:59 -0000 1.8 +++ README 10 Apr 2003 10:21:29 -0000 1.9 @@ -56,16 +56,26 @@ STATUS - This version (2.03) is the current stable release. + This version (2.04) is the current stable release. Please send any feedback to the author: gr...@cp... NEW IN THIS RELEASE + - new 'GroupTags' option (patch from Michel Rodriguez) + - optionally collapse 'content' hashes to scalars after folding + (also from Michel) + - new variable substitution facility via 'Variables' and 'VarAttr' + options (Michel again) + - new 'NormaliseSpace' option (suggested by Alex Manoussakis) + - option names are no longer case-sensitive and can include '_' + - XMLin() and XMLout() aliased to xml_in() and xml_out() + + New in Version 2.03 - fixed circular reference check which was incorrectly catching 'parallel' references (patch from Theo Lengyel) - New in Version 2.03: + New in Version 2.02: - changed Storable calls to use locking New in Version 2.01: |
From: Grant M. <gr...@us...> - 2003-04-10 10:20:16
|
Update of /cvsroot/perl-xml/xml-simple/t In directory sc8-pr-cvs1:/tmp/cvs-serv18853 Modified Files: 1_XMLin.t 2_XMLout.t 3_Storable.t 6_ObjIntf.t 9_Strict.t Log Message: - tests for new features in release 2.04 Index: 1_XMLin.t =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/t/1_XMLin.t,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- 1_XMLin.t 20 Jan 2003 07:48:59 -0000 1.10 +++ 1_XMLin.t 10 Apr 2003 10:20:06 -0000 1.11 @@ -15,14 +15,14 @@ plan skip_all => 'Test data missing'; } -plan tests => 66; +plan tests => 93; $@ = ''; eval "use XML::Simple;"; is($@, '', 'Module compiled OK'); -unless($XML::Simple::VERSION eq '2.03') { - diag("Warning: XML::Simple::VERSION = $XML::Simple::VERSION (expected 2.03)"); +unless($XML::Simple::VERSION eq '2.04') { + diag("Warning: XML::Simple::VERSION = $XML::Simple::VERSION (expected 2.04)"); } @@ -134,13 +134,14 @@ {name => 'item2', attr1 => 'value3', attr2 => 'value4' } ] }; -$opt = XMLin($string, keyattr => [] ); +my @cont_key = (contentkey => '-content'); +$opt = XMLin($string, keyattr => [], @cont_key); is_deeply($opt, $target, 'not folded when keyattr turned off'); # Same again with alternative key suppression -$opt = XMLin($string, keyattr => {} ); +$opt = XMLin($string, keyattr => {}, @cont_key); is_deeply($opt, $target, 'still works when keyattr is empty hash'); @@ -151,7 +152,7 @@ <item key="item1" attr1="value1" attr2="value2" /> <item key="item2" attr1="value3" attr2="value4" /> </opt> -)); +), @cont_key); is_deeply($opt, { item => { item1 => { attr1 => 'value1', attr2 => 'value2' }, @@ -165,7 +166,7 @@ <item id="item1" attr1="value1" attr2="value2" /> <item id="item2" attr1="value3" attr2="value4" /> </opt> -)); +), @cont_key); is_deeply($opt, { item => { item1 => { attr1 => 'value1', attr2 => 'value2' }, @@ -189,28 +190,40 @@ } }; -$opt = XMLin($xml, keyattr => [qw(xname)]); +$opt = XMLin($xml, keyattr => [qw(xname)], @cont_key); is_deeply($opt, $target, "folded on non-default key 'xname'"); # And with precise element/key specification -$opt = XMLin($xml, keyattr => { 'item' => 'xname' }); +$opt = XMLin($xml, keyattr => { 'item' => 'xname' }, @cont_key); is_deeply($opt, $target, 'same again but keyattr set with hash'); # Same again but with key field further down the list -$opt = XMLin($xml, keyattr => [qw(wibble xname)]); +$opt = XMLin($xml, keyattr => [qw(wibble xname)], @cont_key); is_deeply($opt, $target, 'keyattr as array with value in second position'); # Same again but with key field supplied as scalar -$opt = XMLin($xml, keyattr => qw(xname)); +$opt = XMLin($xml, keyattr => qw(xname), @cont_key); is_deeply($opt, $target, 'keyattr as scalar'); +# Same again but with mixed-case option name + +$opt = XMLin($xml, KeyAttr => qw(xname), @cont_key); +is_deeply($opt, $target, 'KeyAttr as scalar'); + + +# Same again but with underscores in option name + +$opt = XMLin($xml, key_attr => qw(xname), @cont_key); +is_deeply($opt, $target, 'key_attr as scalar'); + + # Weird variation, not exactly what we wanted but it is what we expected # given the current implementation and we don't want to break it accidently @@ -229,7 +242,7 @@ } }; -$opt = XMLin($xml); +$opt = XMLin($xml, @cont_key); is_deeply($opt, $target, 'fold same array on two different keys'); @@ -241,7 +254,7 @@ 'three' => { 'value' => '3' }, } }; -$opt = XMLin($xml, keyattr => { 'item' => 'id' }); +$opt = XMLin($xml, keyattr => { 'item' => 'id' }, @cont_key); is_deeply($opt, $target, 'same again but with priority switch'); @@ -281,7 +294,8 @@ } }; -$opt = XMLin($xml, forcearray => 1, keyattr => { 'car' => 'license', 'option' => 'pn' }); +$opt = XMLin($xml, forcearray => 1, + keyattr => { 'car' => 'license', 'option' => 'pn' }, @cont_key); is_deeply($opt, $target, 'folded on multi-key keyattr hash'); @@ -313,7 +327,7 @@ } } }; -$opt = XMLin($xml, forcearray => 1, keyattr => { 'car' => '+license', 'option' => '-pn' }); +$opt = XMLin($xml, forcearray => 1, keyattr => { 'car' => '+license', 'option' => '-pn' }, @cont_key); is_deeply($opt, $target, "same again but with '+' prefix to copy keys"); @@ -338,20 +352,22 @@ ] }; -$opt = XMLin($xml); +$opt = XMLin($xml, @cont_key); is_deeply($opt, $target, "did not fold on default key with non-scalar value"); -$opt = XMLin($xml, keyattr => { item => 'name' }); +$opt = XMLin($xml, keyattr => { item => 'name' }, @cont_key); is_deeply($opt, $target, "did not fold on specific key with non-scalar value"); # Make sure that the root element name is preserved if we ask for it $target = XMLin("<opt>$xml</opt>", forcearray => 1, - keyattr => { 'car' => '+license', 'option' => '-pn' }); + keyattr => { 'car' => '+license', 'option' => '-pn' }, + @cont_key); $opt = XMLin( $xml, forcearray => 1, keeproot => 1, - keyattr => { 'car' => '+license', 'option' => '-pn' }); + keyattr => { 'car' => '+license', 'option' => '-pn' }, + @cont_key); is_deeply($opt, $target, 'keeproot option works'); @@ -359,13 +375,13 @@ # confirm that CDATA sections parse correctly $xml = q{<opt><cdata><![CDATA[<greeting>Hello, world!</greeting>]]></cdata></opt>}; -$opt = XMLin($xml); +$opt = XMLin($xml, @cont_key); is_deeply($opt, { 'cdata' => '<greeting>Hello, world!</greeting>' }, 'CDATA section parsed correctly'); $xml = q{<opt><x><![CDATA[<y>one</y>]]><![CDATA[<y>two</y>]]></x></opt>}; -$opt = XMLin($xml); +$opt = XMLin($xml, @cont_key); is_deeply($opt, { 'x' => '<y>one</y><y>two</y>' }, 'CDATA section containing markup characters parsed correctly'); @@ -396,7 +412,7 @@ $@ = ''; $opt = eval { XMLin('test2.xml', searchpath => [ - 'dir1', 'dir2', File::Spec->catdir('t', 'subdir') + 'dir1', 'dir2', File::Spec->catdir('t', 'subdir'), @cont_key ] ); }; @@ -424,7 +440,7 @@ $XMLFile = File::Spec->catfile('t', '1_XMLin.xml'); # t/1_XMLin.xml eval { $fh->open($XMLFile) || die "$!"; - $opt = XMLin($fh); + $opt = XMLin($fh, @cont_key); }; is($@, '', "XMLin didn't choke on an IO::File object"); is($opt->{location}, 't/1_XMLin.xml', 'and it parsed the right file'); @@ -456,7 +472,7 @@ <anon>2.0</anon><anon>2.1</anon><anon>2.2</anon> </row> </opt> -)); +), @cont_key); is_deeply($opt, { row => [ [ '0.0', '0.1', '0.2' ], @@ -474,7 +490,7 @@ <anon>two</anon> <anon>three</anon> </opt> -}); +}, @cont_key); is_deeply($opt, [ qw(one two three) ], 'top level anonymous array returned arrayref'); @@ -491,7 +507,7 @@ </anon> </anon> </opt> -)); +), @cont_key); is_deeply($opt, [ 1, [ @@ -558,11 +574,37 @@ }, "even when we change it's name to 'text'"); +# Confirm that spurious 'content' keys are *not* eliminated after array folding + +$xml = q(<opt><x y="one">First</x><x y="two">Second</x></opt>); +$opt = XMLin($xml, forcearray => [ 'x' ], keyattr => {x => 'y'}); +is_deeply($opt, { + x => { + one => { content => 'First' }, + two => { content => 'Second' }, + } +}, "spurious content keys not eliminated after folding"); + + +# unless we ask nicely + +$xml = q(<opt><x y="one">First</x><x y="two">Second</x></opt>); +$opt = XMLin( + $xml, forcearray => [ 'x' ], keyattr => {x => 'y'}, contentkey => '-content' +); +is_deeply($opt, { + x => { + one => 'First', + two => 'Second', + } +}, "spurious content keys not eliminated after folding"); + + # Check that mixed content parses in the weird way we expect $xml = q(<p class="mixed">Text with a <b>bold</b> word</p>); -is_deeply(XMLin($xml), { +is_deeply(XMLin($xml, @cont_key), { 'class' => 'mixed', 'content' => [ 'Text with a ', ' word' ], 'b' => 'bold' @@ -584,7 +626,7 @@ # Unless 'forcearray' option is specified -$opt = XMLin($string, forcearray => 1); +$opt = XMLin($string, forcearray => 1, @cont_key); is_deeply($opt, { name => [ 'value' ] }, 'except when forcearray is enabled'); @@ -596,7 +638,7 @@ <inner name="one" value="1" /> </opt>); -$opt = XMLin($string, forcearray => 1); +$opt = XMLin($string, forcearray => 1, @cont_key); is_deeply($opt, { 'inner' => { 'one' => { 'value' => 1 } } }, 'array folding works with single nested hash'); @@ -604,7 +646,7 @@ # But not without forcearray option specified -$opt = XMLin($string, forcearray => 0); +$opt = XMLin($string, forcearray => 0, @cont_key); is_deeply($opt, { 'inner' => { 'name' => 'one', 'value' => 1 } }, 'but not if forcearray is turned off'); @@ -621,7 +663,7 @@ </opt> ); -$opt = XMLin($xml, forcearray => [ 'two' ]); +$opt = XMLin($xml, forcearray => [ 'two' ], @cont_key); is_deeply($opt, { 'zero' => '0', 'one' => 'i', @@ -637,7 +679,7 @@ </opt> ); -$opt = XMLin($xml, noattr => 1); +$opt = XMLin($xml, noattr => 1, @cont_key); is_deeply($opt, { nest => 'text' }, 'attributes successfully skipped'); @@ -651,7 +693,7 @@ }; -$opt = XMLin($xml, noattr => 1); +$opt = XMLin($xml, noattr => 1, @cont_key); is_deeply($opt, { 'item' => { 'a' => { 'value' => 'alpha' }, @@ -671,7 +713,7 @@ </outer> </body>); -$opt = XMLin($xml, noattr => 1); +$opt = XMLin($xml, noattr => 1, @cont_key); is_deeply($opt, { 'name' => 'bob', 'outer' => { @@ -683,13 +725,13 @@ # Unless 'suppressempty' is enabled -$opt = XMLin($xml, noattr => 1, suppressempty => 1); +$opt = XMLin($xml, noattr => 1, suppressempty => 1, @cont_key); is_deeply($opt, { 'name' => 'bob', }, 'or are suppressed'); # Check behaviour when 'suppressempty' is set to to undef; -$opt = XMLin($xml, noattr => 1, suppressempty => undef); +$opt = XMLin($xml, noattr => 1, suppressempty => undef, @cont_key); is_deeply($opt, { 'name' => 'bob', 'outer' => { @@ -700,7 +742,7 @@ # Check behaviour when 'suppressempty' is set to to empty string; -$opt = XMLin($xml, noattr => 1, suppressempty => ''); +$opt = XMLin($xml, noattr => 1, suppressempty => '', @cont_key); is_deeply($opt, { 'name' => 'bob', 'outer' => { @@ -718,10 +760,274 @@ </outer> </body>); -$opt = XMLin($xml, noattr => 1, suppressempty => 1); +$opt = XMLin($xml, noattr => 1, suppressempty => 1, @cont_key); is($opt, undef, 'empty document parses to undef'); +# Confirm nothing magical happens with grouped elements + +$xml = q(<opt> + <prefix>before</prefix> + <dirs> + <dir>/usr/bin</dir> + <dir>/usr/local/bin</dir> + </dirs> + <suffix>after</suffix> +</opt>); + +$opt = XMLin($xml); +is_deeply($opt, { + prefix => 'before', + dirs => { + dir => [ '/usr/bin', '/usr/local/bin' ] + }, + suffix => 'after', +}, 'grouped tags parse normally'); + + +# unless we specify how the grouping works + +$xml = q(<opt> + <prefix>before</prefix> + <dirs> + <dir>/usr/bin</dir> + <dir>/usr/local/bin</dir> + </dirs> + <suffix>after</suffix> +</opt>); + +$opt = XMLin($xml, grouptags => {dirs => 'dir'} ); +is_deeply($opt, { + prefix => 'before', + dirs => [ '/usr/bin', '/usr/local/bin' ], + suffix => 'after', +}, 'disintermediation of grouped tags works'); + + +# try again with multiple groupings + +$xml = q(<opt> + <prefix>before</prefix> + <dirs> + <dir>/usr/bin</dir> + <dir>/usr/local/bin</dir> + </dirs> + <infix>between</infix> + <terms> + <term>vt100</term> + <term>xterm</term> + </terms> + <suffix>after</suffix> +</opt>); + +$opt = XMLin($xml, grouptags => {dirs => 'dir', terms => 'term'} ); +is_deeply($opt, { + prefix => 'before', + dirs => [ '/usr/bin', '/usr/local/bin' ], + infix => 'between', + terms => [ 'vt100', 'xterm' ], + suffix => 'after', +}, 'disintermediation works with multiple groups'); + + +# confirm folding and ungrouping work together + +$xml = q(<opt> + <prefix>before</prefix> + <dirs> + <dir name="first">/usr/bin</dir> + <dir name="second">/usr/local/bin</dir> + </dirs> + <suffix>after</suffix> +</opt>); + +$opt = XMLin($xml, keyattr => {dir => 'name'}, grouptags => {dirs => 'dir'} ); +is_deeply($opt, { + prefix => 'before', + dirs => { + first => { content => '/usr/bin' }, + second => { content => '/usr/local/bin' }, + }, + suffix => 'after', +}, 'folding and ungrouping work together'); + + +# confirm folding, ungrouping and content stripping work together + +$xml = q(<opt> + <prefix>before</prefix> + <dirs> + <dir name="first">/usr/bin</dir> + <dir name="second">/usr/local/bin</dir> + </dirs> + <suffix>after</suffix> +</opt>); + +$opt = XMLin($xml, + contentkey => '-text', + keyattr => {dir => 'name'}, + grouptags => {dirs => 'dir'} +); +is_deeply($opt, { + prefix => 'before', + dirs => { + first => '/usr/bin', + second => '/usr/local/bin', + }, + suffix => 'after', +}, 'folding, ungrouping and content stripping work together'); + + +# confirm folding fails as expected even with ungrouping but (no forcearray) + +$xml = q(<opt> + <prefix>before</prefix> + <dirs> + <dir name="first">/usr/bin</dir> + </dirs> + <suffix>after</suffix> +</opt>); + +$opt = XMLin($xml, + contentkey => '-text', + keyattr => {dir => 'name'}, + grouptags => {dirs => 'dir'} +); +is_deeply($opt, { + prefix => 'before', + dirs => { name => 'first', text => '/usr/bin'}, + suffix => 'after', +}, 'folding without forcearray but with ungrouping fails as expected'); + + +# but works with forcearray enabled + +$xml = q(<opt> + <prefix>before</prefix> + <dirs> + <dir name="first">/usr/bin</dir> + </dirs> + <suffix>after</suffix> +</opt>); + +$opt = XMLin($xml, + contentkey => '-text', + forcearray => [ 'dir' ], + keyattr => {dir => 'name'}, + grouptags => {dirs => 'dir'} +); +is_deeply($opt, { + prefix => 'before', + dirs => {'first' => '/usr/bin'}, + suffix => 'after', +}, 'folding with forcearray and ungrouping works'); + + +# Test variable expansion - when no variables are defined + +$xml = q(<opt> + <file name="config_file">${conf_dir}/appname.conf</file> + <file name="log_file">${log_dir}/appname.log</file> + <file name="debug_file">${log_dir}/appname.dbg</file> +</opt>); + +$opt = XMLin($xml, contentkey => '-content'); +is_deeply($opt, { + file => { + config_file => '${conf_dir}/appname.conf', + log_file => '${log_dir}/appname.log', + debug_file => '${log_dir}/appname.dbg', + } +}, 'undefined variables are left untouched'); + + +# try again but with variables defined in advance + +$opt = XMLin($xml, + contentkey => '-content', + variables => { conf_dir => '/etc', log_dir => '/var/log' } +); +is_deeply($opt, { + file => { + config_file => '/etc/appname.conf', + log_file => '/var/log/appname.log', + debug_file => '/var/log/appname.dbg', + } +}, 'substitution of pre-defined variables works'); + + +# now try defining them in the XML + +$xml = q(<opt> + <dir xsvar="conf_dir">/etc</dir> + <dir xsvar="log_dir">/var/log</dir> + <file name="config_file">${conf_dir}/appname.conf</file> + <file name="log_file">${log_dir}/appname.log</file> + <file name="debug_file">${log_dir}/appname.dbg</file> +</opt>); + +$opt = XMLin($xml, contentkey => '-content', varattr => 'xsvar'); +is_deeply($opt, { + file => { + config_file => '/etc/appname.conf', + log_file => '/var/log/appname.log', + debug_file => '/var/log/appname.dbg', + }, + dir => [ + { xsvar => 'conf_dir', content => '/etc' }, + { xsvar => 'log_dir', content => '/var/log' }, + ] +}, 'variables defined in XML work'); + + +# confirm that variables in XML are merged with pre-defined ones + +$xml = q(<opt> + <dir xsvar="log_dir">/var/log</dir> + <file name="config_file">${conf_dir}/appname.conf</file> + <file name="log_file">${log_dir}/appname.log</file> + <file name="debug_file">${log_dir}/appname.dbg</file> +</opt>); + +$opt = XMLin($xml, + contentkey => '-content', + varattr => 'xsvar', + variables => { conf_dir => '/etc', log_dir => '/tmp' } +); +is_deeply($opt, { + file => { + config_file => '/etc/appname.conf', + log_file => '/var/log/appname.log', + debug_file => '/var/log/appname.dbg', + }, + dir => { xsvar => 'log_dir', content => '/var/log' }, +}, 'variables defined in XML merged successfully with predefined vars'); + + +# confirm that a variables are expanded in variable definitions + +$xml = q(<opt> + <dirs> + <dir name="prefix">/usr/local/apache</dir> + <dir name="exec_prefix">${prefix}</dir> + <dir name="bin_dir">${exec_prefix}/bin</dir> + </dirs> +</opt>); + +$opt = XMLin($xml, + contentkey => '-content', + varattr => 'name', + grouptags => { dirs => 'dir' }, +); +is_deeply($opt, { + dirs => { + prefix => '/usr/local/apache', + exec_prefix => '/usr/local/apache', + bin_dir => '/usr/local/apache/bin', + } +}, 'variables are expanded in later variable definitions'); + + # Test option error handling $@=''; @@ -736,9 +1042,59 @@ 'with correct error message'); +# Test the NormaliseSpace option + +$xml = q(<opt> + <user name=" Joe + Bloggs " id=" one two "/> + <user> + <name> Jane + Doe </name> + <id> + three + four + </id> + </user> +</opt>); + +$opt = XMLin($xml, KeyAttr => [ 'name' ], NormaliseSpace => 1); +ok(ref($opt->{user}) eq 'HASH', "NS-1: folding OK"); +ok(exists($opt->{user}->{'Joe Bloggs'}), "NS-2: space normalised in hash key"); +ok(exists($opt->{user}->{'Jane Doe'}), "NS-3: space normalised in hash key"); +like($opt->{user}->{'Jane Doe'}->{id}, qr{^\s\s+three\s\s+four\s\s+$}s, + "NS-4: space not normalised in hash value"); + +$opt = XMLin($xml, KeyAttr => [ 'name' ], NormaliseSpace => 2); +ok(ref($opt->{user}) eq 'HASH', "NS-5: folding OK"); +ok(exists($opt->{user}->{'Joe Bloggs'}), "NS-6: space normalised in hash key"); +like($opt->{user}->{'Joe Bloggs'}->{id}, qr{^one\stwo$}s, + "NS-7: space normalised in attribute value"); +ok(exists($opt->{user}->{'Jane Doe'}), "NS-8: space normalised in hash key"); +like($opt->{user}->{'Jane Doe'}->{id}, qr{^three\sfour$}s, + "NS-9: space normalised in element text content"); + +# confirm NormaliseSpace works in anonymous arrays too + +$xml = q(<opt> + <anon> one two </anon><anon> three + four five </anon><anon> six </anon><anon> seveneightnine </anon> +</opt>); + +$opt = XMLin($xml, NormaliseSpace => 2); +is_deeply($opt, [ 'one two', 'three four five', 'six', 'seveneightnine' ], + "NS-10: space normalised in anonymous array"); + +# Check that American speeling works too + +$opt = XMLin($xml, NormalizeSpace => 2); +is_deeply($opt, [ 'one two', 'three four five', 'six', 'seveneightnine' ], + "NS-11: space normalized in anonymous array"); + # Now for a 'real world' test, try slurping in an SRT config file -$opt = XMLin(File::Spec->catfile('t', 'srt.xml'), forcearray => 1); +$opt = XMLin(File::Spec->catfile('t', 'srt.xml'), + forcearray => 1, @cont_key +); $target = { 'global' => [ { Index: 2_XMLout.t =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/t/2_XMLout.t,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- 2_XMLout.t 20 Jan 2003 07:48:10 -0000 1.5 +++ 2_XMLout.t 10 Apr 2003 10:20:07 -0000 1.6 @@ -5,7 +5,7 @@ use Test::More; use IO::File; -plan tests => 174; +plan tests => 190; ############################################################################## # S U P P O R T R O U T I N E S @@ -681,6 +681,13 @@ like($_, qr{^\s*<opt\s+one="1">text</opt>\s*$}s, 'even when name changed'); +# and also if we add the '-' prefix + +$_ = XMLout($ref, contentkey => '-text_content'); + +like($_, qr{^\s*<opt\s+one="1">text</opt>\s*$}s, 'even with "-" prefix'); + + # Check 'noattr' option $ref = { @@ -748,6 +755,129 @@ ok(s{\s*<(word)>thirty two</\1>\s*}{32}s, 'scalar 2.1 mapped OK'); ok(s{\s*<(number)>323232</\1>\s*}{NUM}s, 'element 2 OK'); like($_, qr{^<(\w+)\s*>NUMNUM</\1>$}, 'document OK'); + + +# Check grouped tags get ungrouped correctly + +$ref = { + prefix => 'before', + dirs => [ '/usr/bin', '/usr/local/bin' ], + suffix => 'after', +}; + +# Expect: +# +# <opt> +# <prefix>before</prefix> +# <dirs> +# <dir>/usr/bin</dir> +# <dir>/usr/local/bin</dir> +# </dirs> +# <suffix>after</suffix> +# </opt> +# + +$_ = XMLout($ref, grouptags => {dirs => 'dir'}, noattr => 1); + +ok(s{\s*<(prefix)>before</\1>\s*}{ELEM}s, 'prefix OK'); +ok(s{\s*<(suffix)>after</\1>\s*}{ELEM}s, 'suffix OK'); +ok(s{\s*<dir>/usr/bin</dir>\s*<dir>/usr/local/bin</dir>\s*}{LIST}s, 'list OK'); +ok(s{\s*<dirs>LIST</dirs>\s*}{ELEM}s, 'group OK'); +like($_, qr{^<(\w+)\s*>ELEMELEMELEM</\1>$}, 'document OK'); + + +# Try again with multiple groupings + +$ref = { + dirs => [ '/usr/bin', '/usr/local/bin' ], + terms => [ 'vt100', 'xterm' ], +}; + +# Expect: +# +# <opt> +# <dirs> +# <dir>/usr/bin</dir> +# <dir>/usr/local/bin</dir> +# </dirs> +# <terms> +# <term>vt100</term> +# <term>xterm</term> +# </terms> +# </opt> +# + +$_ = XMLout($ref, grouptags => {dirs => 'dir', terms => 'term'}, noattr => 1); + +ok(s{\s*<dir>/usr/bin</dir>\s*<dir>/usr/local/bin</dir>\s*}{LIST}s, 'list 1 OK'); +ok(s{\s*<dirs>LIST</dirs>\s*}{ELEM}s, 'group 1 OK'); +ok(s{\s*<term>vt100</term>\s*<term>xterm</term>\s*}{LIST}s, 'list 2 OK'); +ok(s{\s*<terms>LIST</terms>\s*}{ELEM}s, 'group 2 OK'); +like($_, qr{^<(\w+)\s*>ELEMELEM</\1>$}, 'document OK'); + + +# Confirm unfolding and grouping work together + +$ref = { + dirs => { + first => { content => '/usr/bin' }, + second => { content => '/usr/local/bin' }, + }, +}; + +# Expect: +# +# <opt> +# <dirs> +# <dir name="first">/usr/bin</dir> +# <dir name="second">/usr/local/bin</dir> +# </dirs> +# </opt> +# + +$_ = XMLout($ref, + grouptags => {dirs => 'dir'}, keyattr => {dir => 'name'}, +); + +ok(s{\s*<dir\s+name="first">/usr/bin</dir>\s*}{ITEM}s, 'item 1 OK'); +ok(s{\s*<dir\s+name="second">/usr/local/bin</dir>\s*}{ITEM}s, 'item 2 OK'); +ok(s{\s*<dirs>ITEMITEM</dirs>\s*}{GROUP}s, 'group OK'); +like($_, qr{^<(\w+)\s*>GROUP</\1>$}, 'document OK'); + + +# Combine unfolding, grouping and stripped content - watch it fail :-( + +$ref = { + dirs => { + first => '/usr/bin', + second => '/usr/local/bin' + }, +}; + +# Expect: +# +# <opt> +# <dirs first="/usr/bin" second="/usr/local/bin" /> +# </opt> +# + +$_ = XMLout($ref, + grouptags => {dirs => 'dir'}, keyattr => {dir => 'name'}, + contentkey => '-content' +); + +like($_, qr{ + ^<(\w+)>\s* + <dirs>\s* + <dir + (?: + \s+first="/usr/bin" + |\s+second="/usr/local/bin" + ){2}\s* + />\s* + </dirs>\s* + </\1>$ +}x, 'Failed to unwrap/group stripped content - as expected'); # 'Stress test' with a data structure that maps to several thousand elements. Index: 3_Storable.t =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/t/3_Storable.t,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- 3_Storable.t 16 Oct 2002 09:43:35 -0000 1.5 +++ 3_Storable.t 10 Apr 2003 10:20:08 -0000 1.6 @@ -36,7 +36,7 @@ } -plan tests => 20; +plan tests => 21; ############################################################################## # S U P P O R T R O U T I N E S @@ -175,6 +175,11 @@ PassTime($t1); $opt = XMLin($XMLFile, cache => 'storable'); is_deeply($opt, $Expected, 'parsed expected data in through cache'); + +# Make sure scheme name is case-insensitive + +$opt = XMLin($XMLFile, cache => 'Storable'); +is_deeply($opt, $Expected, 'scheme name is case-insensitive'); # Clean up and go Index: 6_ObjIntf.t =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/t/6_ObjIntf.t,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- 6_ObjIntf.t 16 Oct 2002 09:43:35 -0000 1.4 +++ 6_ObjIntf.t 10 Apr 2003 10:20:08 -0000 1.5 @@ -2,7 +2,7 @@ # vim: syntax=perl use strict; -use Test::More tests => 27; +use Test::More tests => 33; ############################################################################## # Derived version of XML::Simple that returns everything in upper case @@ -101,10 +101,19 @@ keyattr => { } ); +my %opts3 = ( + keyattr => { disc => 'cddbid', track => 'number' }, + keeproot => 1, + contentkey => '-title', + forcearray => [ qw(disc album) ] +); + my $xs1 = new XML::Simple( %opts1 ); my $xs2 = new XML::Simple( %opts2 ); +my $xs3 = new XML::Simple( %opts3 ); isa_ok($xs1, 'XML::Simple', 'object one'); isa_ok($xs2, 'XML::Simple', 'object two'); +isa_ok($xs3, 'XML::Simple', 'object three'); is_deeply(\%opts1, { keyattr => { disc => 'cddbid', track => 'number' }, keeproot => 1, @@ -171,6 +180,38 @@ is_deeply($ref2, $exp2, 'parsed expected data via object 2'); +# Try using the third object + +my $exp3 = { + 'cddatabase' => { + 'disc' => { + '960b750c' => { + 'id' => '9362-45055-2', + 'album' => [ 'Automatic For The People' ], + 'artist' => 'R.E.M.', + 'track' => { + 1 => 'Drive', + 2 => 'Try Not To Breathe', + 3 => 'The Sidewinder Sleeps Tonite', + 4 => 'Everybody Hurts', + 5 => 'New Orleans Instrumental No. 1', + 6 => 'Sweetness Follows', + 7 => 'Monty Got A Raw Deal', + 8 => 'Ignoreland', + 9 => 'Star Me Kitten', + 10 => 'Man On The Moon', + 11 => 'Nightswimming', + 12 => 'Find The River' + } + } + } + } +}; + +my $ref3 = $xs3->XMLin($xml); +is_deeply($ref3, $exp3, 'parsed expected data via object 3'); + + # Confirm default options in object merge correctly with options as args $ref1 = $xs1->XMLin($xml, keyattr => [], forcearray => 0); @@ -266,3 +307,53 @@ like($_, qr{<opt>\s* <server\s+address="<!\[CDATA\[12->14\s+"Puf&Stuf"\s+Drive\]\]>"\s*/>\s* </opt>}xs, 'inheritance works with escape_value() overridden'); + + +# Check variables defined in the constructor don't get trounced for +# subsequent parses + +$xs1 = XML::Simple->new( + contentkey => '-content', + varattr => 'xsvar', + variables => { conf_dir => '/etc', log_dir => '/tmp' } +); + +$xml = q(<opt> + <dir xsvar="log_dir">/var/log</dir> + <file name="config_file">${conf_dir}/appname.conf</file> + <file name="log_file">${log_dir}/appname.log</file> + <file name="debug_file">${log_dir}/appname.dbg</file> +</opt>); + +my $opt = $xs1->XMLin($xml); +is_deeply($opt, { + file => { + config_file => '/etc/appname.conf', + log_file => '/var/log/appname.log', + debug_file => '/var/log/appname.dbg', + }, + dir => { xsvar => 'log_dir', content => '/var/log' }, +}, 'variables from XML merged with predefined variables'); + +$xml = q(<opt> + <file name="config_file">${conf_dir}/appname.conf</file> + <file name="log_file">${log_dir}/appname.log</file> + <file name="debug_file">${log_dir}/appname.dbg</file> +</opt>); + +my $opt = $xs1->XMLin($xml); +is_deeply($opt, { + file => { + config_file => '/etc/appname.conf', + log_file => '/tmp/appname.log', + debug_file => '/tmp/appname.dbg', + }, +}, 'variables from XML merged with predefined variables'); + +# check that unknown options passed to the constructor are rejected + +$@ = undef; +eval { $xs1 = XML::Simple->new(KeyAttr => {}, WibbleFlibble => 1) }; +ok(defined($@), "unrecognised option caught by constructor"); +like($@, qr/^Unrecognised option: WibbleFlibble at/, + "correct message in exception"); Index: 9_Strict.t =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/t/9_Strict.t,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- 9_Strict.t 11 Dec 2002 01:48:28 -0000 1.3 +++ 9_Strict.t 10 Apr 2003 10:20:10 -0000 1.4 @@ -36,7 +36,7 @@ }; isnt($@, '', 'omitting forcearray was a fatal error'); -like($@, qr/No value specified for 'forcearray'/, +like($@, qr/(?i)No value specified for 'forcearray'/, 'with the correct error message'); @@ -47,7 +47,7 @@ }; isnt($@, '', 'omitting keyattr was a fatal error'); -like($@, qr/No value specified for 'keyattr'/, +like($@, qr/(?i)No value specified for 'keyattr'/, 'with the correct error message'); @@ -58,7 +58,7 @@ }; isnt($@, '', 'omitting forcearray for elements in keyattr was a fatal error'); -like($@, qr/<part> set in keyattr but not in forcearray/, +like($@, qr/(?i)<part> set in keyattr but not in forcearray/, 'with the correct error message'); @@ -67,7 +67,7 @@ }; isnt($@, '', 'omitting keyattr elements from forcearray was a fatal error'); -like($@, qr/<part> set in keyattr but not in forcearray/, +like($@, qr/(?i)<part> set in keyattr but not in forcearray/, 'with the correct error message'); @@ -86,7 +86,7 @@ }; isnt($@, '', 'key attribute missing from names element was a fatal error'); -like($@, qr/<part> element has no 'partnum' key attribute/, +like($@, qr/(?i)<part> element has no 'partnum' key attribute/, 'with the correct error message'); @@ -106,7 +106,7 @@ }; isnt($@, '', 'key attribute not a scalar was a fatal error'); -like($@, qr/<item> element has non-scalar 'name' key attribute/, +like($@, qr/(?i)<item> element has non-scalar 'name' key attribute/, 'with the correct error message'); @@ -145,7 +145,7 @@ }; isnt($@, '', 'omitting keyattr was a fatal error'); -like($@, qr/No value specified for 'keyattr'/, +like($@, qr/(?i)No value specified for 'keyattr'/, 'with the correct error message'); @@ -179,7 +179,7 @@ }; isnt($@, '', 'omitting forcearray was a fatal error'); -like($@, qr/No value specified for 'forcearray'/, +like($@, qr/(?i)No value specified for 'forcearray'/, 'with the correct error message'); @@ -192,7 +192,7 @@ }; isnt($@, '', 'omitting keyattr was a fatal error'); -like($@, qr/No value specified for 'keyattr'/, +like($@, qr/(?i)No value specified for 'keyattr'/, 'with the correct error message'); @@ -205,7 +205,7 @@ }; isnt($@, '', 'omitting forcearray for elements in keyattr was a fatal error'); -like($@, qr/<part> set in keyattr but not in forcearray/, +like($@, qr/(?i)<part> set in keyattr but not in forcearray/, 'with the correct error message'); @@ -216,7 +216,7 @@ }; isnt($@, '', 'omitting keyattr elements from forcearray was a fatal error'); -like($@, qr/<part> set in keyattr but not in forcearray/, +like($@, qr/(?i)<part> set in keyattr but not in forcearray/, 'with the correct error message'); @@ -236,7 +236,7 @@ }; isnt($@, '', 'key attribute missing from names element was a fatal error'); -like($@, qr/<part> element has no 'partnum' key attribute/, +like($@, qr/(?i)<part> element has no 'partnum' key attribute/, 'with the correct error message'); @@ -258,7 +258,7 @@ }; isnt($@, '', 'key attribute not a scalar was a fatal error'); -like($@, qr/<item> element has non-scalar 'name' key attribute/, +like($@, qr/(?i)<item> element has non-scalar 'name' key attribute/, 'with the correct error message'); @@ -301,7 +301,7 @@ }; isnt($@, '', 'omitting keyattr was a fatal error'); -like($@, qr/No value specified for 'keyattr'/, +like($@, qr/(?i)No value specified for 'keyattr'/, 'with the correct error message'); |
From: Grant M. <gr...@us...> - 2003-04-10 10:19:07
|
Update of /cvsroot/perl-xml/xml-simple/lib/XML In directory sc8-pr-cvs1:/tmp/cvs-serv18089/lib/XML Modified Files: Simple.pm Log Message: - integrated a patch from Michel Rodriguez + new facility for removing extra levels of indirection (using the new 'GroupTags' option) + new facility for rolling the dreaded 'content' hash up into a scalar if there are no keys left after array folding (using the '-' prefix mode on the ContentKey option) + new facility for doing variable substitution in the XML; variables can be defined in Perl (using the new 'Variables' option) or in the XML document (using the new 'VarAttr' option) - added 'NormaliseSpace' option for tidying up hash keys and other text content if required (feature requested by Alex Manoussakis) - option names are now case-insensitive and can include underscores - XMLin() and XMLout() are now aliased to xml_in() and xml_out() when called as methods or imported explicitly - option names passed to XML::Simple->new() are now validated Index: Simple.pm =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/lib/XML/Simple.pm,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- Simple.pm 20 Jan 2003 07:48:08 -0000 1.10 +++ Simple.pm 10 Apr 2003 10:19:02 -0000 1.11 @@ -48,11 +48,12 @@ # Define some constants # -use vars qw($VERSION @ISA @EXPORT $PREFERRED_PARSER); +use vars qw($VERSION @ISA @EXPORT @EXPORT_OK $PREFERRED_PARSER); @ISA = qw(Exporter); @EXPORT = qw(XMLin XMLout); -$VERSION = '2.03'; +@EXPORT_OK = qw(xml_in xml_out); +$VERSION = '2.04'; [...1552 lines suppressed...] Anonymous arrays can be nested to arbirtrary levels and as a special case, if @@ -2358,7 +2691,8 @@ Elements which only contain text content will simply be represented as a scalar. Where an element has both attributes and text content, the element -will be represented as a hashref with the text content in the 'content' key: +will be represented as a hashref with the text content in the 'content' key +(see the C<ContentKey> option): <opt> <one>first</one> @@ -2422,7 +2756,7 @@ =head1 STATUS -This version (2.03) is the current stable version. +This version (2.04) is the current stable version. =head1 SEE ALSO |
From: Petr P. <pa...@us...> - 2003-04-04 18:43:32
|
Update of /cvsroot/perl-xml/XML-LibXML-XPathContext/t In directory sc8-pr-cvs1:/tmp/cvs-serv858/t Modified Files: 01-variables.t 00-xpathcontext.t Log Message: fixed bugs in new(), setContextNode(), and register* causing loosing stored context data passed from a variable if the variable itself gets changed Index: 01-variables.t =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/t/01-variables.t,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- 01-variables.t 26 Mar 2003 15:26:47 -0000 1.3 +++ 01-variables.t 4 Apr 2003 18:42:57 -0000 1.4 @@ -1,6 +1,6 @@ # -*- cperl -*- use Test; -BEGIN { plan tests => 31 }; +BEGIN { plan tests => 33 }; use XML::LibXML; use XML::LibXML::XPathContext; @@ -76,3 +76,10 @@ $xc->unregisterVarLookupFunc(); eval { $xc->find('$a') }; ok($@); + +my $foo='foo'; +$xc->registerVarLookupFunc(sub {},$foo); +ok($xc->getVarLookupData eq 'foo'); +$foo=undef; +ok($xc->getVarLookupData eq 'foo'); + Index: 00-xpathcontext.t =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/t/00-xpathcontext.t,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- 00-xpathcontext.t 2 Apr 2003 14:15:55 -0000 1.5 +++ 00-xpathcontext.t 4 Apr 2003 18:42:58 -0000 1.6 @@ -1,5 +1,5 @@ use Test; -BEGIN { plan tests => 21 }; +BEGIN { plan tests => 23 }; use XML::LibXML; use XML::LibXML::XPathContext; @@ -70,6 +70,10 @@ ok(!defined($xc4->getContextNode)); eval { $xc4->find('/') }; ok($@); -$xc4->setContextNode($doc2->getDocumentElement); +my $cn=$doc2->getDocumentElement; +$xc4->setContextNode($cn); ok($xc4->find('/')); +ok($xc4->getContextNode->isSameNode($doc2->getDocumentElement)); +$cn=undef; +ok($xc4->getContextNode); ok($xc4->getContextNode->isSameNode($doc2->getDocumentElement)); |
From: Petr P. <pa...@us...> - 2003-04-04 18:43:08
|
Update of /cvsroot/perl-xml/XML-LibXML-XPathContext In directory sc8-pr-cvs1:/tmp/cvs-serv858 Modified Files: XPathContext.xs Changes Log Message: fixed bugs in new(), setContextNode(), and register* causing loosing stored context data passed from a variable if the variable itself gets changed Index: XPathContext.xs =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/XPathContext.xs,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- XPathContext.xs 4 Apr 2003 11:07:28 -0000 1.30 +++ XPathContext.xs 4 Apr 2003 18:42:59 -0000 1.31 @@ -451,8 +451,11 @@ croak("XPathContext: failed to allocate proxy object"); } - XPathContextDATA(ctxt)->node = pnode; - if (SvOK(pnode)) SvREFCNT_inc(pnode); + if (SvOK(pnode)) { + XPathContextDATA(ctxt)->node = newSVsv(pnode); + } else { + XPathContextDATA(ctxt)->node = &PL_sv_undef; + } XPathContextDATA(ctxt)->lock = 0; XPathContextDATA(ctxt)->pool = NULL; @@ -537,9 +540,10 @@ if (XPathContextDATA(ctxt)->node && SvOK(XPathContextDATA(ctxt)->node)) { SvREFCNT_dec(XPathContextDATA(ctxt)->node); } - XPathContextDATA(ctxt)->node = pnode; if (SvOK(pnode)) { - SvREFCNT_inc(pnode); + XPathContextDATA(ctxt)->node = newSVsv(pnode); + } else { + XPathContextDATA(ctxt)->node = &PL_sv_undef; } void @@ -615,8 +619,8 @@ if (SvOK(lookup_func)) { if ( SvROK(lookup_func) && SvTYPE(SvRV(lookup_func)) == SVt_PVCV ) { pfdr = newRV_inc((SV*) newAV()); - av_push((AV *)SvRV(pfdr), SvREFCNT_inc(lookup_func)); - av_push((AV *)SvRV(pfdr), SvREFCNT_inc(lookup_data)); + av_push((AV *)SvRV(pfdr), newSVsv(lookup_func)); + av_push((AV *)SvRV(pfdr), newSVsv(lookup_data)); } else { croak("XPathContext: 1st argument is not a CODE reference"); } @@ -691,7 +695,7 @@ strkey = SvPV(key, len); /* warn("Trying to store function '%s' in %d\n", strkey, pfdr); */ if (SvOK(func)) { - hv_store((HV *)SvRV(pfdr),strkey, len, SvREFCNT_inc(func), 0); + hv_store((HV *)SvRV(pfdr),strkey, len, newSVsv(func), 0); } else { /* unregister */ hv_delete((HV *)SvRV(pfdr),strkey, len, G_DISCARD); Index: Changes =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/Changes,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- Changes 4 Apr 2003 11:07:28 -0000 1.5 +++ Changes 4 Apr 2003 18:43:02 -0000 1.6 @@ -4,7 +4,9 @@ Not in CVS -* minor bug fix for new() without context node +* fixed bugs in new(), setContextNode(), and register* causing loosing +stored context data passed from a variable if the variable itself gets +changed 0.02 Fri Apr 4 2003 |
From: Petr P. <pa...@us...> - 2003-04-04 11:07:32
|
Update of /cvsroot/perl-xml/XML-LibXML-XPathContext In directory sc8-pr-cvs1:/tmp/cvs-serv959 Modified Files: XPathContext.xs Changes Log Message: - minor bug fix for new without context node Index: XPathContext.xs =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/XPathContext.xs,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- XPathContext.xs 4 Apr 2003 09:08:47 -0000 1.29 +++ XPathContext.xs 4 Apr 2003 11:07:28 -0000 1.30 @@ -441,9 +441,9 @@ SV * pnode = &PL_sv_undef; INIT: xmlXPathContextPtr ctxt; - CODE: - if( items > 1 ) - pnode = ST(1); + CODE: + if( items > 1 ) + pnode = ST(1); ctxt = xmlXPathNewContext( NULL ); New(0, ctxt->user, sizeof(XPathContextData), XPathContextData); @@ -451,9 +451,9 @@ croak("XPathContext: failed to allocate proxy object"); } - if (SvOK(pnode)) { - XPathContextDATA(ctxt)->node = SvREFCNT_inc(pnode); - } + XPathContextDATA(ctxt)->node = pnode; + if (SvOK(pnode)) SvREFCNT_inc(pnode); + XPathContextDATA(ctxt)->lock = 0; XPathContextDATA(ctxt)->pool = NULL; @@ -478,7 +478,7 @@ if (ctxt) { if (XPathContextDATA(ctxt) != NULL) { if (XPathContextDATA(ctxt)->node != NULL && - SvOK(XPathContextDATA(ctxt)->node)) { + SvOK(XPathContextDATA(ctxt)->node)) { SvREFCNT_dec(XPathContextDATA(ctxt)->node); } if (XPathContextDATA(ctxt)->pool != NULL && Index: Changes =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/Changes,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- Changes 4 Apr 2003 09:05:47 -0000 1.4 +++ Changes 4 Apr 2003 11:07:28 -0000 1.5 @@ -2,6 +2,10 @@ Revision history for Perl module XML::LibXML::XPathContext. +Not in CVS + +* minor bug fix for new() without context node + 0.02 Fri Apr 4 2003 * Added missing include xpathInternals.h what fixes problems with |
From: Ilya M. <m_...@us...> - 2003-04-04 09:08:53
|
Update of /cvsroot/perl-xml/XML-LibXML-XPathContext In directory sc8-pr-cvs1:/tmp/cvs-serv24415 Modified Files: XPathContext.pm XPathContext.xs Log Message: Rename perl_dispatcher() to _perl_dispatcher() as this sub is not a part of public API Index: XPathContext.pm =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/XPathContext.pm,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- XPathContext.pm 4 Apr 2003 09:06:31 -0000 1.19 +++ XPathContext.pm 4 Apr 2003 09:08:46 -0000 1.20 @@ -91,7 +91,7 @@ # extension function perl dispatcher # borrowed from XML::LibXSLT -sub perl_dispatcher { +sub _perl_dispatcher { my $func = shift; my @params = @_; my @perlParams; Index: XPathContext.xs =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/XPathContext.xs,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- XPathContext.xs 2 Apr 2003 14:15:05 -0000 1.28 +++ XPathContext.xs 4 Apr 2003 09:08:47 -0000 1.29 @@ -374,7 +374,7 @@ /* call perl dispatcher */ PUTBACK; - perl_dispatch = sv_2mortal(newSVpv("XML::LibXML::XPathContext::perl_dispatcher",0)); + perl_dispatch = sv_2mortal(newSVpv("XML::LibXML::XPathContext::_perl_dispatcher",0)); count = perl_call_sv(perl_dispatch, G_SCALAR|G_EVAL); SPAGAIN; |
From: Ilya M. <m_...@us...> - 2003-04-04 09:06:35
|
Update of /cvsroot/perl-xml/XML-LibXML-XPathContext In directory sc8-pr-cvs1:/tmp/cvs-serv23794 Modified Files: XPathContext.pm Log Message: Update version number Index: XPathContext.pm =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/XPathContext.pm,v retrieving revision 1.18 retrieving revision 1.19 diff -u -d -r1.18 -r1.19 --- XPathContext.pm 4 Apr 2003 07:56:41 -0000 1.18 +++ XPathContext.pm 4 Apr 2003 09:06:31 -0000 1.19 @@ -7,7 +7,7 @@ use XML::LibXML::NodeList; -$VERSION = "0.01"; +$VERSION = '0.02'; require DynaLoader; @ISA = qw(DynaLoader); |
From: Ilya M. <m_...@us...> - 2003-04-04 09:05:55
|
Update of /cvsroot/perl-xml/XML-LibXML-XPathContext In directory sc8-pr-cvs1:/tmp/cvs-serv23525 Modified Files: Changes README Log Message: Updated Index: Changes =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/Changes,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Changes 3 Apr 2003 19:38:41 -0000 1.3 +++ Changes 4 Apr 2003 09:05:47 -0000 1.4 @@ -2,7 +2,7 @@ Revision history for Perl module XML::LibXML::XPathContext. -0.02 unreleased +0.02 Fri Apr 4 2003 * Added missing include xpathInternals.h what fixes problems with float numbers used in xpath expressions on platforms where PV is not Index: README =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/README,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- README 26 Mar 2003 21:24:26 -0000 1.2 +++ README 4 Apr 2003 09:05:48 -0000 1.3 @@ -4,8 +4,12 @@ SYNOPSIS use XML::LibXML::XPathContext; + my $xc = XML::LibXML::XPathContext->new; my $xc = XML::LibXML::XPathContext->new($node); + my $node = $xc->getContextNode; + $xc->setContextNode($node); + $xc->registerNs($prefix, $namespace_uri); $xc->registerFunction($name, sub { ... }); $xc->registerFunctionNS($name, $namespace_uri, sub { ... }); @@ -21,9 +25,6 @@ my $result = $xc->find($xpath); my $value = $xc->findvalue($xpath); - my $node = $xc->getContextNode; - $xc->setContextNode($node); - DESCRIPTION This module augments XML::LibXML by providing Perl interface to libxml2's xmlXPathContext structure. Besides just performing xpath @@ -91,9 +92,12 @@ my @nodes = $xc->findnodes('$A[work_area/street = $B]/name'); METHODS + new Creates a new XML::LibXML::XPathContext object without a context + node. + new($node) - Creates a new XML::LibXML::XPathContext object with current node set - to *$node*. + Creates a new XML::LibXML::XPathContext object with the context node + set to *$node*. registerNs($prefix, $namespace_uri) Registers namespace *$prefix* to *$namespace_uri*. @@ -184,6 +188,8 @@ my $xc = XML::LibXML::XPathContext->new($node); $xc->registerFunction('func', sub { $xc->findvalue('1') }); my $result = $xc->findvalue('func()'); + + Currently this module doesn't work on Mac OS X. AUTHORS Based on XML::LibXML and XML::XSLT code by Matt Sergeant and Christian |
From: Ilya M. <m_...@us...> - 2003-04-03 19:41:38
|
Update of /cvsroot/perl-xml/XML-LibXML-XPathContext In directory sc8-pr-cvs1:/tmp/cvs-serv8230 Modified Files: XPathContext.pm Log Message: Update POD docs Index: XPathContext.pm =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/XPathContext.pm,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- XPathContext.pm 26 Mar 2003 21:21:41 -0000 1.16 +++ XPathContext.pm 3 Apr 2003 19:41:33 -0000 1.17 @@ -131,8 +131,12 @@ use XML::LibXML::XPathContext; + my $xc = XML::LibXML::XPathContext->new; my $xc = XML::LibXML::XPathContext->new($node); + my $node = $xc->getContextNode; + $xc->setContextNode($node); + $xc->registerNs($prefix, $namespace_uri); $xc->registerFunction($name, sub { ... }); $xc->registerFunctionNS($name, $namespace_uri, sub { ... }); @@ -148,9 +152,6 @@ my $result = $xc->find($xpath); my $value = $xc->findvalue($xpath); - my $node = $xc->getContextNode; - $xc->setContextNode($node); - =head1 DESCRIPTION This module augments L<XML::LibXML|XML::LibXML> by providing Perl @@ -237,6 +238,11 @@ =over 4 +=item B<new> + +Creates a new XML::LibXML::XPathContext object without current node +set. + =item B<new($node)> Creates a new XML::LibXML::XPathContext object with current node @@ -351,6 +357,8 @@ my $xc = XML::LibXML::XPathContext->new($node); $xc->registerFunction('func', sub { $xc->findvalue('1') }); my $result = $xc->findvalue('func()'); + +Currently this module doesn't work on Mac OS X. =head1 AUTHORS |
From: Ilya M. <m_...@us...> - 2003-04-03 19:38:47
|
Update of /cvsroot/perl-xml/XML-LibXML-XPathContext In directory sc8-pr-cvs1:/tmp/cvs-serv7041 Modified Files: Changes Log Message: Updated Index: Changes =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/Changes,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- Changes 29 Mar 2003 15:48:08 -0000 1.2 +++ Changes 3 Apr 2003 19:38:41 -0000 1.3 @@ -8,6 +8,9 @@ float numbers used in xpath expressions on platforms where PV is not defined as double. +* XML::LibXML::XPathContext objects can be created without specifying +a current node now. I.e. new()'s parameter $node is optional now. + 0.01 Thu Mar 27 2003 * First version based on XML::LibXML and XML::XSLT code. |
From: Petr P. <pa...@us...> - 2003-04-02 14:15:59
|
Update of /cvsroot/perl-xml/XML-LibXML-XPathContext/t In directory sc8-pr-cvs1:/tmp/cvs-serv20826/t Modified Files: 00-xpathcontext.t Log Message: - tests for XPathContext with NULL/undef context node Index: 00-xpathcontext.t =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/t/00-xpathcontext.t,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- 00-xpathcontext.t 26 Mar 2003 21:21:40 -0000 1.4 +++ 00-xpathcontext.t 2 Apr 2003 14:15:55 -0000 1.5 @@ -1,5 +1,5 @@ use Test; -BEGIN { plan tests => 17 }; +BEGIN { plan tests => 21 }; use XML::LibXML; use XML::LibXML::XPathContext; @@ -64,3 +64,12 @@ my $xc3 = XML::LibXML::XPathContext->new($doc2->getDocumentElement); $xc3->find('/'); ok($xc3->getContextNode->toString() eq '<foo><bar/></foo>'); + +# check starting with empty context +my $xc4 = XML::LibXML::XPathContext->new(); +ok(!defined($xc4->getContextNode)); +eval { $xc4->find('/') }; +ok($@); +$xc4->setContextNode($doc2->getDocumentElement); +ok($xc4->find('/')); +ok($xc4->getContextNode->isSameNode($doc2->getDocumentElement)); |
From: Petr P. <pa...@us...> - 2003-04-02 14:15:12
|
Update of /cvsroot/perl-xml/XML-LibXML-XPathContext In directory sc8-pr-cvs1:/tmp/cvs-serv20136 Modified Files: XPathContext.xs Log Message: - fix LibXML_configure_namespaces for NULL context node Index: XPathContext.xs =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/XPathContext.xs,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- XPathContext.xs 2 Apr 2003 14:07:08 -0000 1.27 +++ XPathContext.xs 2 Apr 2003 14:15:05 -0000 1.28 @@ -401,16 +401,18 @@ if (ctxt->namespaces != NULL) { xmlFree( ctxt->namespaces ); } - if (node->type == XML_DOCUMENT_NODE) { - ctxt->namespaces = xmlGetNsList( node->doc, - xmlDocGetRootElement( node->doc ) ); - } else { - ctxt->namespaces = xmlGetNsList(node->doc, node); - } - ctxt->nsNr = 0; - if (ctxt->namespaces != NULL) { - while (ctxt->namespaces[ctxt->nsNr] != NULL) - ctxt->nsNr++; + if (node != NULL) { + if (node->type == XML_DOCUMENT_NODE) { + ctxt->namespaces = xmlGetNsList( node->doc, + xmlDocGetRootElement( node->doc ) ); + } else { + ctxt->namespaces = xmlGetNsList(node->doc, node); + } + ctxt->nsNr = 0; + if (ctxt->namespaces != NULL) { + while (ctxt->namespaces[ctxt->nsNr] != NULL) + ctxt->nsNr++; + } } } |
From: Petr P. <pa...@us...> - 2003-04-02 14:07:13
|
Update of /cvsroot/perl-xml/XML-LibXML-XPathContext In directory sc8-pr-cvs1:/tmp/cvs-serv10387 Modified Files: XPathContext.xs Log Message: - changed #include "xpathInternals.h" to #include <libxml/xpathInternals.h> - allow XML::LibXML::XPathContext->new() without a node or document Index: XPathContext.xs =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/XPathContext.xs,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- XPathContext.xs 29 Mar 2003 15:43:54 -0000 1.26 +++ XPathContext.xs 2 Apr 2003 14:07:08 -0000 1.27 @@ -12,12 +12,12 @@ /* libxml2 stuff */ #include <libxml/xpath.h> +#include <libxml/xpathInternals.h> /* XML::LibXML stuff */ #include "perl-libxml-mm.h" #include "xpath.h" -#include "xpathInternals.h" #ifdef __cplusplus } @@ -418,7 +418,11 @@ LibXML_configure_xpathcontext( xmlXPathContextPtr ctxt ) { xmlNodePtr node = PmmSvNode(XPathContextDATA(ctxt)->node); - ctxt->doc = node->doc; + if (node != NULL) { + ctxt->doc = node->doc; + } else { + ctxt->doc = NULL; + } ctxt->node = node; LibXML_configure_namespaces(ctxt); @@ -429,18 +433,25 @@ PROTOTYPES: DISABLE SV* -new( CLASS, pnode ) +new( CLASS, ... ) const char * CLASS - SV * pnode + PREINIT: + SV * pnode = &PL_sv_undef; INIT: xmlXPathContextPtr ctxt; - CODE: + CODE: + if( items > 1 ) + pnode = ST(1); + ctxt = xmlXPathNewContext( NULL ); New(0, ctxt->user, sizeof(XPathContextData), XPathContextData); if (ctxt->user == NULL) { croak("XPathContext: failed to allocate proxy object"); } - XPathContextDATA(ctxt)->node = SvREFCNT_inc(pnode); + + if (SvOK(pnode)) { + XPathContextDATA(ctxt)->node = SvREFCNT_inc(pnode); + } XPathContextDATA(ctxt)->lock = 0; XPathContextDATA(ctxt)->pool = NULL; @@ -464,10 +475,12 @@ xs_warn( "DESTROY XPATH CONTEXT" ); if (ctxt) { if (XPathContextDATA(ctxt) != NULL) { - if (XPathContextDATA(ctxt)->node != NULL) { + if (XPathContextDATA(ctxt)->node != NULL && + SvOK(XPathContextDATA(ctxt)->node)) { SvREFCNT_dec(XPathContextDATA(ctxt)->node); } - if (XPathContextDATA(ctxt)->pool != NULL) { + if (XPathContextDATA(ctxt)->pool != NULL && + SvOK(XPathContextDATA(ctxt)->pool)) { SvREFCNT_dec((SV *)XPathContextDATA(ctxt)->pool); } Safefree(XPathContextDATA(ctxt)); @@ -503,7 +516,7 @@ PmmOWNERPO( PmmPROXYNODE(ctxt->node))); } else { - croak("XPathContext: lost context node"); + /* croak("XPathContext: lost context node"); */ RETVAL = &PL_sv_undef; } OUTPUT: @@ -519,11 +532,13 @@ croak("XPathContext: missing xpath context"); } PPCODE: - if (XPathContextDATA(ctxt)->node) { + if (XPathContextDATA(ctxt)->node && SvOK(XPathContextDATA(ctxt)->node)) { SvREFCNT_dec(XPathContextDATA(ctxt)->node); } XPathContextDATA(ctxt)->node = pnode; - SvREFCNT_inc(pnode); + if (SvOK(pnode)) { + SvREFCNT_inc(pnode); + } void registerNs( pxpath_context, prefix, ns_uri ) |
From: Ilya M. <m_...@us...> - 2003-03-29 15:48:11
|
Update of /cvsroot/perl-xml/XML-LibXML-XPathContext In directory sc8-pr-cvs1:/tmp/cvs-serv8089 Modified Files: Changes Log Message: Updated Index: Changes =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/Changes,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Changes 26 Mar 2003 21:20:45 -0000 1.1 +++ Changes 29 Mar 2003 15:48:08 -0000 1.2 @@ -2,6 +2,12 @@ Revision history for Perl module XML::LibXML::XPathContext. +0.02 unreleased + +* Added missing include xpathInternals.h what fixes problems with +float numbers used in xpath expressions on platforms where PV is not +defined as double. + 0.01 Thu Mar 27 2003 * First version based on XML::LibXML and XML::XSLT code. |