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: Grant M. <gr...@us...> - 2006-11-06 08:26:39
|
Update of /cvsroot/perl-xml/perl-xml-faq In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16337 Modified Files: perl-xml-faq.xml Log Message: - add Q&A re namespaces and XPath Index: perl-xml-faq.xml =================================================================== RCS file: /cvsroot/perl-xml/perl-xml-faq/perl-xml-faq.xml,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- perl-xml-faq.xml 23 Oct 2006 02:54:34 -0000 1.23 +++ perl-xml-faq.xml 6 Nov 2006 08:26:32 -0000 1.24 @@ -19,6 +19,7 @@ <year>2003</year> <year>2004</year> <year>2005</year> + <year>2006</year> <holder>Grant McLean</holder> </copyright> @@ -2332,6 +2333,103 @@ </answer> </qandaentry> + <qandaentry id="namespaces_xpath"> + <question> + <para>Using XPath with Namespaces</para> + </question> + <answer> + + <para>People often experience difficulty getting their XPath expressions + to match when they first use <classname>XML::LibXML</classname> to + process an XML document containing namespaces. For example, consider + this XHTML document with an embedded SVG section:</para> + + <programlisting><![CDATA[ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml"> +<head> + <title>Sample Document</title> +</head> +<body> + +<h1>An HTML Heading</h1> + +<s:svg xmlns:s="http://www.w3.org/2000/svg" width="300" height="200"> + <s:rect style="fill: #eeeeee; stroke: #000000; stroke-width: 1;" + width="80" height="30" x="60" y="50" /> + <s:text style="font-size: 12px; fill: #000066; font-family: sans-serif;" + x="70" y="70">Label One</s:text> +</s:svg> + +</body> +</html> + ]]></programlisting> + + <para>The elements in the SVG section each use the namespace prefix + 's' which is bound to the URI 'http://www.w3.org/2000/svg'. The + prefix 's' is completely arbitrary and is merely a mechanism for + associating the URI with the elements. As a programmer, you will + perform matches against namespace URIs not prefixes.</para> + + <para>The elements in the XHTML wrapper do not have namespace prefixes, + but are bound to the URI 'http://www.w3.org/1999/xhtml' by way of the + default namespace declaration on the opening <html> tag.</para> + + <para>You might expect that you could match all the 'h1' elements using + this XPath expression ...</para> + + <programlisting><![CDATA[ +//h1 + ]]></programlisting> + + <para>... however, that won't work since the namespace URI is effectively + part of the name of the element you're trying to match.</para> + + <para>One approach would be to fashion an XPath query which ignored the + namespace portion of element names and matched only on the 'local name' + portion. For example:</para> + + <programlisting><![CDATA[ +//*[local-name() = 'h1'] + ]]></programlisting> + + <para>A better approach is to match the namespace portion as well. To + achieve that, the first step is to use + <classname>XML::LibXML::XPathContext</classname> to declare a namespace + prefix. Then, the prefix can be used in the XPath expression:</para> + + <programlisting><![CDATA[ +my $parser = XML::LibXML->new(); +my $doc = $parser->parse_file('sample.xhtml'); + +my $xpc = XML::LibXML::XPathContext->new($doc); +$xpc->registerNs(xhtml => 'http://www.w3.org/1999/xhtml'); + +foreach my $node ($xpc->findnodes('//xhtml:h1')) { + print $node->to_literal, "\n"; +} + ]]></programlisting> + + <para>The same technique can be used to match 'text' elements in the + SVG section:</para> + + <programlisting><![CDATA[ +$xpc->registerNs(svg => 'http://www.w3.org/2000/svg'); +foreach my $node ($xpc->findnodes('//svg:text')) { + print $node->to_literal, "\n"; +} + ]]></programlisting> + + <note><para>The <classname>XML::LibXML::XPathContext</classname> module + has been included in the <classname>XML::LibXML</classname> distribution + since version 1.61. Prior to that it was in its own separate + distribution on CPAN.</para></note> + + </answer> + </qandaentry> + </qandadiv> <qandadiv id="misc"><title>Miscellaneous</title> |
From: Grant M. <gr...@us...> - 2006-10-30 08:28:24
|
Update of /cvsroot/perl-xml/xml-simple/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5403/t Modified Files: 1_XMLin.t Log Message: - for 2.16 release Index: 1_XMLin.t =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/t/1_XMLin.t,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- 1_XMLin.t 3 Oct 2006 01:07:48 -0000 1.24 +++ 1_XMLin.t 30 Oct 2006 08:28:13 -0000 1.25 @@ -25,8 +25,9 @@ $@ = ''; eval "use XML::Simple;"; is($@, '', 'Module compiled OK'); -unless($XML::Simple::VERSION eq '2.15') { - diag("Warning: XML::Simple::VERSION = $XML::Simple::VERSION (expected 2.15)"); +my $version = '2.16'; +unless($XML::Simple::VERSION eq $version) { + diag("Warning: XML::Simple::VERSION = $XML::Simple::VERSION (expected $version)"); } |
From: Grant M. <gr...@us...> - 2006-10-30 08:28:24
|
Update of /cvsroot/perl-xml/xml-simple/lib/XML In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5403/lib/XML Modified Files: Simple.pm Log Message: - for 2.16 release Index: Simple.pm =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/lib/XML/Simple.pm,v retrieving revision 1.33 retrieving revision 1.34 diff -u -d -r1.33 -r1.34 --- Simple.pm 29 Oct 2006 07:28:25 -0000 1.33 +++ Simple.pm 30 Oct 2006 08:28:13 -0000 1.34 @@ -53,7 +53,7 @@ @ISA = qw(Exporter); @EXPORT = qw(XMLin XMLout); @EXPORT_OK = qw(xml_in xml_out); -$VERSION = '2.15'; +$VERSION = '2.16'; $PREFERRED_PARSER = undef; my $StrictMode = 0; |
From: Grant M. <gr...@us...> - 2006-10-30 08:28:24
|
Update of /cvsroot/perl-xml/xml-simple In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5403 Modified Files: Changes README todo Log Message: - for 2.16 release Index: Changes =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/Changes,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- Changes 5 Oct 2006 08:28:05 -0000 1.25 +++ Changes 30 Oct 2006 08:28:12 -0000 1.26 @@ -1,7 +1,9 @@ Revision history for Perl module XML::Simple -2.16 ??? ?? 2006 - - Added test for bad GroupTags option (report from Lee Goddard) +2.16 Oct 30 2006 + - Added test/fix for bad GroupTags option (report from Lee Goddard) + - Added new_hashref() hook method + - refactored cache save/restore methods for easier overriding 2.15 Oct 03 2006 - Makefile.PL changes: reject known-bad PurePerl and RTF parser modules; Index: README =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/README,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- README 3 Oct 2006 01:07:48 -0000 1.20 +++ README 30 Oct 2006 08:28:12 -0000 1.21 @@ -56,7 +56,7 @@ STATUS - This version (2.15) is the current stable release. + This version (2.16) is the current stable release. Please send any feedback to the author: gr...@cp... Index: todo =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/todo,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- todo 12 Oct 2006 08:57:51 -0000 1.3 +++ todo 30 Oct 2006 08:28:12 -0000 1.4 @@ -1,10 +1,6 @@ To Release ========== -- fix infinite loop reported by Lee Goddard -- add new_hashref hook method -- refactored cache save/restore methods for easier overriding To Do ===== -- make options handling method overridable - add a parse_string method? |
From: Grant M. <gr...@us...> - 2006-10-29 07:28:28
|
Update of /cvsroot/perl-xml/xml-simple/lib/XML In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22921/lib/XML Modified Files: Simple.pm Log Message: - refactoring of code to turn function calls into method calls Index: Simple.pm =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/lib/XML/Simple.pm,v retrieving revision 1.32 retrieving revision 1.33 diff -u -d -r1.32 -r1.33 --- Simple.pm 29 Oct 2006 07:09:39 -0000 1.32 +++ Simple.pm 29 Oct 2006 07:28:25 -0000 1.33 @@ -130,20 +130,13 @@ ############################################################################## -# Sub/Method: XMLin() -# -# Exported routine for slurping XML into a hashref - see pod for info. -# -# May be called as object method or as a plain function. +# Sub: _get_object() # -# Expects one arg for the source XML, optionally followed by a number of -# name => value option pairs. +# Helper routine called from XMLin() and XMLout() to create an object if none +# was provided. Note, this routine does mess with the caller's @_ array. # -sub XMLin { - - # If this is not a method call, create an object - +sub _get_object { my $self; if($_[0] and UNIVERSAL::isa($_[0], 'XML::Simple')) { $self = shift; @@ -151,7 +144,23 @@ else { $self = XML::Simple->new(); } + + return $self; +} + +############################################################################## +# Sub/Method: XMLin() +# +# Exported routine for slurping XML into a hashref - see pod for info. +# +# May be called as object method or as a plain function. +# +# Expects one arg for the source XML, optionally followed by a number of +# name => value option pairs. +# +sub XMLin { + my $self = &_get_object; # note, @_ is passed implicitly my $string = shift; @@ -482,16 +491,7 @@ # sub XMLout { - - # If this is not a method call, create an object - - my $self; - if($_[0] and UNIVERSAL::isa($_[0], 'XML::Simple')) { - $self = shift; - } - else { - $self = XML::Simple->new(); - } + my $self = &_get_object; # note, @_ is passed implicitly croak "XMLout() requires at least one argument" unless(@_); my $ref = shift; |
From: Grant M. <gr...@us...> - 2006-10-29 07:09:45
|
Update of /cvsroot/perl-xml/xml-simple/lib/XML In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16075/lib/XML Modified Files: Simple.pm Log Message: - remove occurrences of indirect object syntax Index: Simple.pm =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/lib/XML/Simple.pm,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- Simple.pm 12 Oct 2006 08:57:51 -0000 1.31 +++ Simple.pm 29 Oct 2006 07:09:39 -0000 1.32 @@ -18,7 +18,7 @@ require XML::Simple; - my $xs = new XML::Simple(options); + my $xs = XML::Simple->new(options); my $ref = $xs->XMLin([<xml file or string>] [, <options>]); @@ -149,7 +149,7 @@ $self = shift; } else { - $self = new XML::Simple(); + $self = XML::Simple->new(); } @@ -321,7 +321,7 @@ carp "'nsexpand' option requires XML::SAX"; } - my $xp = new XML::Parser(Style => 'Tree', @{$self->{opt}->{parseropts}}); + my $xp = XML::Parser->new(Style => 'Tree', @{$self->{opt}->{parseropts}}); my($tree); if($filename) { # $tree = $xp->parsefile($filename); # Changed due to prob w/mod_perl @@ -490,7 +490,7 @@ $self = shift; } else { - $self = new XML::Simple(); + $self = XML::Simple->new(); } croak "XMLout() requires at least one argument" unless(@_); @@ -1900,7 +1900,7 @@ An IO::Handle object will be read to EOF and its contents parsed. eg: - $fh = new IO::File('/etc/params.xml'); + $fh = IO::File->new('/etc/params.xml'); $ref = XMLin($fh); =back @@ -2651,7 +2651,7 @@ First create an XML::Simple parser object with your preferred defaults: - my $xs = new XML::Simple(ForceArray => 1, KeepRoot => 1); + my $xs = XML::Simple->new(ForceArray => 1, KeepRoot => 1); then call C<XMLin()> or C<XMLout()> as a method of that object: |
From: Grant M. <gr...@us...> - 2006-10-23 02:54:41
|
Update of /cvsroot/perl-xml/perl-xml-faq In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12642 Modified Files: perl-xml-faq.xml Log Message: - fix bug in sanitise() function - fix link to CVS source Index: perl-xml-faq.xml =================================================================== RCS file: /cvsroot/perl-xml/perl-xml-faq/perl-xml-faq.xml,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- perl-xml-faq.xml 12 Dec 2005 08:13:00 -0000 1.22 +++ perl-xml-faq.xml 23 Oct 2006 02:54:34 -0000 1.23 @@ -38,8 +38,8 @@ <ulink url="http://perl-xml.sourceforge.net/faq/">http://perl-xml.sourceforge.net/faq/</ulink>. The official source for this document is in CVS on <ulink url="http://www.sourceforge.net/">SourceForge</ulink> at <ulink - url="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/perl-xml/perl-xml-faq/" - >http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/perl-xml/perl-xml-faq/</ulink></para> + url="http://perl-xml.cvs.sourceforge.net/perl-xml/perl-xml-faq/" + >http://perl-xml.cvs.sourceforge.net/perl-xml/perl-xml-faq/</ulink></para> </abstract> @@ -1692,7 +1692,7 @@ $string =~ tr/\x91\x92\x93\x94\x96\x97/''""\-\-/; $string =~ s/\x85/.../sg; - $string =~ tr/[\x80-\x9F]//d; + $string =~ tr/\x80-\x9F//d; return($string); } |
From: Grant M. <gr...@us...> - 2006-10-12 08:57:58
|
Update of /cvsroot/perl-xml/xml-simple In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26018 Modified Files: todo Log Message: - refactor cache handling routines for easier overriding Index: todo =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/todo,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- todo 8 Oct 2006 07:44:26 -0000 1.2 +++ todo 12 Oct 2006 08:57:51 -0000 1.3 @@ -2,7 +2,9 @@ ========== - fix infinite loop reported by Lee Goddard - add new_hashref hook method +- refactored cache save/restore methods for easier overriding To Do ===== -- add cache_dir (?) method (rather than option) +- make options handling method overridable +- add a parse_string method? |
From: Grant M. <gr...@us...> - 2006-10-12 08:57:58
|
Update of /cvsroot/perl-xml/xml-simple/lib/XML In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26018/lib/XML Modified Files: Simple.pm Log Message: - refactor cache handling routines for easier overriding Index: Simple.pm =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/lib/XML/Simple.pm,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- Simple.pm 8 Oct 2006 07:44:26 -0000 1.30 +++ Simple.pm 12 Oct 2006 08:57:51 -0000 1.31 @@ -57,11 +57,6 @@ $PREFERRED_PARSER = undef; my $StrictMode = 0; -my %CacheScheme = ( - storable => [ \&StorableSave, \&StorableRestore ], - memshare => [ \&MemShareSave, \&MemShareRestore ], - memcopy => [ \&MemCopySave, \&MemCopyRestore ] - ); my @KnownOptIn = qw(keyattr keeproot forcecontent contentkey noattr searchpath forcearray cache suppressempty parseropts @@ -197,10 +192,8 @@ if($self->{opt}->{cache}) { foreach $scheme (@{$self->{opt}->{cache}}) { - croak "Unsupported caching scheme: $scheme" - unless($CacheScheme{$scheme}); - - my $opt = $CacheScheme{$scheme}->[1]->($filename); + my $method = 'cache_read_' . $scheme; + my $opt = $self->$method($filename); return($opt) if($opt); } } @@ -232,7 +225,8 @@ } if($self->{opt}->{cache}) { - $CacheScheme{$self->{opt}->{cache}->[0]}->[0]->($ref, $filename); + my $method = 'cache_write_' . $self->{opt}->{cache}->[0]; + $self->$method($ref, $filename); } return($ref); @@ -345,17 +339,16 @@ ############################################################################## -# Sub: StorableSave() +# Method: cache_write_storable() # # Wrapper routine for invoking Storable::nstore() to cache a parsed data # structure. # -sub StorableSave { - my($data, $filename) = @_; +sub cache_write_storable { + my($self, $data, $filename) = @_; - my $cachefile = $filename; - $cachefile =~ s{(\.xml)?$}{.stor}; + my $cachefile = $self->storable_filename($filename); require Storable; # We didn't need it until now @@ -371,18 +364,17 @@ ############################################################################## -# Sub: StorableRestore() +# Method: cache_read_storable() # # Wrapper routine for invoking Storable::retrieve() to read a cached parsed # data structure. Only returns cached data if the cache file exists and is # newer than the source XML file. # -sub StorableRestore { - my($filename) = @_; +sub cache_read_storable { + my($self, $filename) = @_; - my $cachefile = $filename; - $cachefile =~ s{(\.xml)?$}{.stor}; + my $cachefile = $self->storable_filename($filename); return unless(-r $cachefile); return unless((stat($cachefile))[9] > (stat($filename))[9]); @@ -400,27 +392,43 @@ ############################################################################## -# Sub: MemShareSave() +# Method: storable_filename() +# +# Translates the supplied source XML filename into a filename for the storable +# cached data. A '.stor' suffix is added after stripping an optional '.xml' +# suffix. +# + +sub storable_filename { + my($self, $cachefile) = @_; + + $cachefile =~ s{(\.xml)?$}{.stor}; + return $cachefile; +} + + +############################################################################## +# Method: cache_write_memshare() # # Takes the supplied data structure reference and stores it away in a global # hash structure. # -sub MemShareSave { - my($data, $filename) = @_; +sub cache_write_memshare { + my($self, $data, $filename) = @_; $MemShareCache{$filename} = [time(), $data]; } ############################################################################## -# Sub: MemShareRestore() +# Method: cache_read_memshare() # # Takes a filename and looks in a global hash for a cached parsed version. # -sub MemShareRestore { - my($filename) = @_; +sub cache_read_memshare { + my($self, $filename) = @_; return unless($MemShareCache{$filename}); return unless($MemShareCache{$filename}->[0] > (stat($filename))[9]); @@ -431,14 +439,14 @@ ############################################################################## -# Sub: MemCopySave() +# Method: cache_write_memcopy() # # Takes the supplied data structure and stores a copy of it in a global hash # structure. # -sub MemCopySave { - my($data, $filename) = @_; +sub cache_write_memcopy { + my($self, $data, $filename) = @_; require Storable; # We didn't need it until now @@ -447,14 +455,14 @@ ############################################################################## -# Sub: MemCopyRestore() +# Method: cache_read_memcopy() # # Takes a filename and looks in a global hash for a cached parsed version. # Returns a reference to a copy of that data structure. # -sub MemCopyRestore { - my($filename) = @_; +sub cache_read_memcopy { + my($self, $filename) = @_; return unless($MemCopyCache{$filename}); return unless($MemCopyCache{$filename}->[0] > (stat($filename))[9]); @@ -682,6 +690,11 @@ } if($opt->{cache}) { $_ = lc($_) foreach (@{$opt->{cache}}); + foreach my $scheme (@{$opt->{cache}}) { + my $method = 'cache_read_' . $scheme; + croak "Unsupported caching scheme: $scheme" + unless($self->can($method)); + } } if(exists($opt->{parseropts})) { |
From: Grant M. <gr...@us...> - 2006-10-12 08:57:58
|
Update of /cvsroot/perl-xml/xml-simple/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26018/t Modified Files: B_Hooks.t Log Message: - refactor cache handling routines for easier overriding Index: B_Hooks.t =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/t/B_Hooks.t,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- B_Hooks.t 8 Oct 2006 07:44:26 -0000 1.1 +++ B_Hooks.t 12 Oct 2006 08:57:52 -0000 1.2 @@ -3,8 +3,9 @@ use strict; use Test::More; +use File::Spec; -plan tests => 4; +plan tests => 12; use_ok('XML::Simple'); @@ -64,4 +65,72 @@ } + +my $xs = XML::Simple->new(cache => 'storable'); +my $sx = ElbarotsXS->new(cache => 'storable'); + +isa_ok($sx, 'XML::Simple', 'object of class ElbarotsXS'); + +my $src_file = File::Spec->catfile('t', 'test1.xml'); + +is( + $xs->storable_filename($src_file), + File::Spec->catfile('t', 'test1.stor'), + 'default storable cache filename looks good' +); + +my $cache_file = File::Spec->catfile('t', '1tset.stor'),; +is( + $sx->storable_filename($src_file), + $cache_file, + 'overridden storable cache filename looks good' +); + +SKIP: { + eval { require Storable }; + + skip "Storable not installed", 2 if $@; + + unlink($cache_file), + ok(! -e $cache_file, 'overridden cache file does not exist before parse'); + my $data = $sx->xml_in($src_file); + ok(-e $cache_file, 'overridden cache file does exist after parse'); + unlink($cache_file), +} + +my $data = eval { + $xs = XML::Simple->new(cache => 'floogle'); + $xs->xml_in($src_file); +}; +ok($@, 'bad cache scheme was rejected'); + +$data = eval { + $sx = ElbarotsXS->new(cache => 'floogle'); + $sx->xml_in($src_file); +}; +ok(! $@, 'custom cache scheme was not rejected'); +is_deeply( + $data, + { data => 'floogle' }, + 'custom cache reading method delivered the goods' +); + exit 0; + + +package ElbarotsXS; + +use base 'XML::Simple'; + +sub storable_filename { + my($self, $path) = @_; + + my($vol, $dir, $file) = File::Spec->splitpath( $path ); + $file =~ s{\.xml$}{}; + + return File::Spec->catpath($vol, $dir, reverse($file) . '.stor'); +} + +sub cache_read_floogle { + return { data => 'floogle' }; +} |
From: Grant M. <gr...@us...> - 2006-10-08 07:44:30
|
Update of /cvsroot/perl-xml/xml-simple In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19558 Modified Files: MANIFEST todo Log Message: - add hook method: new_hashref() Index: MANIFEST =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/MANIFEST,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- MANIFEST 29 Jan 2005 04:43:02 -0000 1.8 +++ MANIFEST 8 Oct 2006 07:44:26 -0000 1.9 @@ -18,6 +18,7 @@ t/8_Namespaces.t t/9_Strict.t t/A_XMLParser.t +t/B_Hooks.t t/desertnet.src t/lib/TagsToUpper.pm t/srt.xml Index: todo =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/todo,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- todo 29 Jan 2005 04:20:58 -0000 1.1 +++ todo 8 Oct 2006 07:44:26 -0000 1.2 @@ -1,2 +1,8 @@ -- test cases - - iterate parsers (only on author's machine?) +To Release +========== +- fix infinite loop reported by Lee Goddard +- add new_hashref hook method + +To Do +===== +- add cache_dir (?) method (rather than option) |
From: Grant M. <gr...@us...> - 2006-10-08 07:44:30
|
Update of /cvsroot/perl-xml/xml-simple/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19558/t Added Files: B_Hooks.t Log Message: - add hook method: new_hashref() --- NEW FILE: B_Hooks.t --- # $Id: B_Hooks.t,v 1.1 2006/10/08 07:44:26 grantm Exp $ # vim: syntax=perl use strict; use Test::More; plan tests => 4; use_ok('XML::Simple'); SKIP: { eval { require Tie::IxHash }; skip "Tie::IxHash not installed", 3 if $@; $@ = ''; eval <<'EOF'; package SimpleOrder; use base qw(XML::Simple); use Tie::IxHash; sub new_hashref { my $self = shift; my %hash; tie %hash, 'Tie::IxHash', @_; return \%hash; } EOF ok(!$@, 'no errors processing SimpleOrder'); my $xs = SimpleOrder->new; my $xml = q{ <nums> <num id="one">I</num> <num id="two">II</num> <num id="three">III</num> <num id="four">IV</num> <num id="five">V</num> <num id="six">VI</num> <num id="seven">VII</num> </nums> }; my $expected = { 'one' => { 'content' => 'I' }, 'two' => { 'content' => 'II' }, 'three' => { 'content' => 'III' }, 'four' => { 'content' => 'IV' }, 'five' => { 'content' => 'V' }, 'six' => { 'content' => 'VI' }, 'seven' => { 'content' => 'VII' }, }; my $data = $xs->xml_in($xml); is_deeply($data->{num}, $expected, 'hash content looks good'); is_deeply( [ keys %{$data->{num}} ], [ qw(one two three four five six seven) ], 'order of the hash keys looks good too' ); } exit 0; |
From: Grant M. <gr...@us...> - 2006-10-08 07:44:30
|
Update of /cvsroot/perl-xml/xml-simple/lib/XML In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19558/lib/XML Modified Files: Simple.pm Log Message: - add hook method: new_hashref() Index: Simple.pm =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/lib/XML/Simple.pm,v retrieving revision 1.29 retrieving revision 1.30 diff -u -d -r1.29 -r1.30 --- Simple.pm 5 Oct 2006 08:28:05 -0000 1.29 +++ Simple.pm 8 Oct 2006 07:44:26 -0000 1.30 @@ -1131,7 +1131,7 @@ my $name = shift; my $arrayref = shift; - my $hashref = {}; + my $hashref = $self->new_hashref; my($i, $key, $val, $flag); @@ -1203,6 +1203,20 @@ ############################################################################## +# Method: new_hashref() +# +# This is a hook routine for overriding in a sub-class. Some people believe +# that using Tie::IxHash here will solve order-loss problems. +# + +sub new_hashref { + my $self = shift; + + return { @_ }; +} + + +############################################################################## # Method: collapse_content() # # Helper routine for array_to_hash |
From: Grant M. <gr...@us...> - 2006-10-05 08:28:11
|
Update of /cvsroot/perl-xml/xml-simple In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7623 Modified Files: Changes Log Message: - added test for bad GroupTags option Index: Changes =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/Changes,v retrieving revision 1.24 retrieving revision 1.25 diff -u -d -r1.24 -r1.25 --- Changes 3 Oct 2006 01:07:48 -0000 1.24 +++ Changes 5 Oct 2006 08:28:05 -0000 1.25 @@ -1,5 +1,8 @@ Revision history for Perl module XML::Simple +2.16 ??? ?? 2006 + - Added test for bad GroupTags option (report from Lee Goddard) + 2.15 Oct 03 2006 - Makefile.PL changes: reject known-bad PurePerl and RTF parser modules; default to XML::SAX::Expat if no parser installed |
From: Grant M. <gr...@us...> - 2006-10-05 08:28:11
|
Update of /cvsroot/perl-xml/xml-simple/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7623/t Modified Files: 2_XMLout.t Log Message: - added test for bad GroupTags option Index: 2_XMLout.t =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/t/2_XMLout.t,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- 2_XMLout.t 19 Sep 2006 09:52:34 -0000 1.16 +++ 2_XMLout.t 5 Oct 2006 08:28:05 -0000 1.17 @@ -6,7 +6,7 @@ $^W = 1; -plan tests => 198; +plan tests => 201; ############################################################################## @@ -869,7 +869,15 @@ # </opt> # -$_ = XMLout($ref, grouptags => {dirs => 'dir'}, noattr => 1); +$@ = ''; +$_ = eval { XMLout($ref, grouptags => {dirs => 'dirs'}, noattr => 1); }; +ok($@, 'bad GroupTags value was caught'); +like("$@", qr{Bad value in GroupTags: 'dirs' => 'dirs'}, + 'error message looks good'); + +$@ = ''; +$_ = eval { XMLout($ref, grouptags => {dirs => 'dir'}, noattr => 1); }; +ok(!$@, 'good GroupTags value caused no error'); ok(s{\s*<(prefix)>before</\1>\s*}{ELEM}s, 'prefix OK'); ok(s{\s*<(suffix)>after</\1>\s*}{ELEM}s, 'suffix OK'); |
From: Grant M. <gr...@us...> - 2006-10-05 08:28:10
|
Update of /cvsroot/perl-xml/xml-simple/lib/XML In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7623/lib/XML Modified Files: Simple.pm Log Message: - added test for bad GroupTags option Index: Simple.pm =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/lib/XML/Simple.pm,v retrieving revision 1.28 retrieving revision 1.29 diff -u -d -r1.28 -r1.29 --- Simple.pm 3 Oct 2006 01:07:48 -0000 1.28 +++ Simple.pm 5 Oct 2006 08:28:05 -0000 1.29 @@ -791,8 +791,14 @@ # make sure there's nothing weird in {grouptags} - if($opt->{grouptags} and !UNIVERSAL::isa($opt->{grouptags}, 'HASH')) { - croak "Illegal value for 'GroupTags' option - expected a hashref"; + if($opt->{grouptags}) { + croak "Illegal value for 'GroupTags' option - expected a hashref" + unless UNIVERSAL::isa($opt->{grouptags}, 'HASH'); + + while(my($key, $val) = each %{$opt->{grouptags}}) { + next if $key ne $val; + croak "Bad value in GroupTags: '$key' => '$val'"; + } } |
From: Grant M. <gr...@us...> - 2006-10-03 01:07:52
|
Update of /cvsroot/perl-xml/xml-simple In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16851 Modified Files: README Changes Log Message: - for 2.15 release Index: README =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/README,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- README 29 Jan 2005 04:22:10 -0000 1.19 +++ README 3 Oct 2006 01:07:48 -0000 1.20 @@ -56,7 +56,7 @@ STATUS - This version (2.14) is the current stable release. + This version (2.15) is the current stable release. Please send any feedback to the author: gr...@cp... Index: Changes =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/Changes,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- Changes 19 Sep 2006 10:01:32 -0000 1.23 +++ Changes 3 Oct 2006 01:07:48 -0000 1.24 @@ -1,6 +1,8 @@ Revision history for Perl module XML::Simple -2.15 Sep ?? 2006 +2.15 Oct 03 2006 + - Makefile.PL changes: reject known-bad PurePerl and RTF parser modules; + default to XML::SAX::Expat if no parser installed - allow '.' characters in variable names (suggested by Cosimo Streppone) - fix output of undefs in arrayrefs with SuppressEmpty (reported by ãã㪠- Kanna) |
From: Grant M. <gr...@us...> - 2006-10-03 01:07:52
|
Update of /cvsroot/perl-xml/xml-simple/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16851/t Modified Files: 1_XMLin.t Log Message: - for 2.15 release Index: 1_XMLin.t =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/t/1_XMLin.t,v retrieving revision 1.23 retrieving revision 1.24 diff -u -d -r1.23 -r1.24 --- 1_XMLin.t 28 Apr 2006 22:43:36 -0000 1.23 +++ 1_XMLin.t 3 Oct 2006 01:07:48 -0000 1.24 @@ -25,8 +25,8 @@ $@ = ''; eval "use XML::Simple;"; is($@, '', 'Module compiled OK'); -unless($XML::Simple::VERSION eq '2.14') { - diag("Warning: XML::Simple::VERSION = $XML::Simple::VERSION (expected 2.14)"); +unless($XML::Simple::VERSION eq '2.15') { + diag("Warning: XML::Simple::VERSION = $XML::Simple::VERSION (expected 2.15)"); } |
From: Grant M. <gr...@us...> - 2006-10-03 01:07:52
|
Update of /cvsroot/perl-xml/xml-simple/lib/XML In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16851/lib/XML Modified Files: Simple.pm Log Message: - for 2.15 release Index: Simple.pm =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/lib/XML/Simple.pm,v retrieving revision 1.27 retrieving revision 1.28 diff -u -d -r1.27 -r1.28 --- Simple.pm 19 Sep 2006 10:01:32 -0000 1.27 +++ Simple.pm 3 Oct 2006 01:07:48 -0000 1.28 @@ -53,7 +53,7 @@ @ISA = qw(Exporter); @EXPORT = qw(XMLin XMLout); @EXPORT_OK = qw(xml_in xml_out); -$VERSION = '2.14'; +$VERSION = '2.15'; $PREFERRED_PARSER = undef; my $StrictMode = 0; |
From: Grant M. <gr...@us...> - 2006-10-03 01:02:27
|
Update of /cvsroot/perl-xml/xml-simple In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15024 Modified Files: Makefile.PL Log Message: - reject known-bad SAX parsers - if no parser installed, default to XML::SAX::Expat Index: Makefile.PL =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/Makefile.PL,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- Makefile.PL 17 Nov 2004 08:43:52 -0000 1.7 +++ Makefile.PL 3 Oct 2006 01:02:20 -0000 1.8 @@ -28,6 +28,47 @@ print "Checking installed modules ...\n"; if ( eval { require XML::SAX } && ! $@ ) { + my $default_parser = ref(XML::SAX::ParserFactory->parser()); + if ($default_parser eq 'XML::SAX::PurePerl') { + my $version = XML::SAX->VERSION; + if($version > 0.12 and $version < 0.15) { + die <<"EOF"; +============================================================================= + + Fatal error: Your default XML parser (XML::SAX::PurePerl) is broken. + + There are known bugs in the PurePerl parser included with version 0.13 + and 0.14 of XML::SAX. The XML::Simple tests will fail with this parser. + + One way to avoid the problem is to install XML::SAX::Expat - it will + install itself as the system default XML parser and then you will be able + to install XML::Simple successfully. XML::SAX::Expat is also much faster + than XML::SAX::PurePerl so you probably want it anyway. + +============================================================================= +EOF + } + } + elsif ($default_parser eq 'XML::SAX::RTF') { + die <<"EOF"; +============================================================================= + + Fatal error: Your default XML parser (XML::SAX::RTF) is broken. + + The XML::SAX:RTF module is installed as the default XML parser on your + system. This is a bug - although the module does generate SAX events, + it does not parse XML and should not register itself as an XML parser. + + One way to avoid the problem is to install XML::SAX::Expat - it will + register itself as the system default XML parser and then you will be + able to install XML::Simple successfully. + + Another solution would be to locate the XML/SAX/ParserDetails.ini file + and edit it to completely remove the section beginning [XML::SAX::RTF]. + +============================================================================= +EOF + } print "XML::SAX is installed, it will be used by the test suite\n"; $make_params->{PREREQ_PM}->{'XML::SAX'} = 0; $make_params->{PREREQ_PM}->{'XML::NamespaceSupport'} = 1.04; @@ -40,6 +81,8 @@ print "You don't have either XML::SAX or XML::Parser installed!\n"; $make_params->{PREREQ_PM}->{'XML::SAX'} = 0; $make_params->{PREREQ_PM}->{'XML::NamespaceSupport'} = 1.04; + # Hopefully the following line can be removed after next XML::SAX release + $make_params->{PREREQ_PM}->{'XML::SAX::Expat'} = 0; } eval { require Storable }; |
From: Grant M. <gr...@us...> - 2006-09-19 10:01:35
|
Update of /cvsroot/perl-xml/xml-simple/lib/XML In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14380/lib/XML Modified Files: Simple.pm Log Message: - integrate Dan Sully's patch to reduce memory usage Index: Simple.pm =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/lib/XML/Simple.pm,v retrieving revision 1.26 retrieving revision 1.27 diff -u -d -r1.26 -r1.27 --- Simple.pm 19 Sep 2006 09:52:34 -0000 1.26 +++ Simple.pm 19 Sep 2006 10:01:32 -0000 1.27 @@ -218,8 +218,8 @@ # Parsing is required, so let's get on with it - my $tree = $self->build_tree($filename, $string); - + my $tree = $self->build_tree($filename, ref($string) ? $string : \$string); + undef($string); # Now work some magic on the resulting parse tree @@ -240,20 +240,21 @@ ############################################################################## -# Method: build_tree() +#Method: build_tree() # # This routine will be called if there is no suitable pre-parsed tree in a # cache. It parses the XML and returns an XML::Parser 'Tree' style data # structure (summarised in the comments for the collapse() routine below). # -# XML::Simple requires the services of another module that knows how to -# parse XML. If XML::SAX is installed, the default SAX parser will be used, +# XML::Simple requires the services of another module that knows how to parse +# XML. If XML::SAX is installed, the default SAX parser will be used, # otherwise XML::Parser will be used. # # This routine expects to be passed a 'string' as argument 1 or a filename as -# argument 2. The 'string' might be a string of XML or it might be a -# reference to an IO::Handle. (This non-intuitive mess results in part from -# the way XML::Parser works but that's really no excuse). +# argument 2. The 'string' might be a string of XML (passed by reference to +# save memory) or it might be a reference to an IO::Handle. (This +# non-intuitive mess results in part from the way XML::Parser works but that's +# really no excuse). # sub build_tree { @@ -288,11 +289,11 @@ $tree = $sp->parse_uri($filename); } else { - if(ref($string)) { + if(ref($string) && ref($string) ne 'SCALAR') { $tree = $sp->parse_file($string); } else { - $tree = $sp->parse_string($string); + $tree = $sp->parse_string($$string); } } @@ -336,7 +337,7 @@ close(XML_FILE); } else { - $tree = $xp->parse($string); + $tree = $xp->parse($$string); } return($tree); |
From: Grant M. <gr...@us...> - 2006-09-19 10:01:34
|
Update of /cvsroot/perl-xml/xml-simple In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14380 Modified Files: Changes Log Message: - integrate Dan Sully's patch to reduce memory usage Index: Changes =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/Changes,v retrieving revision 1.22 retrieving revision 1.23 diff -u -d -r1.22 -r1.23 --- Changes 19 Sep 2006 09:52:34 -0000 1.22 +++ Changes 19 Sep 2006 10:01:32 -0000 1.23 @@ -4,8 +4,10 @@ - allow '.' characters in variable names (suggested by Cosimo Streppone) - fix output of undefs in arrayrefs with SuppressEmpty (reported by ãã㪠- Kanna) - - tidy up code and docs around lexical filehandle passed to - OutputFile (report from Helge Sauer) + - tidy up code and docs around lexical filehandle passed to OutputFile + (report from Helge Sauer) + - reduce memory usage by passing XML strings by reference (patch from + Dan Sully) 2.14 Jan 29 2005 - unlink and lock fixes for VMS (patch from Peter (Stig) Edwards) |
From: Grant M. <gr...@us...> - 2006-09-19 09:52:40
|
Update of /cvsroot/perl-xml/xml-simple In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10760 Modified Files: Changes Log Message: - automatically load IO::Handle if required to parse from lexical filehandle Index: Changes =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/Changes,v retrieving revision 1.21 retrieving revision 1.22 diff -u -d -r1.21 -r1.22 --- Changes 19 Sep 2006 08:33:30 -0000 1.21 +++ Changes 19 Sep 2006 09:52:34 -0000 1.22 @@ -4,6 +4,8 @@ - allow '.' characters in variable names (suggested by Cosimo Streppone) - fix output of undefs in arrayrefs with SuppressEmpty (reported by ãã㪠- Kanna) + - tidy up code and docs around lexical filehandle passed to + OutputFile (report from Helge Sauer) 2.14 Jan 29 2005 - unlink and lock fixes for VMS (patch from Peter (Stig) Edwards) |
From: Grant M. <gr...@us...> - 2006-09-19 09:52:38
|
Update of /cvsroot/perl-xml/xml-simple/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10760/t Modified Files: 2_XMLout.t Log Message: - automatically load IO::Handle if required to parse from lexical filehandle Index: 2_XMLout.t =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/t/2_XMLout.t,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- 2_XMLout.t 19 Sep 2006 08:33:30 -0000 1.15 +++ 2_XMLout.t 19 Sep 2006 09:52:34 -0000 1.16 @@ -3,7 +3,6 @@ use strict; use Test::More; -use IO::File; $^W = 1; @@ -352,10 +351,10 @@ }xs, 'and encodes as expected'); -# Try encoding a blessed reference and confirm that it fails +# Try encoding a non array/hash blessed reference and confirm that it fails -$_ = eval { my $ref = new IO::File; XMLout($ref) }; -ok(!defined($_), 'caught blessed reference in data structure'); +$_ = eval { my $ref = bless \*STDERR, 'BogoClass'; XMLout($ref) }; +is($_, undef, 'caught blessed non array/hash reference in data structure'); like($@, qr/Can't encode a value of type: /, 'with correct error message'); @@ -531,8 +530,7 @@ ok(!-e $TestFile); eval { - my $fh = new IO::File; - $fh->open(">$TestFile") || die "$!"; + open my $fh, '>', $TestFile or die "$!"; XMLout($hashref1, outputfile => $fh); $fh->close(); }; |
From: Grant M. <gr...@us...> - 2006-09-19 09:52:38
|
Update of /cvsroot/perl-xml/xml-simple/lib/XML In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10760/lib/XML Modified Files: Simple.pm Log Message: - automatically load IO::Handle if required to parse from lexical filehandle Index: Simple.pm =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/lib/XML/Simple.pm,v retrieving revision 1.25 retrieving revision 1.26 diff -u -d -r1.25 -r1.26 --- Simple.pm 19 Sep 2006 08:33:30 -0000 1.25 +++ Simple.pm 19 Sep 2006 09:52:34 -0000 1.26 @@ -546,7 +546,12 @@ if($self->{opt}->{outputfile}) { if(ref($self->{opt}->{outputfile})) { - return($self->{opt}->{outputfile}->print($xml)); + my $fh = $self->{opt}->{outputfile}; + if(UNIVERSAL::isa($fh, 'GLOB') and !UNIVERSAL::can($fh, 'print')) { + eval { require IO::Handle; }; + croak $@ if $@; + } + return($fh->print($xml)); } else { local(*OUT); @@ -2445,6 +2450,10 @@ open my $fh, '>:encoding(iso-8859-1)', $path or die "open($path): $!"; XMLout($ref, OutputFile => $fh); +Note, XML::Simple does not require that the object you pass in to the +OutputFile option inherits from L<IO::Handle> - it simply assumes the object +supports a C<print> method. + =head2 ParserOpts => [ XML::Parser Options ] I<# in - don't use this> I<Note: This option is now officially deprecated. If you find it useful, email |