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...> - 2004-03-02 08:29:40
|
Update of /cvsroot/perl-xml/xml-simple/lib/XML In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32112/lib/XML Modified Files: Simple.pm Log Message: - for release 2.11 Index: Simple.pm =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/lib/XML/Simple.pm,v retrieving revision 1.17 retrieving revision 1.18 diff -u -d -r1.17 -r1.18 --- Simple.pm 29 Feb 2004 09:48:17 -0000 1.17 +++ Simple.pm 2 Mar 2004 08:18:02 -0000 1.18 @@ -53,7 +53,7 @@ @ISA = qw(Exporter); @EXPORT = qw(XMLin XMLout); @EXPORT_OK = qw(xml_in xml_out); -$VERSION = '2.10'; +$VERSION = '2.11'; $PREFERRED_PARSER = undef; my $StrictMode = 0; |
From: Grant M. <gr...@us...> - 2004-03-02 08:29:24
|
Update of /cvsroot/perl-xml/xml-simple/t In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32070/t Modified Files: 2_XMLout.t Log Message: - fixed test with hash ordering assumption Index: 2_XMLout.t =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/t/2_XMLout.t,v retrieving revision 1.10 retrieving revision 1.11 diff -u -d -r1.10 -r1.11 --- 2_XMLout.t 29 Feb 2004 09:49:18 -0000 1.10 +++ 2_XMLout.t 2 Mar 2004 08:17:45 -0000 1.11 @@ -1056,18 +1056,23 @@ skip "Tie::IxHash not installed", 1 if $@; my(%hash1, %hash2); - tie %hash1, 'Tie::IxHash', Jan => 1, Feb => 2, Mar => 3, Apr => 4; - tie %hash2, 'Tie::IxHash', X => { b => 2 }, A => { c => 3 }, Z => { a => 1 }; + tie %hash1, 'Tie::IxHash', Jan => 1, Feb => 2, Mar => 3, Apr => 4, May => 5; + tie %hash2, 'Tie::IxHash', X => { b => 2 }, A => { c => 3 }, Z => { a => 1 }, + M => { f => 6 }, K => { e => 4 }, O => { d => 5 }; $hash1{func} = \%hash2; $_ = XMLout(\%hash1, NoSort => 1, KeyAttr => {func => 'name'}); - is($_, qq(<opt Jan="1" Feb="2" Mar="3" Apr="4">\n) . - qq( <func b="2" name="X" />\n) . - qq( <func c="3" name="A" />\n) . - qq( <func a="1" name="Z" />\n) . - qq(</opt>\n), - 'Suppressing sort worked'); + like($_, qr{ + ^<opt\sJan="1"\sFeb="2"\sMar="3"\sApr="4"\sMay="5">\s+ + <func(\sb="2"|\sname="X"){2}\s/>\s+ + <func(\sc="3"|\sname="A"){2}\s/>\s+ + <func(\sa="1"|\sname="Z"){2}\s/>\s+ + <func(\sf="6"|\sname="M"){2}\s/>\s+ + <func(\se="4"|\sname="K"){2}\s/>\s+ + <func(\sd="5"|\sname="O"){2}\s/>\s+ + </opt>\s*$ + }sx, 'Suppressing sort worked'); } |
From: Grant M. <gr...@us...> - 2004-02-29 10:17:00
|
Update of /cvsroot/perl-xml/xml-simple In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26873 Modified Files: Changes README Log Message: - for release 2.10 Index: Changes =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/Changes,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- Changes 9 Sep 2003 09:37:41 -0000 1.14 +++ Changes 29 Feb 2004 10:06:51 -0000 1.15 @@ -1,5 +1,16 @@ Revision history for Perl module XML::Simple +2.10 Feb 29 2004 + - Added AttrIndent option (patch from Volker Moell) + - Hash keys are now sorted alphabetically by default; enable the + new NoSort option if you don't want this (patch from Volker Moell) + - Fixed bug where disabling array folding broke anonymous array handling + - Fixed bug when unfolding a tied hash + - SuppressEmpty patch from Douglas Wilson + - Numerous test improvements - Devel::Cover rocks! + - POD update re XMLin(XMLout($data)) caveats (bug report from Slaven + Rezic) + 2.09 Sep 09 2003 - Makefile.PL makeover contributed by Joshua Keroes - fixed hash ordering assumption in test script (reported by Michel Index: README =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/README,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- README 9 Sep 2003 09:37:41 -0000 1.14 +++ README 29 Feb 2004 10:06:51 -0000 1.15 @@ -56,21 +56,23 @@ STATUS - This version (2.09) is the current stable release. + This version (2.10) is the current stable release. Please send any feedback to the author: gr...@cp... NEW IN THIS RELEASE - - test fixes and POD updates + - Added AttrIndent option (patch from Volker Moell) + - Hash keys are now sorted alphabetically by default; enable the new + NoSort option if you don't want this (patch from Volker Moell) + - Fixed bug where disabling array folding broke anonymous array handling + - Fixed bug when unfolding a tied hash + - SuppressEmpty patch from Douglas Wilson + - Numerous test improvements - Devel::Cover rocks! + - POD updates - New in Version 2.08 - - fixed bug - no variable expansion in attributes (patch from Paul Bussé) - - New in Version 2.07 - - fixed bug which broke compatibility with Perl 5.005_03 - - fixed test problems with Storable - + New in Version 2.09 + - test fixes and POD updates See 'Changes' for a detailed history. |
From: Grant M. <gr...@us...> - 2004-02-29 10:01:19
|
Update of /cvsroot/perl-xml/xml-simple In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24321 Modified Files: MANIFEST Log Message: - added t/A_XMLParser.t and META.yml Index: MANIFEST =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/MANIFEST,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- MANIFEST 6 Nov 2002 07:57:28 -0000 1.6 +++ MANIFEST 29 Feb 2004 09:51:10 -0000 1.7 @@ -16,8 +16,10 @@ t/7_SaxStuff.t t/8_Namespaces.t t/9_Strict.t +t/A_XMLParser.t t/desertnet.src t/lib/TagsToUpper.pm t/subdir/test2.xml t/srt.xml t/test1.xml +META.yml Module meta-data (added by MakeMaker) |
From: Grant M. <gr...@us...> - 2004-02-29 09:58:26
|
Update of /cvsroot/perl-xml/xml-simple/lib/XML In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23851/lib/XML Modified Files: Simple.pm Log Message: - Added AttrIndent option (patch from Volker Moell) - Hash keys are now sorted alphabetically by default; enable the new NoSort option if you don't want this (patch from Volker Moell) - Fixed bug where disabling array folding broke anonymous array handling - Fixed bug when unfolding a tied hash - SuppressEmpty patch from Douglas Wilson - POD update re XMLin(XMLout()) caveats (bug report from Slaven Rezic) Index: Simple.pm =================================================================== RCS file: /cvsroot/perl-xml/xml-simple/lib/XML/Simple.pm,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- Simple.pm 9 Sep 2003 09:33:43 -0000 1.16 +++ Simple.pm 29 Feb 2004 09:48:17 -0000 1.17 @@ -53,7 +53,7 @@ @ISA = qw(Exporter); @EXPORT = qw(XMLin XMLout); @EXPORT_OK = qw(xml_in xml_out); -$VERSION = '2.09'; +$VERSION = '2.10'; $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 noindent); + grouptags nsexpand handler noindent attrindent nosort); my @DefKeyAttr = qw(name key id); my $DefRootName = qq(opt); @@ -381,9 +381,7 @@ return unless(-r $cachefile); return unless((stat($cachefile))[9] > (stat($filename))[9]); - unless($INC{'Storable.pm'}) { - require Storable; # We didn't need it until now - } + require Storable; # We didn't need it until now return(Storable::lock_retrieve($cachefile)); @@ -431,9 +429,7 @@ sub MemCopySave { my($data, $filename) = @_; - unless($INC{'Storable.pm'}) { - require Storable; # We didn't need it until now - } + require Storable; # We didn't need it until now $MemCopyCache{$filename} = [time(), Storable::dclone($data)]; } @@ -478,7 +474,7 @@ $self = new XML::Simple(); } - + croak "XMLout() requires at least one argument" unless(@_); my $ref = shift; $self->handle_options('out', @_); @@ -614,12 +610,10 @@ # Merge in options passed to constructor - if($self->{def_opt}) { - foreach (keys(%known_opt)) { - unless(exists($opt->{$_})) { - if(exists($self->{def_opt}->{$_})) { - $opt->{$_} = $self->{def_opt}->{$_}; - } + foreach (keys(%known_opt)) { + unless(exists($opt->{$_})) { + if(exists($self->{def_opt}->{$_})) { + $opt->{$_} = $self->{def_opt}->{$_}; } } } @@ -824,9 +818,7 @@ # If user did not supply a search path, default to current directory if(!@search_path) { - if(-e $file) { - return($file); - } + return($file) if(-e $file); croak "File does not exist: $file"; } @@ -970,13 +962,11 @@ # Turn arrayrefs into hashrefs if key fields present - my $count = 0; if($self->{opt}->{keyattr}) { while(($key,$val) = each %$attr) { if(defined($val) and UNIVERSAL::isa($val, 'ARRAY')) { $attr->{$key} = $self->array_to_hash($key, $val); } - $count++; } } @@ -999,6 +989,7 @@ # Fold hashes containing a single anonymous array up into just the array + my $count = scalar keys %$attr; if($count == 1 and exists $attr->{anon} and UNIVERSAL::isa($attr->{anon}, 'ARRAY') @@ -1253,7 +1244,7 @@ # Unfold hash to array if possible if(UNIVERSAL::isa($ref, 'HASH') # It is a hash - and %$ref # and it's not empty + and keys %$ref # and it's not empty and $self->{opt}->{keyattr} # and folding is enabled and $indent # and its not the root element ) { @@ -1344,15 +1335,22 @@ } if(keys %$ref) { - while(($key, $value) = each(%$ref)) { - next if(substr($key, 0, 1) eq '-'); + my $first_arg = 1; + foreach my $key ($self->sorted_keys($name, $ref)) { + my $value = $ref->{$key}; + next if(substr($key, 0, 1) eq '-'); if(!defined($value)) { unless(exists($self->{opt}->{suppressempty}) and !defined($self->{opt}->{suppressempty}) ) { carp 'Use of uninitialized value' if($^W); } - $value = {}; + if($key eq $self->{opt}->{contentkey}) { + $text_content = ''; + } + else { + $value = {}; + } } if(ref($value) or $self->{opt}->{noattr}) { push @nested, @@ -1364,7 +1362,10 @@ $text_content = $value; } else { + push @result, "\n$indent " . ' ' x length($name) + if($self->{opt}->{attrindent} and !$first_arg); push @result, ' ', $key, '="', $value , '"'; + $first_arg = 0; } } } @@ -1433,6 +1434,42 @@ ############################################################################## +# Method: sorted_keys() +# +# Returns the keys of the referenced hash sorted into alphabetical order, but +# with the 'key' key (as in KeyAttr) first, if there is one. +# + +sub sorted_keys { + my($self, $name, $ref) = @_; + + return keys %$ref if $self->{opt}->{nosort}; + + my %hash = %$ref; + my $keyattr = $self->{opt}->{keyattr}; + + my @key; + + if(ref $keyattr eq 'HASH') { + if(exists $keyattr->{$name} and exists $hash{$keyattr->{$name}->[0]}) { + push @key, $keyattr->{$name}->[0]; + delete $hash{$keyattr->{$name}->[0]}; + } + } + elsif(ref $keyattr eq 'ARRAY') { + foreach (@{$keyattr}) { + if(exists $hash{$_}) { + push @key, $_; + delete $hash{$_}; + last; + } + } + } + + return(@key, sort keys %hash); +} + +############################################################################## # Method: escape_value() # # Helper routine for automatically escaping values for XMLout(). @@ -1471,7 +1508,8 @@ my($key, $value); - foreach $key (keys(%$hashref)) { + my @keys = $self->{opt}->{nosort} ? keys %$hashref : sort keys %$hashref; + foreach $key (@keys) { $value = $hashref->{$key}; return($hashref) unless(UNIVERSAL::isa($value, 'HASH')); @@ -1743,8 +1781,8 @@ =head2 XMLout() Takes a data structure (generally a hashref) and returns an XML encoding of -that structure. If the resulting XML is parsed using C<XMLin()>, it will -return a data structure equivalent to the original. +that structure. If the resulting XML is parsed using C<XMLin()>, it should +return a data structure equivalent to the original (see caveats below). The C<XMLout()> function can also be used to output the XML as SAX events see the C<Handler> option and L<"SAX SUPPORT"> for more details). @@ -1779,6 +1817,12 @@ Note also that although you can nest hashes and arrays to arbitrary levels, circular data structures are not supported and will cause C<XMLout()> to die. +If you wish to 'round-trip' arbitrary data structures from Perl to XML and back +to Perl, then you should probably disable array folding (using the KeyAttr +option) both with C<XMLout()> and with C<XMLin()>. If you still don't get the +expected results, you may prefer to use L<XML::Dumper> which is designed for +exactly that purpose. + Refer to L<"WHERE TO FROM HERE?"> if C<XMLout()> is too simple for your needs. @@ -1841,6 +1885,11 @@ or you can add underscores between the words (eg: key_attr). +=head2 AttrIndent => 1 I<# out - handy> + +When you are using C<XMLout()>, enable this option to have attributes printed +one-per-line with sensible indentation rather than all on one line. + =head2 Cache => [ cache schemes ] I<# in - advanced> Because loading the B<XML::Parser> module and parsing an XML file can consume a @@ -2209,6 +2258,29 @@ When used with C<XMLin()>, any attributes in the XML will be ignored. +=head2 NoEscape => 1 I<# out - seldom used> + +By default, C<XMLout()> will translate the characters 'E<lt>', 'E<gt>', '&' and +'"' to '<', '>', '&' and '"' respectively. Use this option to +suppress escaping (presumably because you've already escaped the data in some +more sophisticated manner). + +=head2 NoIndent => 1 I<# out - 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. + +=head2 NoSort => 1 I<# out - seldom used> + +Newer versions of XML::Simple sort elements and attributes alphabetically (*), +by default. Enable this option to suppress the sorting - possibly for +backwards compatibility. + +* Actually, sorting is alphabetical but 'key' attribute or element names (as in +'KeyAttr') sort first. Also, when a hash of hashes is 'unfolded', the elements +are sorted alphabetically by the value of the key field. + =head2 NormaliseSpace => 0 | 1 | 2 I<# in - handy> This option controls how whitespace in text content is handled. Recognised @@ -2236,19 +2308,6 @@ Note: you can spell this option with a 'z' if that is more natural for you. -=head2 NoEscape => 1 I<# out - seldom used> - -By default, C<XMLout()> will translate the characters 'E<lt>', 'E<gt>', '&' and -'"' to '<', '>', '&' and '"' respectively. Use this option to -suppress escaping (presumably because you've already escaped the data in some -more sophisticated manner). - -=head2 NoIndent => 1 I<# out - 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. - =head2 NSExpand => 1 I<# in+out handy - SAX only> This option controls namespace expansion - the translation of element and @@ -2323,7 +2382,8 @@ The option also controls what C<XMLout()> does with undefined values. Setting the option to undef causes undefined values to be output as -empty elements (rather than empty attributes). +empty elements (rather than empty attributes), it also suppresses the +generation of warnings about undefined values. =head2 Variables => { name => value } I<# in - handy> @@ -2813,10 +2873,6 @@ XPath support. -=head1 STATUS - -This version (2.09) is the current stable version. - =head1 SEE ALSO B<XML::Simple> requires either L<XML::Parser> or L<XML::SAX>. @@ -2830,7 +2886,7 @@ =head1 COPYRIGHT -Copyright 1999-2003 Grant McLean E<lt>gr...@cp...E<gt> +Copyright 1999-2004 Grant McLean E<lt>gr...@cp...E<gt> This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
From: Petr C. <pci...@us...> - 2004-02-19 13:59:49
|
Update of /cvsroot/perl-xml/sax-perl-org In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29104 Modified Files: index.html sax-2.1-idx.html sax-2.1-ref.html Log Message: Importing Perl SAX 2.1 working drafts Index: index.html =================================================================== RCS file: /cvsroot/perl-xml/sax-perl-org/index.html,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- index.html 19 Feb 2004 09:50:04 -0000 1.2 +++ index.html 19 Feb 2004 13:49:18 -0000 1.3 @@ -32,13 +32,13 @@ <tr> <td> <ul> - <li><a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/sax-perl-org/sax-2.1.html?rev=HEAD&content-type=text/html">Perl + <li><a href="http://cvs.sourceforge.net/viewcvs.py/*checkout*/perl-xml/sax-perl-org/sax-2.1.html?rev=HEAD&content-type=text/html">Perl SAX 2.1 Binding</a></li> - <li><a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/sax-perl-org/sax-2.1-adv.html?rev=HEAD&content-type=text/html">Perl + <li><a href="http://cvs.sourceforge.net/viewcvs.py/*checkout*/perl-xml/sax-perl-org/sax-2.1-adv.html?rev=HEAD&content-type=text/html">Perl SAX 2.1 Advanced</a></li> - <li><a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/sax-perl-org/sax-2.1-ref.html?rev=HEAD&content-type=text/html">Perl + <li><a href="http://cvs.sourceforge.net/viewcvs.py/*checkout*/perl-xml/sax-perl-org/sax-2.1-ref.html?rev=HEAD&content-type=text/html">Perl SAX 2.1 Reference</a></li> - <li><a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/sax-perl-org/changes-2.1?rev=HEAD&content-type=text/plain">Changes + <li><a href="http://cvs.sourceforge.net/viewcvs.py/*checkout*/perl-xml/sax-perl-org/changes-2.1?rev=HEAD&content-type=text/plain">Changes and Issues</a></li> </ul> </td> Index: sax-2.1-idx.html =================================================================== RCS file: /cvsroot/perl-xml/sax-perl-org/sax-2.1-idx.html,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- sax-2.1-idx.html 19 Feb 2004 09:50:04 -0000 1.1 +++ sax-2.1-idx.html 19 Feb 2004 13:49:18 -0000 1.2 @@ -49,22 +49,22 @@ <div class="title"><a name="parser"/>Parser</div> <div class="right">[<a href="#top">top</a>]</div> <div class="item"> - <a href="sax-2.1.html#parse" target="cnt">parse()</a> + <a href="sax-2.1.html?rev=HEAD&content-type=text/html#parse" target="cnt">parse()</a> </div> <div class="item"> - <a href="sax-2.1.html#parseFile" target="cnt">parse_file()</a> + <a href="sax-2.1.html?rev=HEAD&content-type=text/html#parseFile" target="cnt">parse_file()</a> </div> <div class="item"> - <a href="sax-2.1.html#parseString" target="cnt">parse_string()</a> + <a href="sax-2.1.html?rev=HEAD&content-type=text/html#parseString" target="cnt">parse_string()</a> </div> <div class="item"> - <a href="sax-2.1-adv.html#getFeature" target="cnt">get_feature()</a> + <a href="sax-2.1-adv.html?rev=HEAD&content-type=text/html#getFeature" target="cnt">get_feature()</a> </div> <div class="item"> - <a href="sax-2.1-adv.html#setFeature" target="cnt">set_feature()</a> + <a href="sax-2.1-adv.html?rev=HEAD&content-type=text/html#setFeature" target="cnt">set_feature()</a> </div> <div class="item"> - <a href="sax-2.1-adv.html#getFeatures" target="cnt">get_features()</a> + <a href="sax-2.1-adv.html?rev=HEAD&content-type=text/html#getFeatures" target="cnt">get_features()</a> </div> </div> @@ -72,37 +72,37 @@ <div class="title"><a name="content"/>ContentHandler</div> <div class="right">[<a href="#top">top</a>]</div> <div class="item"> - <a href="sax-2.1-adv.html#setDocumentLocator" target="cnt">set_document_locator()</a> + <a href="sax-2.1-adv.html?rev=HEAD&content-type=text/html#setDocumentLocator" target="cnt">set_document_locator()</a> </div> <div class="item"> - <a href="sax-2.1.html#startDocument" target="cnt">start_document()</a> + <a href="sax-2.1.html?rev=HEAD&content-type=text/html#startDocument" target="cnt">start_document()</a> </div> <div class="item"> - <a href="sax-2.1.html#endDocument" target="cnt">end_document()</a> + <a href="sax-2.1.html?rev=HEAD&content-type=text/html#endDocument" target="cnt">end_document()</a> </div> <div class="item"> - <a href="sax-2.1.html#startElement" target="cnt">start_element()</a> + <a href="sax-2.1.html?rev=HEAD&content-type=text/html#startElement" target="cnt">start_element()</a> </div> <div class="item"> - <a href="sax-2.1.html#endElement" target="cnt">end_element()</a> + <a href="sax-2.1.html?rev=HEAD&content-type=text/html#endElement" target="cnt">end_element()</a> </div> <div class="item"> - <a href="sax-2.1.html#characters" target="cnt">characters()</a> + <a href="sax-2.1.html?rev=HEAD&content-type=text/html#characters" target="cnt">characters()</a> </div> <div class="item"> - <a href="sax-2.1.html#ignorableWhitespace" target="cnt">ignorable_whitespace()</a> + <a href="sax-2.1.html?rev=HEAD&content-type=text/html#ignorableWhitespace" target="cnt">ignorable_whitespace()</a> </div> <div class="item"> - <a href="sax-2.1-adv.html#startPrefixMapping" target="cnt">start_prefix_mapping()</a> + <a href="sax-2.1-adv.html?rev=HEAD&content-type=text/html#startPrefixMapping" target="cnt">start_prefix_mapping()</a> </div> <div class="item"> - <a href="sax-2.1-adv.html#endPrefixMapping" target="cnt">end_prefix_mapping()</a> + <a href="sax-2.1-adv.html?rev=HEAD&content-type=text/html#endPrefixMapping" target="cnt">end_prefix_mapping()</a> </div> <div class="item"> - <a href="sax-2.1-adv.html#processingInstruction" target="cnt">processing_instruction()</a> + <a href="sax-2.1-adv.html?rev=HEAD&content-type=text/html#processingInstruction" target="cnt">processing_instruction()</a> </div> <div class="item"> - <a href="sax-2.1-adv.html#skippedEntity" target="cnt">skipped_entity()</a> + <a href="sax-2.1-adv.html?rev=HEAD&content-type=text/html#skippedEntity" target="cnt">skipped_entity()</a> </div> </div> @@ -110,13 +110,13 @@ <div class="title"><a name="error"/>ErrorHandler</div> <div class="right">[<a href="#top">top</a>]</div> <div class="item"> - <a href="sax-2.1-adv.html#warning" target="cnt">warning()</a> + <a href="sax-2.1-adv.html?rev=HEAD&content-type=text/html#warning" target="cnt">warning()</a> </div> <div class="item"> - <a href="sax-2.1-adv.html#error" target="cnt">error()</a> + <a href="sax-2.1-adv.html?rev=HEAD&content-type=text/html#error" target="cnt">error()</a> </div> <div class="item"> - <a href="sax-2.1-adv.html#fatalError" target="cnt">fatal_error()</a> + <a href="sax-2.1-adv.html?rev=HEAD&content-type=text/html#fatalError" target="cnt">fatal_error()</a> </div> </div> @@ -124,25 +124,25 @@ <div class="title"><a name="lexical"/>LexicalHandler</div> <div class="right">[<a href="#top">top</a>]</div> <div class="item"> - <a href="sax-2.1-adv.html#startDTD" target="cnt">start_dtd()</a> + <a href="sax-2.1-adv.html?rev=HEAD&content-type=text/html#startDTD" target="cnt">start_dtd()</a> </div> <div class="item"> - <a href="sax-2.1-adv.html#endDTD" target="cnt">end_dtd()</a> + <a href="sax-2.1-adv.html?rev=HEAD&content-type=text/html#endDTD" target="cnt">end_dtd()</a> </div> <div class="item"> - <a href="sax-2.1-adv.html#startEntity" target="cnt">start_entity()</a> + <a href="sax-2.1-adv.html?rev=HEAD&content-type=text/html#startEntity" target="cnt">start_entity()</a> </div> <div class="item"> - <a href="sax-2.1-adv.html#endEntity" target="cnt">end_entity()</a> + <a href="sax-2.1-adv.html?rev=HEAD&content-type=text/html#endEntity" target="cnt">end_entity()</a> </div> <div class="item"> - <a href="sax-2.1-adv.html#startCDATA" target="cnt">start_cdata()</a> + <a href="sax-2.1-adv.html?rev=HEAD&content-type=text/html#startCDATA" target="cnt">start_cdata()</a> </div> <div class="item"> - <a href="sax-2.1-adv.html#endCDATA" target="cnt">end_cdata()</a> + <a href="sax-2.1-adv.html?rev=HEAD&content-type=text/html#endCDATA" target="cnt">end_cdata()</a> </div> <div class="item"> - <a href="sax-2.1-adv.html#comment" target="cnt">comment()</a> + <a href="sax-2.1-adv.html?rev=HEAD&content-type=text/html#comment" target="cnt">comment()</a> </div> </div> @@ -150,10 +150,10 @@ <div class="title"><a name="dtd"/>DTDHandler</div> <div class="right">[<a href="#top">top</a>]</div> <div class="item"> - <a href="sax-2.1-adv.html#notationDecl" target="cnt">notation_decl()</a> + <a href="sax-2.1-adv.html?rev=HEAD&content-type=text/html#notationDecl" target="cnt">notation_decl()</a> </div> <div class="item"> - <a href="sax-2.1-adv.html#unparsedEntity" target="cnt">unparsed_entity_decl()</a> + <a href="sax-2.1-adv.html?rev=HEAD&content-type=text/html#unparsedEntity" target="cnt">unparsed_entity_decl()</a> </div> </div> @@ -161,16 +161,16 @@ <div class="title"><a name="decl"/>DeclHandler</div> <div class="right">[<a href="#top">top</a>]</div> <div class="item"> - <a href="sax-2.1-adv.html#elementDecl" target="cnt">element_decl()</a> + <a href="sax-2.1-adv.html?rev=HEAD&content-type=text/html#elementDecl" target="cnt">element_decl()</a> </div> <div class="item"> - <a href="sax-2.1-adv.html#attributeDecl" target="cnt">attribute_decl()</a> + <a href="sax-2.1-adv.html?rev=HEAD&content-type=text/html#attributeDecl" target="cnt">attribute_decl()</a> </div> <div class="item"> - <a href="sax-2.1-adv.html#internalEntityDecl" target="cnt">internal_entity_decl()</a> + <a href="sax-2.1-adv.html?rev=HEAD&content-type=text/html#internalEntityDecl" target="cnt">internal_entity_decl()</a> </div> <div class="item"> - <a href="sax-2.1-adv.html#externalEntityDecl" target="cnt">external_entity_decl()</a> + <a href="sax-2.1-adv.html?rev=HEAD&content-type=text/html#externalEntityDecl" target="cnt">external_entity_decl()</a> </div> </div> @@ -178,7 +178,7 @@ <div class="title"><a name="resolver"/>EntityResolver</div> <div class="right">[<a href="#top">top</a>]</div> <div class="item"> - <a href="sax-2.1-adv.html#resolveEntity" target="cnt">resolve_entity()</a> + <a href="sax-2.1-adv.html?rev=HEAD&content-type=text/html#resolveEntity" target="cnt">resolve_entity()</a> </div> </div> @@ -186,13 +186,13 @@ <div class="title"><a name="other"/>other objects</div> <div class="right">[<a href="#top">top</a>]</div> <div class="item"> - <a href="sax-2.1.html#Exceptions" target="cnt">Exceptions</a> + <a href="sax-2.1.html?rev=HEAD&content-type=text/html#Exceptions" target="cnt">Exceptions</a> </div> <div class="item"> - <a href="sax-2.1-adv.html#InputSources" target="cnt">Input Sources</a> + <a href="sax-2.1-adv.html?rev=HEAD&content-type=text/html#InputSources" target="cnt">Input Sources</a> </div> <div class="item"> - <a href="sax-2.1-adv.html#Features" target="cnt">Features</a> + <a href="sax-2.1-adv.html?rev=HEAD&content-type=text/html#Features" target="cnt">Features</a> </div> </div> Index: sax-2.1-ref.html =================================================================== RCS file: /cvsroot/perl-xml/sax-perl-org/sax-2.1-ref.html,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- sax-2.1-ref.html 19 Feb 2004 09:50:04 -0000 1.1 +++ sax-2.1-ref.html 19 Feb 2004 13:49:18 -0000 1.2 @@ -3,9 +3,9 @@ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> <frameset cols="225, *"> <noframes> - <a href="sax-2.1.html">Perl SAX 2.1 Binding</a> + <a href="http://cvs.sourceforge.net/viewcvs.py/*checkout*/perl-xml/sax-perl-org/sax-2.1.html?rev=HEAD&content-type=text/html">Perl SAX 2.1 Binding</a> </noframes> - <frame name="idx" id="idx" src="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/sax-perl-org/sax-2.1-idx.html?rev=HEAD&content-type=text/html" /> - <frame name="cnt" id="cnt"src="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/sax-perl-org/sax-2.1.html?rev=HEAD&content-type=text/html" /> + <frame name="idx" id="idx" src="http://cvs.sourceforge.net/viewcvs.py/*checkout*/perl-xml/sax-perl-org/sax-2.1-idx.html?rev=HEAD&content-type=text/html" /> + <frame name="cnt" id="cnt"src="http://cvs.sourceforge.net/viewcvs.py/*checkout*/perl-xml/sax-perl-org/sax-2.1.html?rev=HEAD&content-type=text/html" /> </frameset> |
From: Petr C. <pci...@us...> - 2004-02-19 10:00:23
|
Update of /cvsroot/perl-xml/sax-perl-org In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17540 Modified Files: index.html Added Files: changes-2.1 sax-2.1-adv.html sax-2.1-idx.html sax-2.1-ref.html sax-2.1.html Log Message: --- NEW FILE: changes-2.1 --- ======================================= = Perl SAX 2.1 Changes and Issues = ======================================= The purpose of this file is to record changes done from Perl SAX 2.0 and to track related issues. --------------------------------------- Changes --------------------------------------- [C1] XMLVersion and Encoding fields added to document locator (as in Locator2 interface of SAX 2.0 Ext. 1.1) --------------------------------------- Issues --------------------------------------- [I1] Resolution: none A parser should advertise SAX version it supports. There can be a new method ($parser->get_sax_version()) or a read-only feature (http://xmlns.perl.org/sax/version). This feature should be introduced also to Perl SAX 2.0 retrospectively to distinguish between 1.0, 2.0 and 2.1 drivers. [I2] Resolution: none "http://xml.org/sax/handlers/LexicalHandler" feature on the parser needs to be set to the object to receive lexical events currently. If the reader does not support lexical events, it will throw a XML::SAX::Exception::NotRecognized or a XML::SAX::Exception::NotSupported when you attempt to register the handler. DeclHandler works in the same way. Actually, this is a theory - XML::SAX::Base doesn't implement this currently. This approach is very different from the common PerlSAX mechanism: look for a specific handler, then look for a handler method on the default handler, ignore the callback when not found. It would be more 'perlish' to apply this simple mechanism to LexicalHandler and DeclHandler too. If we want these two be extension handlers (compliant 2.1 parsers are not required to support them) there could be read-only features to let apps to know whether extension handlers are supported o not (http://xmlns.perl.org/sax/LexicalHandler, DeclHandler). [I3] Resolution: none SAX 2.0 Ext. 1.1 has a new Attributes2 interface which extends attributes with new properties (Declared, Specified) to distinguish between attributed specified in an XML doc and those declared in DTD. This could be introduced into Perl SAX 2.1 as an optional extension (advertised by a feature). --- NEW FILE: sax-2.1-adv.html --- <!-- $Id: sax-2.1-adv.html,v 1.1 2004/02/19 09:50:04 pcimprich Exp $ --> <html> <head> <title>Advanced Features of the Perl SAX 2.1 Binding</title> <meta name="keywords" content="XML SGML SAX Perl libxml libxml-perl" /> </head> <body> <h1>Advanced SAX</h1> <p>The classes, methods, and features described below are not commonly used in most applications and can be ignored by most users. If however you find that you are not getting the granularity you expect from Basic SAX, this would be the place to look for more. Advanced SAX isn't advanced in the sense that it is harder, or requires better programming skills. It is simply more complete, and has been separated to keep Basic SAX simple in terms of the number of events one would have to deal with. </p> [...975 lines suppressed...] <li> Method names have been converted to lower-case with underscores. Parameters are all mixed case with initial upper-case. </li> </ul> <p> If compatibility is a problem for you consider writing a Filter that converts from this style to the one you want. It is likely that such a Filter will be available from CPAN in the not distant future. </p> <!-- <p>[FIXME: need to list package/class name equivalents for all hashes.]</p> --> </body> </html> --- NEW FILE: sax-2.1-idx.html --- <!-- $Id: sax-2.1-idx.html,v 1.1 2004/02/19 09:50:04 pcimprich Exp $ --> <html> <head> <title>Perl SAX 2.1</title> <style> a {text-decoration:none} div {font-size: 14px; color: #777777;} div.box {padding:4px 2px 4px 2px; margin:0px 0px 10px 0px; border:1px solid #777777;} div.title {font-size:16px; font-weight:bold; float:left; padding:0px 0px 0px 2px;} div.item {padding: 1px 0px 0px 10px; clear:left;} div.right {float:right; padding:0px 5px 0px 0px;} </style> </head> <body> <div class="box" style="background-color:#eeeeee"> <div class="title">Perl SAX 2.1</div> <div class="right">[<a href="http://sax.perl.org">home</a>]</div> <div class="item"> <a href="#parser">Parser</a> </div> <div class="item"> <a href="#content">ContentHandler</a> </div> <div class="item"> <a href="#error">ErrorHandler</a> </div> <div class="item"> <a href="#lexical">LexicalHandler</a> </div> <div class="item"> <a href="#dtd">DTDHandler</a> </div> <div class="item"> <a href="#decl">DeclHandler</a> </div> <div class="item"> <a href="#resolver">Entity Resolver</a> </div> <div class="item"> <a href="#other">other objects</a> </div> </div> <div class="box"> <div class="title"><a name="parser"/>Parser</div> <div class="right">[<a href="#top">top</a>]</div> <div class="item"> <a href="sax-2.1.html#parse" target="cnt">parse()</a> </div> <div class="item"> <a href="sax-2.1.html#parseFile" target="cnt">parse_file()</a> </div> <div class="item"> <a href="sax-2.1.html#parseString" target="cnt">parse_string()</a> </div> <div class="item"> <a href="sax-2.1-adv.html#getFeature" target="cnt">get_feature()</a> </div> <div class="item"> <a href="sax-2.1-adv.html#setFeature" target="cnt">set_feature()</a> </div> <div class="item"> <a href="sax-2.1-adv.html#getFeatures" target="cnt">get_features()</a> </div> </div> <div class="box"> <div class="title"><a name="content"/>ContentHandler</div> <div class="right">[<a href="#top">top</a>]</div> <div class="item"> <a href="sax-2.1-adv.html#setDocumentLocator" target="cnt">set_document_locator()</a> </div> <div class="item"> <a href="sax-2.1.html#startDocument" target="cnt">start_document()</a> </div> <div class="item"> <a href="sax-2.1.html#endDocument" target="cnt">end_document()</a> </div> <div class="item"> <a href="sax-2.1.html#startElement" target="cnt">start_element()</a> </div> <div class="item"> <a href="sax-2.1.html#endElement" target="cnt">end_element()</a> </div> <div class="item"> <a href="sax-2.1.html#characters" target="cnt">characters()</a> </div> <div class="item"> <a href="sax-2.1.html#ignorableWhitespace" target="cnt">ignorable_whitespace()</a> </div> <div class="item"> <a href="sax-2.1-adv.html#startPrefixMapping" target="cnt">start_prefix_mapping()</a> </div> <div class="item"> <a href="sax-2.1-adv.html#endPrefixMapping" target="cnt">end_prefix_mapping()</a> </div> <div class="item"> <a href="sax-2.1-adv.html#processingInstruction" target="cnt">processing_instruction()</a> </div> <div class="item"> <a href="sax-2.1-adv.html#skippedEntity" target="cnt">skipped_entity()</a> </div> </div> <div class="box"> <div class="title"><a name="error"/>ErrorHandler</div> <div class="right">[<a href="#top">top</a>]</div> <div class="item"> <a href="sax-2.1-adv.html#warning" target="cnt">warning()</a> </div> <div class="item"> <a href="sax-2.1-adv.html#error" target="cnt">error()</a> </div> <div class="item"> <a href="sax-2.1-adv.html#fatalError" target="cnt">fatal_error()</a> </div> </div> <div class="box"> <div class="title"><a name="lexical"/>LexicalHandler</div> <div class="right">[<a href="#top">top</a>]</div> <div class="item"> <a href="sax-2.1-adv.html#startDTD" target="cnt">start_dtd()</a> </div> <div class="item"> <a href="sax-2.1-adv.html#endDTD" target="cnt">end_dtd()</a> </div> <div class="item"> <a href="sax-2.1-adv.html#startEntity" target="cnt">start_entity()</a> </div> <div class="item"> <a href="sax-2.1-adv.html#endEntity" target="cnt">end_entity()</a> </div> <div class="item"> <a href="sax-2.1-adv.html#startCDATA" target="cnt">start_cdata()</a> </div> <div class="item"> <a href="sax-2.1-adv.html#endCDATA" target="cnt">end_cdata()</a> </div> <div class="item"> <a href="sax-2.1-adv.html#comment" target="cnt">comment()</a> </div> </div> <div class="box"> <div class="title"><a name="dtd"/>DTDHandler</div> <div class="right">[<a href="#top">top</a>]</div> <div class="item"> <a href="sax-2.1-adv.html#notationDecl" target="cnt">notation_decl()</a> </div> <div class="item"> <a href="sax-2.1-adv.html#unparsedEntity" target="cnt">unparsed_entity_decl()</a> </div> </div> <div class="box"> <div class="title"><a name="decl"/>DeclHandler</div> <div class="right">[<a href="#top">top</a>]</div> <div class="item"> <a href="sax-2.1-adv.html#elementDecl" target="cnt">element_decl()</a> </div> <div class="item"> <a href="sax-2.1-adv.html#attributeDecl" target="cnt">attribute_decl()</a> </div> <div class="item"> <a href="sax-2.1-adv.html#internalEntityDecl" target="cnt">internal_entity_decl()</a> </div> <div class="item"> <a href="sax-2.1-adv.html#externalEntityDecl" target="cnt">external_entity_decl()</a> </div> </div> <div class="box"> <div class="title"><a name="resolver"/>EntityResolver</div> <div class="right">[<a href="#top">top</a>]</div> <div class="item"> <a href="sax-2.1-adv.html#resolveEntity" target="cnt">resolve_entity()</a> </div> </div> <div class="box"> <div class="title"><a name="other"/>other objects</div> <div class="right">[<a href="#top">top</a>]</div> <div class="item"> <a href="sax-2.1.html#Exceptions" target="cnt">Exceptions</a> </div> <div class="item"> <a href="sax-2.1-adv.html#InputSources" target="cnt">Input Sources</a> </div> <div class="item"> <a href="sax-2.1-adv.html#Features" target="cnt">Features</a> </div> </div> </body> </html> --- NEW FILE: sax-2.1-ref.html --- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd"> <frameset cols="225, *"> <noframes> <a href="sax-2.1.html">Perl SAX 2.1 Binding</a> </noframes> <frame name="idx" id="idx" src="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/sax-perl-org/sax-2.1-idx.html?rev=HEAD&content-type=text/html" /> <frame name="cnt" id="cnt"src="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/sax-perl-org/sax-2.1.html?rev=HEAD&content-type=text/html" /> </frameset> --- NEW FILE: sax-2.1.html --- <!-- $Id: sax-2.1.html,v 1.1 2004/02/19 09:50:04 pcimprich Exp $ --> <html> <head> <title>Perl SAX 2.1 Binding</title> </head> <body> <h1>Perl SAX 2.1 Binding</h1> <p>SAX (Simple API for XML) is a common parser interface for XML parsers. It allows application writers to write applications that use XML parsers, but are independent of which parser is actually used.</p> <p>This document describes the version of SAX used by Perl modules. The original version of SAX 2.0, for Java, is described at <a href="http://sax.sourceforge.net/">http://sax.sourceforge.net/</a>.</p> <p>There are two basic interfaces in the Perl version of SAX, the parser interface and the handler interface. The parser interface creates new parser instances, starts parsing, and provides additional information to handlers on request. The handler interface is used to receive parse events from the parser. This pattern is also commonly called "Producer and Consumer" or "Generator and Sink". Note that the parser doesn't have to be an XML parser, all it needs to do is provide a stream of events to the handler as if it were parsing XML. But the actual data from which the events are generated can be anything, a Perl object, a CSV file, a database table... </p> <p>SAX is typically used like this: <pre> my $handler = MyHandler->new(); my $parser = AnySAXParser->new( Handler => $handler ); $parser->parse($uri); </pre></p> <p>Handlers are typically written like this: <pre> package MyHandler; sub new { my $type = shift; return bless {}, $type; } sub start_element { my ($self, $element) = @_; print "Starting element $element->{Name}\n"; } sub end_element { my ($self, $element) = @_; print "Ending element $element->{Name}\n"; } sub characters { my ($self, $characters) = @_; print "characters: $characters->{Data}\n"; } 1; </pre></p> <h2>Basic SAX Parser</h2> <p>These methods and options are the most commonly used with SAX parsers and event generators.</p> <p>Applications may not invoke a <tt>parse()</tt> method again while a parse is in progress (they should create a new SAX parser instead for each nested XML document). Once a parse is complete, an application may reuse the same parser object, possibly with a different input source.</p> <p>During the parse, the parser will provide information about the XML document through the registered event handlers. Note that an event that hasn't been registered (ie that doesn't have its corresponding method in the handler's class) will <b>not</b> be called. This allows one to only get the events one is interested in. </p> <p>If you generate SAX events, data are required to be passed to handler methods with all properties defined in this document unless otherwise specified. </p> <p><a name="parse"/> <dl><dt><b><tt class='function'>parse</tt></b>(<var>uri</var> [, <var>options</var>])</dt> <dd> Parses the XML instance identified by <var>uri</var> (a system identifier). <var>options</var> can be a list of options, value pairs or a hash (reference). Options include <tt>Handler</tt>, features and properties, and advanced SAX parser options. <tt>parse()</tt> returns the result of calling the <tt>end_document()</tt> handler. The options supported by <tt>parse()</tt> may vary slightly if what is being "parsed" isn't XML. </dd></dl></p> <p><a name="parseFile"/> <dl><dt><b><tt class='function'>parse_file</tt></b>(<var>stream</var> [, <var>options</var>])</dt> <dd> Parses the XML instance in the already opened <var>stream</var>, an IO::Handler or similar. <var>options</var> are the same as for <tt class='function'>parse()</tt>. <tt>parse_file()</tt> returns the result of calling the <tt>end_document()</tt> handler.</dd></dl></p> <p><a name="parseString"/> <dl><dt><b><tt class='function'>parse_string</tt></b>(<var>string</var> [, <var>options</var>])</dt> <dd> Parses the XML instance in <var>string</var>. <var>options</var> are the same as for <tt class='function'>parse()</tt>. <tt>parse_string()</tt> returns the result of calling the <tt>end_document()</tt> handler.</dd></dl></p> <p> <dl><dt><b><tt>Handler</tt></b></dt> <dd> The default handler object to receive all events from the parser. Applications may change <tt>Handler</tt> in the middle of the parse and the SAX parser will begin using the new handler immediately. The <a href="sax-2.1-adv.html">Advanced SAX</a> document lists a number of more specialized handlers that can be used should you wish to dispatch different types of events to different objects. </dd></dl></p> <h2><a name="BasicHandler">Basic SAX Handler</a></h2> <p>These methods are the most commonly used by SAX handlers.</p> <p><a name="startDocument"/> <dl><dt><b><tt class='function'>start_document</tt></b>(<var>document</var>)</dt> <dd> Receive notification of the beginning of a document. <p>The SAX parser will invoke this method only once, before any other methods (except for <tt>set_document_locator()</tt> in advanced SAX handlers).</p> No properties are defined for this event (<var>document</var> is empty).</dd></dl></p> <p><a name="endDocument"/> <dl><dt><b><tt class='function'>end_document</tt></b>(<var>document</var>)</dt> <dd> Receive notification of the end of a document. <p>The SAX parser will invoke this method only once, and it will be the last method invoked during the parse. The parser shall not invoke this method until it has either abandoned parsing (because of an unrecoverable error) or reached the end of input.</p> <p>No properties are defined for this event (<var>document</var> is empty).</p> The return value of <tt>end_document()</tt> is returned by the parser's <tt>parse()</tt> methods.</dd></dl></p> <p><a name="startElement"/> <dl><dt><b><tt class='function'>start_element</tt></b>(<var>element</var>)</dt> <dd> Receive notification of the start of an element. <p>The Parser will invoke this method at the beginning of every element in the XML document; there will be a corresponding <tt>end_element()</tt> event for every <tt>start_element()</tt> event (even when the element is empty). All of the element's content will be reported, in order, before the corresponding <tt>end_element()</tt> event.</p> <var>element</var> is a hash reference with these properties: <blockquote> <table> <tr><td><b><tt>Name</tt></b></td> <td>The element type name (including prefix).</td></tr> <tr><td><b><tt>Attributes</tt></b></td> <td>The attributes attached to the element, if any.</td></tr> </table> </blockquote> If namespace processing is turned on (which is the default), these properties are also available: <blockquote> <table> <tr><td><b><tt>NamespaceURI</tt></b></td> <td>The namespace of this element.</td></tr> <tr><td><b><tt>Prefix</tt></b></td> <td>The namespace prefix used on this element.</td></tr> <tr><td><b><tt>LocalName</tt></b></td> <td>The local name of this element.</td></tr> </table> </blockquote> <tt>Attributes</tt> is a reference to hash keyed by JClark namespace notation. That is, the keys are of the form "{NamespaceURI}LocalName". If the attribute has no NamespaceURI, then it is simply "{}LocalName". Each attribute is a hash reference with these properties: <blockquote> <table> <tr><td><b><tt>Name</tt></b></td> <td>The attribute name (including prefix).</td></tr> <tr><td><b><tt>Value</tt></b></td> <td>The normalized value of the attribute.</td></tr> <tr><td><b><tt>NamespaceURI</tt></b></td> <td>The namespace of this attribute.</td></tr> <tr><td><b><tt>Prefix</tt></b></td> <td>The namespace prefix used on this attribute.</td></tr> <tr><td><b><tt>LocalName</tt></b></td> <td>The local name of this attribute.</td></tr> </table> </blockquote> </dd> </dl> </p> <p><a name="endElement"/> <dl><dt><b><tt class='function'>end_element</tt></b>(<var>element</var>)</dt> <dd> Receive notification of the end of an element. <p>The SAX parser will invoke this method at the end of every element in the XML document; there will be a corresponding <tt class='function'>start_element()</tt> event for every <tt class='function'>end_element()</tt> event (even when the element is empty).</p> <var>element</var> is a hash reference with these properties: <blockquote> <table> <tr><td><b><tt>Name</tt></b></td> <td>The element type name (including prefix).</td></tr> </table> </blockquote> If namespace processing is turned on (which is the default), these properties are also available: <blockquote> <table> <tr><td><b><tt>NamespaceURI</tt></b></td> <td>The namespace of this element.</td></tr> <tr><td><b><tt>Prefix</tt></b></td> <td>The namespace prefix used on this element.</td></tr> <tr><td><b><tt>LocalName</tt></b></td> <td>The local name of this element.</td></tr> </table> </blockquote></dd> </dl></p> <p><a name="characters"/> <dl><dt><b><tt class='function'>characters</tt></b>(<var>characters</var>)</dt> <dd> Receive notification of character data. <p>The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks (however, all of the characters in any single event must come from the same external entity so that the Locator provides useful information).</p> <p><var>characters</var> is a hash reference with this property:</p> <blockquote> <table> <tr><td><b><tt>Data</tt></b></td> <td>The characters from the XML document.</td></tr> </table> </blockquote></dd> </dl></p> <p><a name="ignorableWhitespace"/> <dl><dt><b><tt class='function'>ignorable_whitespace</tt></b>(<var>characters</var>)</dt> <dd> Receive notification of ignorable whitespace in element content. <p>Validating Parsers must use this method to report each chunk of ignorable whitespace (see the W3C XML 1.0 recommendation, section 2.10): non-validating parsers may also use this method if they are capable of parsing and using content models.</p> <p>SAX parsers may return all contiguous whitespace in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity, so that the Locator provides useful information.</p> <p><var>characters</var> is a hash reference with this property:</p> <blockquote> <table> <tr><td><b><tt>Data</tt></b></td> <td>The whitespace characters from the XML document.</td></tr> </table> </blockquote></dd> </dl></p> <h2><a name="Exceptions">Exceptions</a></h2> <p> Conformant XML parsers are required to abort processing when well-formedness or validation errors occur. In Perl, SAX parsers use <tt>die()</tt> to signal these errors. To catch these errors and prevent them from killing your program, use <tt>eval{}</tt>: <pre> eval { $parser->parse($uri) }; if ($@) { # handle error } </pre> </p> <p> Exceptions can also be thrown when setting features or properties on the SAX parser (see advanced SAX below).</p> <p> Exception values (<tt>$@</tt>) in SAX are hash references blessed into the package that defines their type, and have the following properties: </p> <blockquote> <table> <tr><td><b><tt>Message</tt></b></td> <td>A detail message for this exception.</td></tr> <tr><td><b><tt>Exception</tt></b></td> <td>The embedded exception, or <tt>undef</tt> if there is none.</td></tr> </table> </blockquote> If the exception is raised due to parse errors, these properties are also available: <blockquote> <table> <tr><td><b><tt>ColumnNumber</tt></b></td> <td>The column number of the end of the text where the exception occurred.</td></tr> <tr><td><b><tt>LineNumber</tt></b></td> <td>The line number of the end of the text where the exception occurred.</td></tr> <tr><td><b><tt>PublicId</tt></b></td> <td>The public identifier of the entity where the exception occurred.</td></tr> <tr><td><b><tt>SystemId</tt></b></td> <td>The system identifier of the entity where the exception occurred.</td></tr> </table> </blockquote> <p></p><hr /> <h2>Advanced SAX</h2> <ul> <li><a href="sax-2.1-adv.html#Parsers">SAX Parsers</a></li> <li><a href="sax-2.1-adv.html#Features">Features</a></li> <li><a href="sax-2.1-adv.html#InputSources">Input Sources</a></li> <li><a href="sax-2.1-adv.html#Handlers">SAX Handlers</a></li> <li><a href="sax-2.1-adv.html#Filters">SAX Filters</a></li> <li><a href="sax-2.1-adv.html#Java">Java and DOM Compatibility</a></li> </ul> </body> </html> Index: index.html =================================================================== RCS file: /cvsroot/perl-xml/sax-perl-org/index.html,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- index.html 27 Jan 2002 14:02:40 -0000 1.1.1.1 +++ index.html 19 Feb 2004 09:50:04 -0000 1.2 @@ -25,6 +25,25 @@ </ul> </td> </tr> + + <tr> + <td><b>SAX 2.1 Working Drafts</b></td> + </tr> + <tr> + <td> + <ul> + <li><a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/sax-perl-org/sax-2.1.html?rev=HEAD&content-type=text/html">Perl + SAX 2.1 Binding</a></li> + <li><a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/sax-perl-org/sax-2.1-adv.html?rev=HEAD&content-type=text/html">Perl + SAX 2.1 Advanced</a></li> + <li><a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/sax-perl-org/sax-2.1-ref.html?rev=HEAD&content-type=text/html">Perl + SAX 2.1 Reference</a></li> + <li><a href="http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/sax-perl-org/changes-2.1?rev=HEAD&content-type=text/plain">Changes + and Issues</a></li> + </ul> + </td> + </tr> + <tr> <td><b>Misc.</b></td> </tr> |
From: Grant M. <gr...@us...> - 2004-02-19 09:16:02
|
Update of /cvsroot/perl-xml/perl-xml-faq In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8917 Modified Files: perl-xml-faq.xml Log Message: - updated URLs for Randy Kobes' PPM repositories Index: perl-xml-faq.xml =================================================================== RCS file: /cvsroot/perl-xml/perl-xml-faq/perl-xml-faq.xml,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- perl-xml-faq.xml 6 Jan 2004 08:57:05 -0000 1.15 +++ perl-xml-faq.xml 19 Feb 2004 09:05:44 -0000 1.16 @@ -17,6 +17,7 @@ <copyright> <year>2002</year> <year>2003</year> + <year>2004</year> <holder>Grant McLean</holder> </copyright> @@ -826,7 +827,7 @@ <programlisting><![CDATA[ C:\> ppm -ppm> set repository RK http://theoryx5.uwinnipeg.ca/cgi-bin/ppmserver?urn:/PPMServer +ppm> set repository RK http://theoryx5.uwinnipeg.ca/cgi-bin/ppmserver?urn:/PPMServer58 ppm> set save ppm> install XML::LibXML ]]></programlisting> @@ -834,6 +835,13 @@ <para>The 'set save' command means that PPM will remember this additional repository should you need to install another module later.</para> + <para>The location specified above assumes you're using a Perl 5.8 build. + If you're still running Perl 5.6, use this command instead:</para> + + <programlisting><![CDATA[ +ppm> set repository RK http://theoryx5.uwinnipeg.ca/cgi-bin/ppmserver?urn:/PPMServer + ]]></programlisting> + </answer> </qandaentry> |
From: Petr C. <pci...@us...> - 2004-02-04 17:04:23
|
Update of /cvsroot/perl-xml/libxml-perl/doc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9536/doc Modified Files: sax-2.0-adv.html sax-2.0.html Log Message: minor editorial changes Index: sax-2.0-adv.html =================================================================== RCS file: /cvsroot/perl-xml/libxml-perl/doc/sax-2.0-adv.html,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- sax-2.0-adv.html 9 Nov 2001 18:19:48 -0000 1.6 +++ sax-2.0-adv.html 4 Feb 2004 17:01:58 -0000 1.7 @@ -22,7 +22,7 @@ <p>SAX supports several classes of event handlers: content handlers, declaration handlers, DTD handlers, error handlers, entity resolvers, -and other extensions. For each class of events, a seperate handler +and other extensions. For each class of events, a separate handler can be used to handle those events. If a handler is not defined for a class of events, then the default handler, <tt>Handler</tt>, is used. Each of these handlers is described in the sections below. @@ -31,8 +31,8 @@ <p>SAX's basic interface defines methods for parsing system identifiers (URIs), open files, and strings. Behind the scenes, -though, SAX uses a <tt>Source</tt> hash that contains that -information, plus encoding, system and public identifiers if +though, SAX uses a <tt>Source</tt> hash reference that contains +that information, plus encoding, system and public identifiers if available. These are described below under the <tt>Source</tt> option.</p> @@ -44,8 +44,8 @@ <dl><dt><b><tt class='function'>parse</tt></b>(<var>options</var>)</dt> <dd> Parses the XML instance identified by the <tt>Source</tt> option. -<var>options</var> can be a list of option, value pairs or a hash. -<tt>parse()</tt> returns the result of calling the +<var>options</var> can be a list of options, value pairs or a hash +(reference). <tt>parse()</tt> returns the result of calling the <tt>end_document()</tt> handler.</dd></dl></p> <p> @@ -86,24 +86,21 @@ <p> <dl><dt><b><tt>Source</tt></b></dt> <dd> -A hash containing information about the XML instance to be parsed. +A hash reference containing information about the XML instance to be parsed. See <a href="#InputSources">Input Sources</a> below. Note that <tt>Source</tt> cannot be changed during the parse</dd></dl></p> <p> - <dl> - <dt><strong><tt>Features</tt></strong></dt> - <dd> - A hash containing Feature information, as described below. - Features can be set at runtime but not directly on the Features - hash (at least, not reliably. You can do it, but the results - might not be what you expect as it doesn't give the parser a - chance to look at what you've set so that it can't react properly - to errors, or Features that it doesn't support). You should use - the <code>set_feature()</code> method instead. - </dd> - </dl> -</p> +<dl><dt><strong><tt>Features</tt></strong></dt> +<dd> +A hash reference containing Feature information, as described +below. Features can be set at runtime but not directly on the +Features hash (at least, not reliably. You can do it, but the +results might not be what you expect as it doesn't give the +parser a chance to look at what you've set so that it can't +react properly to errors, or Features that it doesn't support). +You should use the <code>set_feature()</code> method instead. +</dd></dl></p> <h2><a name="Features">Features</a></h2> @@ -148,7 +145,7 @@ <p> Also, Features are things that are supposed to be <strong>turned on</strong>, and thus should normally be off by default, especially if - the parser doesn't support turning them off. Due to backwards + the parser doesn't support turning them off. Due to backward compatibility problems, the one exception to this rule is the "<tt>http://xml.org/sax/features/namespaces</tt>" Feature which is on by default and which a number of parsers may not be able to turn off. Thus, @@ -222,26 +219,24 @@ <p> - <dl> - <dt><strong><code class='function'>get_features</code></strong>()</dt> - <dd> - Look up all Features that this parser claims to support. - <p> - This method returns a hash of Features which the parser - claims to support. The value of the hash is currently - unspecified though it may be used later. This method is meant - to be inherited so that Features supported by the base parser - class (XML::SAX::Base) are declared to be supported by - subclasses. - </p> - <p> - Calling this method is probably only moderately useful to end - users. It is mostly meant for use by XML::SAX, so that it can - query parsers for Feature support and return an appropriate - parser depending on the Features that are required. - </p> - </dd> - </dl> +<dl> +<dt><strong><code class='function'>get_features</code></strong>()</dt> +<dd> +Look up all Features that this parser claims to support. +<p> +This method returns a reference to hash of Features which the parser +claims to support. The value of the hash is currently +unspecified though it may be used later. This method is meant +to be inherited so that Features supported by the base parser +class (XML::SAX::Base) are declared to be supported by subclasses. +</p> +<p> +Calling this method is probably only moderately useful to end +users. It is mostly meant for use by XML::SAX, so that it can +query parsers for Feature support and return an appropriate +parser depending on the Features that are required. +</p> +</dd></dl> </p> @@ -249,7 +244,7 @@ <h2><a name="InputSources">Input Sources</a></h2> <p>Input sources may be provided to parser objects or are returned by -entity resolvers. An input source is a hash with these +entity resolvers. An input source is a hash reference with these properties:</p> <dl> @@ -291,8 +286,8 @@ ignore any byte stream and will not attempt to open a URI connection to the system identifier.</p> -<p>Note: A CharacterStream is a filehandle that does not need any encoding -translation done on it. This is implemented as a regular filehandle +<p>Note: A CharacterStream is a file-handle that does not need any encoding +translation done on it. This is implemented as a regular file-handle and only works under Perl 5.7.2 or higher using PerlIO. To get a single character, or number of characters from it, use the perl core read() function. To get a single byte from it (or number of bytes), you can @@ -357,7 +352,7 @@ the invocation of the events in this interface. The application should not attempt to use it at any other time.</p> -<p>The locator is a hash with these properties:</p> +<p>The locator is a hash reference with these properties:</p> <blockquote> <table> @@ -396,14 +391,14 @@ <p>Note that <tt>start</tt>/<tt>end_prefix_mapping()</tt> events are not guaranteed to be properly nested relative to each-other: all -<tt>start_prefix_apping()</tt> events will occur before the +<tt>start_prefix_mapping()</tt> events will occur before the corresponding <tt>start_element()</tt> event, and all <tt>end_prefix_mapping</tt> events will occur after the corresponding <tt>end_element()</tt> event, but their order is not guaranteed. </p> -<p><var>mapping</var> is a hash with these properties:</p> +<p><var>mapping</var> is a hash reference with these properties:</p> <blockquote> <table> @@ -425,7 +420,7 @@ the order of <tt>end_prefix_mapping</tt> events is not otherwise guaranteed.</p> -<p><var>mapping</var> is a hash with this property:</p> +<p><var>mapping</var> is a hash reference with this property:</p> <blockquote> <table> @@ -448,7 +443,7 @@ section 2.8) or a text declaration (XML 1.0, section 4.3.1) using this method.</p> -<p><var>pi</var> is a hash with these properties:</p> +<p><var>pi</var> is a hash reference with these properties:</p> <blockquote> <table> @@ -475,7 +470,7 @@ "<tt>http://xml.org/sax/features/external-parameter-entities</tt>" Features.</p> -<p><var>entity</var> is a hash with these properties:</p> +<p><var>entity</var> is a hash reference with these properties:</p> <blockquote> <table> @@ -499,7 +494,7 @@ handler, all of the events will occur between the <tt>start_dtd</tt> and the <tt>end_dtd</tt> events.</p> -<p>To set a seperate DeclHandler for an XML reader, set the +<p>To set a separate DeclHandler for an XML reader, set the "<tt>http://xml.org/sax/handlers/DeclHandler</tt>" Feature with the object to received declaration events. If the reader does not support declaration events, it will throw a <tt>XML::SAX::Exception::NotRecognized</tt> @@ -518,7 +513,7 @@ indicator. The model will be normalized so that all whitespace is removed, and will include the enclosing parentheses.</p> -<p><var>element</var> is a hash with these properties:</p> +<p><var>element</var> is a hash reference with these properties:</p> <blockquote> <table> @@ -542,7 +537,7 @@ "<tt>ENTITIES</tt>", or "<tt>NOTATION</tt>", or a parenthesized token group with the separator "<tt>|</tt>" and all whitespace removed.</p> -<p><var>attribute</var> is a hash with these properties:</p> +<p><var>attribute</var> is a hash reference with these properties:</p> <blockquote> <table> @@ -571,7 +566,7 @@ <p>Only the effective (first) declaration for each entity will be reported.</p> -<p><var>entity</var> is a hash with these properties:</p> +<p><var>entity</var> is a hash reference with these properties:</p> <blockquote> <table> @@ -592,7 +587,7 @@ <p>Only the effective (first) declaration for each entity will be reported.</p> -<p><var>entity</var> is a hash with these properties:</p> +<p><var>entity</var> is a hash reference with these properties:</p> <blockquote> <table> @@ -639,7 +634,7 @@ <p>If a system identifier is present, and it is a URL, the SAX parser must resolve it fully before passing it to the application.</p> -<p><var>notation</var> is a hash with these properties:</p> +<p><var>notation</var> is a hash reference with these properties:</p> <blockquote> <table> @@ -667,7 +662,7 @@ <p>If the system identifier is a URL, the parser must resolve it fully before passing it to the application.</p> -<p><var>entity</var> is a hash with these properties:</p> +<p><var>entity</var> is a hash reference with these properties:</p> <blockquote> <table> @@ -722,7 +717,7 @@ <p>If the system identifier is a URL, the SAX parser must resolve it fully before reporting it to the application.</p> -<p><var>entity</var> is a hash with these properties:</p> +<p><var>entity</var> is a hash reference with these properties:</p> <blockquote> <table> @@ -749,9 +744,8 @@ renders any continuation of parsing impossible. </p> -<p>All error handlers receive a hash, <var>exception</var>, with the -properties defined in <a -href="sax-2.0.html#Exceptions">Exceptions</a>.</p> +<p>All error handlers receive a hash reference, <var>exception</var>, with +the properties defined in <a href="sax-2.0.html#Exceptions">Exceptions</a>.</p> <p> <dl><dt><b><tt class='function'>warning</tt></b>(<var>exception</var>)</dt> @@ -760,7 +754,7 @@ <p>SAX parsers will use this method to report conditions that are not errors or fatal errors as defined by the XML 1.0 recommendation. The -default behaviour is to take no action.</p> +default behavior is to take no action.</p> The SAX parser must continue to provide normal parsing events after invoking this method: it should still be possible for the application @@ -774,7 +768,7 @@ <p>This corresponds to the definition of "error" in section 1.2 of the W3C XML 1.0 Recommendation. For example, a validating parser would use this callback to report the violation of a validity constraint. The -default behaviour is to take no action.</p> +default behavior is to take no action.</p> The SAX parser must continue to provide normal parsing events after invoking this method: it should still be possible for the application @@ -828,7 +822,7 @@ within the <tt>start</tt>/<tt>end_document()</tt> events from Content Handler and before the first <tt>start_element()</tt> event.</p> -<p><var>dtd</var> is a hash with these properties:</p> +<p><var>dtd</var> is a hash reference with these properties:</p> <blockquote> <table> @@ -868,7 +862,7 @@ <tt>skipped_entity()</tt> event, which is part of the ContentHandler interface.</p> -<p><var>entity</var> is a hash with these properties:</p> +<p><var>entity</var> is a hash reference with these properties:</p> <blockquote> <table> @@ -884,7 +878,7 @@ <dd> Report the end of an entity. -<p><var>entity</var> is a hash with these properties:</p> +<p><var>entity</var> is a hash reference with these properties:</p> <blockquote> <table> @@ -922,7 +916,7 @@ document element, including comments in the external DTD subset (if read).</p> -<p><var>comment</var> is a hash with these properties:</p> +<p><var>comment</var> is a hash reference with these properties:</p> <blockquote> <table> @@ -971,15 +965,15 @@ check the handlers for what methods they support. Note however that using XML::SAX::Base as your base class for Drivers and Filters will make your code a lot simpler, less error prone, and probably much more - correct with regard to this spec. Only reimplement that functionality + correct with regard to this spec. Only re-implement that functionality if you really need to. </li> -<li>The Attribute, InputSource, and SAXException (XML::SAX::Exception) -classes are only described as hashes (see below).</li> +<li>The Attributes, InputSource, and SAXException (XML::SAX::Exception) +classes are only described as hash references (see below).</li> -<li>Handlers are passed a hash (Node) containing properties as an -argument instead of positional arguments.</li> +<li>Handlers are passed a hash reference (Node) containing properties +as an argument instead of positional arguments.</li> <li><tt>parse()</tt> methods return the value returned by calling the <tt>end_document()</tt> handler.</li> Index: sax-2.0.html =================================================================== RCS file: /cvsroot/perl-xml/libxml-perl/doc/sax-2.0.html,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- sax-2.0.html 21 Jan 2002 19:21:43 -0000 1.6 +++ sax-2.0.html 4 Feb 2004 17:01:58 -0000 1.7 @@ -84,12 +84,17 @@ get the events one is interested in. </p> +<p>If you generate SAX events, data are required to be passed to +handler methods with all properties defined in this document +unless otherwise specified. +</p> + <p> <dl><dt><b><tt class='function'>parse</tt></b>(<var>uri</var> [, <var>options</var>])</dt> <dd> Parses the XML instance identified by <var>uri</var> (a system -identifier). <var>options</var> can be a list of option, value pairs -or a hash. Options include <tt>Handler</tt>, features and properties, +identifier). <var>options</var> can be a list of options, value pairs +or a hash (reference). Options include <tt>Handler</tt>, features and properties, and advanced SAX parser options. <tt>parse()</tt> returns the result of calling the <tt>end_document()</tt> handler. The options supported by <tt>parse()</tt> may vary slightly if what is being "parsed" isn't @@ -166,7 +171,7 @@ element is empty). All of the element's content will be reported, in order, before the corresponding <tt>end_element()</tt> event.</p> -<var>element</var> is a hash with these properties: +<var>element</var> is a hash reference with these properties: <blockquote> <table> @@ -191,10 +196,10 @@ </table> </blockquote> -<tt>Attributes</tt> is a hash keyed by JClark namespace notation. That -is, the keys are of the form "{NamespaceURI}LocalName". If the attribute -has no NamespaceURI, then it is simply "{}LocalName". Each attribute is -a hash with these properties: +<tt>Attributes</tt> is a reference to hash keyed by JClark namespace +notation. That is, the keys are of the form "{NamespaceURI}LocalName". +If the attribute has no NamespaceURI, then it is simply "{}LocalName". +Each attribute is a hash reference with these properties: <blockquote> <table> @@ -225,7 +230,7 @@ class='function'>end_element()</tt> event (even when the element is empty).</p> -<var>element</var> is a hash with these properties: +<var>element</var> is a hash reference with these properties: <blockquote> <table> @@ -260,7 +265,7 @@ of the characters in any single event must come from the same external entity so that the Locator provides useful information).</p> -<p><var>characters</var> is a hash with this property:</p> +<p><var>characters</var> is a hash reference with this property:</p> <blockquote> <table> @@ -285,7 +290,7 @@ characters in any single event must come from the same external entity, so that the Locator provides useful information.</p> -<p><var>characters</var> is a hash with this property:</p> +<p><var>characters</var> is a hash reference with this property:</p> <blockquote> <table> @@ -316,8 +321,8 @@ on the SAX parser (see advanced SAX below).</p> <p> - Exception values (<tt>$@</tt>) in SAX are hashes blessed into the - package that defines their type, and have the following properties: + Exception values (<tt>$@</tt>) in SAX are hash references blessed + into the package that defines their type, and have the following properties: </p> <blockquote> |
From: Grant M. <gr...@us...> - 2004-01-06 08:57:11
|
Update of /cvsroot/perl-xml/perl-xml-faq In directory sc8-pr-cvs1:/tmp/cvs-serv6306 Modified Files: perl-xml-faq.xml Log Message: - added question re ParserDetails.ini error Index: perl-xml-faq.xml =================================================================== RCS file: /cvsroot/perl-xml/perl-xml-faq/perl-xml-faq.xml,v retrieving revision 1.14 retrieving revision 1.15 diff -u -d -r1.14 -r1.15 --- perl-xml-faq.xml 14 Dec 2003 09:24:20 -0000 1.14 +++ perl-xml-faq.xml 6 Jan 2004 08:57:05 -0000 1.15 @@ -895,6 +895,65 @@ </answer> </qandaentry> + <qandaentry id="parserdetails.ini"> + <question> + <para>"could not find ParserDetails.ini"</para> + </question> + <answer> + + <para>A number of people have reported encountering the error "could not + find ParserDetails.ini in ..." when installing or attempting to use + <classname>XML::SAX</classname>. <filename>ParserDetails.ini</filename> + is used by <classname>XML::SAX::ParserFactory</classname> to determine + which SAX parser modules are installed. It should be created by the + <classname>XML::SAX</classname> installation script and should be updated + automatically by the install script for each SAX parser module.</para> + + <itemizedlist mark="bullet"> + + <listitem><para>If you are installing <classname>XML::SAX</classname> + manually you must run <filename>Makefile.PL</filename>. Unpacking the + tarball and copying the files into your Perl lib directory will not + work.</para></listitem> + + <listitem><para>During the initial installation, if you are asked whether + <filename>ParserDetails.ini</filename> should be updated, always say yes. + If you say no, the file will not be created.</para></listitem> + + <listitem><para>If you are using ActivePerl, the following command should + resolve the problem: </para> + + <programlisting><![CDATA[ +ppm install http://theoryx5.uwinnipeg.ca/ppms/XML-SAX.ppd + ]]></programlisting> + + </listitem> + + </itemizedlist> + + <para>Once you have successfully installed + <classname>XML::SAX</classname>, you should consider installing a module + such as <classname>XML::SAX::Expat</classname> or + <classname>XML::LibXML</classname> to replace the slower pure-Perl parser + bundled with SAX.</para> + + <para>If you are packaging <classname>XML::SAX</classname> in an + alternative distribution format (such as RPM), your post-install script + should check if <filename>ParserDetails.ini</filename> exists and if it + doesn't, run this command:</para> + + <programlisting><![CDATA[ +perl -MXML::SAX -e "XML::SAX->add_parser(q(XML::SAX::PurePerl))->save_parsers()" + ]]></programlisting> + + <para>Don't unconditionally run this command, or users who re-install + <classname>XML::SAX</classname> may find that any fast SAX parser they + have installed will be replaced as the default by the pure-Perl + parser.</para> + + </answer> + </qandaentry> + </qandadiv> <qandadiv id="xslt"><title>XSLT Support</title> |
From: Grant M. <gr...@us...> - 2003-12-14 09:24:31
|
Update of /cvsroot/perl-xml/perl-xml-faq In directory sc8-pr-cvs1:/tmp/cvs-serv23438 Modified Files: perl-xml-faq.xml Log Message: - more updates to XML::LibXML section Index: perl-xml-faq.xml =================================================================== RCS file: /cvsroot/perl-xml/perl-xml-faq/perl-xml-faq.xml,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- perl-xml-faq.xml 10 Nov 2003 07:58:44 -0000 1.13 +++ perl-xml-faq.xml 14 Dec 2003 09:24:20 -0000 1.14 @@ -485,6 +485,24 @@ DOM to be constructed from SAX events. <classname>XML::LibXML::SAX</classname> is a SAX parser based on the libxml2 library.</para> + + <para><classname>XML::LibXML</classname> can be used to parse HTML (4.0 + strict) and SGML files into DOM structures - which is especially useful + when converting other formats to XML.</para> + + <para>The libxml2 library is not part of the + <classname>XML::LibXML</classname> distribution. The source is available + for download from <ulink url="http://xmlsoft.org">xmlsoft.org</ulink>; + it is a standard package in most Linux distributions; it can be compiled + on numerous other platforms; and it is bundled with PPM packages of + <classname>XML::LibXML</classname> for Windows.</para> + + <para>For early access to upcoming features such as W3C Schema and RelaxNG + validation, you can access the CVS version of <classname>XML::LibXML</classname> at:</para> + + <programlisting><![CDATA[ +cvs -d :pserver:ano...@ax...:/home/cvs co XML-LibXML + ]]></programlisting> </answer> </qandaentry> |
From: Ilya M. <m_...@us...> - 2003-11-10 10:28:15
|
Update of /cvsroot/perl-xml/XML-LibXML-XPathContext In directory sc8-pr-cvs1:/tmp/cvs-serv16370 Modified Files: META.yml Log Message: Updated Index: META.yml =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/META.yml,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- META.yml 22 Sep 2003 08:09:34 -0000 1.1 +++ META.yml 10 Nov 2003 10:28:10 -0000 1.2 @@ -1,7 +1,7 @@ # http://module-build.sourceforge.net/META-spec.html #XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX# name: XML-LibXML-XPathContext -version: 0.05 +version: 0.06 version_from: XPathContext.pm installdirs: site requires: |
From: Ilya M. <m_...@us...> - 2003-11-10 10:10:28
|
Update of /cvsroot/perl-xml/XML-LibXML-XPathContext In directory sc8-pr-cvs1:/tmp/cvs-serv13775 Modified Files: Changes Log Message: Updated Index: Changes =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/Changes,v retrieving revision 1.13 retrieving revision 1.14 diff -u -d -r1.13 -r1.14 --- Changes 3 Nov 2003 18:09:38 -0000 1.13 +++ Changes 10 Nov 2003 10:10:25 -0000 1.14 @@ -2,7 +2,7 @@ Revision history for Perl module XML::LibXML::XPathContext. -0.06 Mon Nov 3 2003 +0.06 Mon Nov 10 2003 * simplified variable lookup code to use a C structure instead of a perl AV* |
From: Ilya M. <m_...@us...> - 2003-11-10 10:09:33
|
Update of /cvsroot/perl-xml/XML-LibXML-XPathContext In directory sc8-pr-cvs1:/tmp/cvs-serv13544 Modified Files: XPathContext.xs XPathContext.pm Log Message: Rename _leave() to _free_node_pool() for clarity Index: XPathContext.xs =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/XPathContext.xs,v retrieving revision 1.40 retrieving revision 1.41 diff -u -d -r1.40 -r1.41 --- XPathContext.xs 10 Nov 2003 10:07:36 -0000 1.40 +++ XPathContext.xs 10 Nov 2003 10:09:12 -0000 1.41 @@ -862,7 +862,7 @@ } void -_leave( pxpath_context ) +_free_node_pool( pxpath_context ) SV * pxpath_context PREINIT: xmlXPathContextPtr ctxt = NULL; Index: XPathContext.pm =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/XPathContext.pm,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- XPathContext.pm 3 Nov 2003 18:09:38 -0000 1.31 +++ XPathContext.pm 10 Nov 2003 10:09:12 -0000 1.32 @@ -55,12 +55,11 @@ $prev_node = $self->getContextNode(); $self->setContextNode($node); } -# $self->_enter; # lock my @ret; eval { @ret = $self->$method($xpath); }; - $self->_leave; # unlock and free node-pool + $self->_free_node_pool; $self->setContextNode($prev_node) if ref($node); if ($@) { die "ERROR: $@"; } |
From: Ilya M. <m_...@us...> - 2003-11-10 10:07:59
|
Update of /cvsroot/perl-xml/XML-LibXML-XPathContext In directory sc8-pr-cvs1:/tmp/cvs-serv13337 Modified Files: XPathContext.xs Log Message: Remove _enter() and unused field lock in struct _XPathContextData Index: XPathContext.xs =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/XPathContext.xs,v retrieving revision 1.39 retrieving revision 1.40 diff -u -d -r1.39 -r1.40 --- XPathContext.xs 7 Nov 2003 15:26:16 -0000 1.39 +++ XPathContext.xs 10 Nov 2003 10:07:36 -0000 1.40 @@ -39,7 +39,6 @@ struct _XPathContextData { SV* node; - int lock; /* currently unnecessary */ HV* pool; SV* varLookup; SV* varData; @@ -525,7 +524,6 @@ XPathContextDATA(ctxt)->node = &PL_sv_undef; } - XPathContextDATA(ctxt)->lock = 0; XPathContextDATA(ctxt)->pool = NULL; XPathContextDATA(ctxt)->varLookup = NULL; XPathContextDATA(ctxt)->varData = NULL; @@ -864,22 +862,6 @@ } void -_enter( pxpath_context ) - SV * pxpath_context - PREINIT: - xmlXPathContextPtr ctxt = NULL; - INIT: - ctxt = (xmlXPathContextPtr)SvIV(SvRV(pxpath_context)); - if ( ctxt == NULL ) { - croak("XPathContext: missing xpath context"); - } - PPCODE: - if ( XPathContextDATA(ctxt)->lock != 0 ) { - croak("XPathContext: context is locked"); - } - XPathContextDATA(ctxt)->lock=1; - -void _leave( pxpath_context ) SV * pxpath_context PREINIT: @@ -890,7 +872,6 @@ croak("XPathContext: missing xpath context"); } PPCODE: - XPathContextDATA(ctxt)->lock=0; if (XPathContextDATA(ctxt)->pool != NULL) { SvREFCNT_dec((SV *)XPathContextDATA(ctxt)->pool); XPathContextDATA(ctxt)->pool = NULL; |
From: Grant M. <gr...@us...> - 2003-11-10 09:38:31
|
Update of /cvsroot/perl-xml/file-find-rule-xpath In directory sc8-pr-cvs1:/tmp/cvs-serv9114 Modified Files: MANIFEST Log Message: - added t/9_pod.t to test POD Index: MANIFEST =================================================================== RCS file: /cvsroot/perl-xml/file-find-rule-xpath/MANIFEST,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- MANIFEST 18 Dec 2002 09:21:18 -0000 1.1.1.1 +++ MANIFEST 10 Nov 2003 09:38:27 -0000 1.2 @@ -6,3 +6,5 @@ t/0_config.t t/1_basics.t t/2_cleanup.t +t/9_pod.t +META.yml Module meta-data (added by MakeMaker) |
From: Grant M. <gr...@us...> - 2003-11-10 09:38:31
|
Update of /cvsroot/perl-xml/file-find-rule-xpath/t In directory sc8-pr-cvs1:/tmp/cvs-serv9114/t Added Files: 9_pod.t Log Message: - added t/9_pod.t to test POD --- NEW FILE: 9_pod.t --- # $Id: 9_pod.t,v 1.1 2003/11/10 09:38:27 grantm Exp $ use Test::More; eval "use Test::Pod 1.00"; plan skip_all => "Test::Pod 1.00 required for testing POD" if $@; all_pod_files_ok(); |
From: Grant M. <gr...@us...> - 2003-11-10 08:31:18
|
Update of /cvsroot/perl-xml/file-find-rule-xpath In directory sc8-pr-cvs1:/tmp/cvs-serv31758 Modified Files: Changes README Log Message: - for 0.03 release Index: Changes =================================================================== RCS file: /cvsroot/perl-xml/file-find-rule-xpath/Changes,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- Changes 18 Dec 2002 09:21:18 -0000 1.1.1.1 +++ Changes 10 Nov 2003 08:31:15 -0000 1.2 @@ -1,5 +1,9 @@ Revision history for Perl extension File::Find::Rule::XPath. +0.03 10-Nov-2003: + - removed calls to File::Spec->cwd which has been renamed in the + latest release (reported by Jim Cromie) + 0.02 16-Dec-2002: first release to CPAN - added support for searching from relative roots Index: README =================================================================== RCS file: /cvsroot/perl-xml/file-find-rule-xpath/README,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- README 18 Dec 2002 09:21:18 -0000 1.1.1.1 +++ README 10 Nov 2003 08:31:15 -0000 1.2 @@ -22,12 +22,12 @@ RELEASE HISTORY - Version 0.02 is the first release to CPAN + Version 0.03 fixes an incompatibility with recent versions of File::Spec COPYRIGHT - Copyright 2002 Grant McLean <gr...@cp...> + Copyright 2003 Grant McLean <gr...@cp...> This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. |
From: Grant M. <gr...@us...> - 2003-11-10 08:30:36
|
Update of /cvsroot/perl-xml/file-find-rule-xpath/lib/File/Find/Rule In directory sc8-pr-cvs1:/tmp/cvs-serv31641/lib/File/Find/Rule Modified Files: XPath.pm Log Message: - fixed an incompatibility with recent versions of File::Spec (reported by Jim Cromie) Index: XPath.pm =================================================================== RCS file: /cvsroot/perl-xml/file-find-rule-xpath/lib/File/Find/Rule/XPath.pm,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- XPath.pm 18 Dec 2002 09:27:58 -0000 1.2 +++ XPath.pm 10 Nov 2003 08:30:33 -0000 1.3 @@ -6,10 +6,11 @@ use Carp; use File::Find::Rule; use File::Spec; +use Cwd (); use vars qw($VERSION @ISA @EXPORT); -$VERSION = '0.02'; +$VERSION = '0.03'; @ISA = qw(File::Find::Rule); @EXPORT = @File::Find::Rule::EXPORT; @@ -29,7 +30,7 @@ croak 'Can\'t locate XML::LibXML or XML::XPath in @INC'; } - my $cwd = File::Spec->cwd(); + my $cwd = Cwd::cwd(); if($use_libxml) { |
From: Grant M. <gr...@us...> - 2003-11-10 07:58:55
|
Update of /cvsroot/perl-xml/perl-xml-faq In directory sc8-pr-cvs1:/tmp/cvs-serv26448 Modified Files: perl-xml-faq.xml Log Message: - fixed typo reported by Fergus McMenemie Index: perl-xml-faq.xml =================================================================== RCS file: /cvsroot/perl-xml/perl-xml-faq/perl-xml-faq.xml,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- perl-xml-faq.xml 15 Oct 2003 18:06:41 -0000 1.12 +++ perl-xml-faq.xml 10 Nov 2003 07:58:44 -0000 1.13 @@ -460,7 +460,7 @@ you will need a compiler.</para> <para>Most of the documentation you need for the - <classname>XML::Parser</classname> API can be access using + <classname>XML::Parser</classname> API can be accessed using <command>perldoc XML::Parser</command>, however some of the low-level functionality is documented in <command>perldoc XML::Parser::Expat</command>.</para> |
From: Petr P. <pa...@us...> - 2003-11-07 15:26:20
|
Update of /cvsroot/perl-xml/XML-LibXML-XPathContext In directory sc8-pr-cvs1:/tmp/cvs-serv15817 Modified Files: XPathContext.xs Log Message: using #define PERL_NO_GET_CONTEXT and dTHX in static functions, to make perl API calls faster Index: XPathContext.xs =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/XPathContext.xs,v retrieving revision 1.38 retrieving revision 1.39 diff -u -d -r1.38 -r1.39 --- XPathContext.xs 5 Nov 2003 13:41:52 -0000 1.38 +++ XPathContext.xs 7 Nov 2003 15:26:16 -0000 1.39 @@ -3,6 +3,7 @@ #ifdef __cplusplus extern "C" { #endif +#define PERL_NO_GET_CONTEXT /* we want efficiency */ /* perl stuff */ #include "EXTERN.h" @@ -59,6 +60,7 @@ { va_list args; SV * sv; + dTHX; /* xmlParserCtxtPtr context = (xmlParserCtxtPtr) ctxt; */ sv = NEWSV(0,512); @@ -91,6 +93,7 @@ SV * pnode2; STRLEN len; char * strkey; + dTHX; if (XPathContextDATA(ctxt)->pool == NULL) { if (pnode == NULL) { @@ -121,6 +124,7 @@ static xmlXPathObjectPtr xpc_LibXML_perldata_to_LibXMLdata(xmlXPathParserContextPtr ctxt, SV* perl_result) { + dTHX; if (!SvOK(perl_result)) { return (xmlXPathObjectPtr)xmlXPathNewCString(""); } @@ -216,6 +220,7 @@ static void xpc_LibXML_restore_context(xmlXPathContextPtr ctxt, xmlXPathContextPtr copy) { + dTHX; /* cleanup */ if (XPathContextDATA(ctxt)) { /* cleanup newly created pool */ @@ -258,6 +263,7 @@ xmlXPathContextPtr copy; XPathContextDataPtr data; I32 count; + dTHX; dSP; ctxt = (xmlXPathContextPtr) varLookupData; @@ -320,6 +326,7 @@ char *strkey; const char *function, *uri; SV **perl_function; + dTHX; dSP; SV * data; xmlXPathContextPtr copy; |
From: Petr P. <pa...@us...> - 2003-11-07 15:19:31
|
Update of /cvsroot/perl-xml/XML-LibXML-XPathContext In directory sc8-pr-cvs1:/tmp/cvs-serv14553 Modified Files: perl-libxml-mm.c MANIFEST Removed Files: perl-libxml-sax.h perl-libxml-sax.c Log Message: removing perl-libxml-sax.c/perl-libxml-sax.h dependency Index: perl-libxml-mm.c =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/perl-libxml-mm.c,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- perl-libxml-mm.c 3 Nov 2003 18:09:38 -0000 1.3 +++ perl-libxml-mm.c 7 Nov 2003 15:19:23 -0000 1.4 @@ -29,8 +29,6 @@ #endif -#include "perl-libxml-sax.h" - #ifdef __cplusplus } #endif @@ -586,103 +584,6 @@ } } } - -xpc_ProxyNodePtr -xpc_PmmNewContext(xmlParserCtxtPtr node) -{ - xpc_ProxyNodePtr proxy = NULL; - - proxy = (xpc_ProxyNodePtr)xmlMalloc(sizeof(xpc_ProxyNode)); - if (proxy != NULL) { - proxy->node = (xmlNodePtr)node; - proxy->owner = NULL; - proxy->count = 1; - } - else { - warn( "empty context" ); - } - return proxy; -} - -int -xpc_PmmContextREFCNT_dec( xpc_ProxyNodePtr node ) -{ - xmlParserCtxtPtr libnode = NULL; - int retval = 0; - if ( node != NULL ) { - retval = xpc_PmmREFCNT(node)--; - if ( xpc_PmmREFCNT(node) <= 0 ) { - xs_warn( "NODE DELETATION\n" ); - libnode = (xmlParserCtxtPtr)xpc_PmmNODE( node ); - if ( libnode != NULL ) { - if (libnode->_private != NULL ) { - if ( libnode->_private != (void*)node ) { - xpc_PmmSAXCloseContext( libnode ); - } - else { - xmlFree( libnode->_private ); - } - libnode->_private = NULL; - } - xpc_PmmNODE( node ) = NULL; - xmlFreeParserCtxt(libnode); - } - } - xmlFree( node ); - } - return retval; -} - -SV* -xpc_PmmContextSv( xmlParserCtxtPtr ctxt ) -{ - xpc_ProxyNodePtr dfProxy= NULL; - SV * retval = &PL_sv_undef; - const char * CLASS = "XML::LibXML::ParserContext"; - void * saxvector = NULL; - - if ( ctxt != NULL ) { - dfProxy = xpc_PmmNewContext(ctxt); - - retval = NEWSV(0,0); - sv_setref_pv( retval, CLASS, (void*)dfProxy ); - xpc_PmmREFCNT_inc(dfProxy); - } - else { - xs_warn( "no node found!" ); - } - - return retval; -} - -xmlParserCtxtPtr -xpc_PmmSvContext( SV * scalar ) -{ - xmlParserCtxtPtr retval = NULL; - - if ( scalar != NULL - && scalar != &PL_sv_undef - && sv_isa( scalar, "XML::LibXML::ParserContext" ) - && SvPROXYNODE(scalar) != NULL ) { - retval = (xmlParserCtxtPtr)xpc_PmmNODE( SvPROXYNODE(scalar) ); - } - else { - if ( scalar == NULL - && scalar == &PL_sv_undef ) { - xs_warn( "no scalar!" ); - } - else if ( ! sv_isa( scalar, "XML::LibXML::ParserContext" ) ) { - xs_warn( "bad object" ); - } - else if (SvPROXYNODE(scalar) == NULL) { - xs_warn( "empty object" ); - } - else { - xs_warn( "nothing was wrong!"); - } - } - return retval; -} xmlChar* xpc_PmmFastEncodeString( int charset, Index: MANIFEST =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/MANIFEST,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- MANIFEST 22 Sep 2003 08:09:34 -0000 1.5 +++ MANIFEST 7 Nov 2003 15:19:23 -0000 1.6 @@ -9,8 +9,6 @@ dom.h perl-libxml-mm.c perl-libxml-mm.h -perl-libxml-sax.c -perl-libxml-sax.h ppport.h t/00-xpathcontext.t t/01-variables.t --- perl-libxml-sax.h DELETED --- --- perl-libxml-sax.c DELETED --- |
From: Petr P. <pa...@us...> - 2003-11-05 13:42:11
|
Update of /cvsroot/perl-xml/XML-LibXML-XPathContext In directory sc8-pr-cvs1:/tmp/cvs-serv12458 Modified Files: XPathContext.xs Log Message: fix: position may be -1 Index: XPathContext.xs =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/XPathContext.xs,v retrieving revision 1.37 retrieving revision 1.38 diff -u -d -r1.37 -r1.38 --- XPathContext.xs 3 Nov 2003 18:09:38 -0000 1.37 +++ XPathContext.xs 5 Nov 2003 13:41:52 -0000 1.38 @@ -643,7 +643,7 @@ xmlXPathContextPtr ctxt = (xmlXPathContextPtr)SvIV(SvRV(self)); if ( ctxt == NULL ) croak("XPathContext: missing xpath context"); - if ( position < 0 || position > ctxt->contextSize ) + if ( position < -1 || position > ctxt->contextSize ) croak("XPathContext: invalid position"); PPCODE: ctxt->proximityPosition = position; |
From: Petr P. <pa...@us...> - 2003-11-03 18:09:41
|
Update of /cvsroot/perl-xml/XML-LibXML-XPathContext In directory sc8-pr-cvs1:/tmp/cvs-serv27421 Modified Files: perl-libxml-mm.c XPathContext.xs XPathContext.pm README Changes Log Message: * simplified variable lookup code to use a C structure instead of a perl AV* * made XPathContext reentrant (by saving the state before a callback and restoring it afterwards). * added get/setContextSize, get/setContextPosition * added getVarLookupFunc * added some tests and documentation for the new features * applied last LibXML patch for perl-libxml-mm.c Index: perl-libxml-mm.c =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/perl-libxml-mm.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- perl-libxml-mm.c 20 May 2003 15:25:50 -0000 1.2 +++ perl-libxml-mm.c 3 Nov 2003 18:09:38 -0000 1.3 @@ -5,7 +5,7 @@ * Basic concept: * perl varies in the implementation of UTF8 handling. this header (together * with the c source) implements a few functions, that can be used from within - * the core module inorder to avoid cascades of c pragmas + * the core module in order to avoid cascades of c pragmas */ #ifdef __cplusplus @@ -28,6 +28,7 @@ #include <libgdome/gdome-libxml-util.h> #endif + #include "perl-libxml-sax.h" #ifdef __cplusplus @@ -132,7 +133,7 @@ #define xpc_PmmENCODING(node) node->encoding #define xpc_PmmNodeEncoding(node) ((xpc_ProxyNodePtr)(node->_private))->encoding - +#define xpc_PmmDocEncoding(node) (node->charset) /* creates a new proxy node from a given node. this function is aware * about the fact that a node may already has a proxy structure. */ @@ -142,7 +143,7 @@ xpc_ProxyNodePtr proxy = NULL; if ( node == NULL ) { - warn( "no node found\n" ); + xs_warn( "no node found\n" ); return NULL; } @@ -173,9 +174,12 @@ frag = xmlNewDocFragment( doc ); retval = xpc_PmmNewNode(frag); - if ( doc ) { + if ( doc != NULL ) { xs_warn("inc document\n"); - xpc_PmmREFCNT_inc(((xpc_ProxyNodePtr)doc->_private)); + /* under rare circumstances _private is not set correctly? */ + if ( doc->_private != NULL ) { + xpc_PmmREFCNT_inc(((xpc_ProxyNodePtr)doc->_private)); + } retval->owner = (xmlNodePtr)doc; } @@ -203,7 +207,7 @@ } break; case XML_DTD_NODE: - if ( node->doc ) { + if ( node->doc != NULL ) { if ( node->doc->extSubset != (xmlDtdPtr)node && node->doc->intSubset != (xmlDtdPtr)node ) { xs_warn( "PFN: XML_DTD_NODE\n"); @@ -233,7 +237,7 @@ xpc_ProxyNodePtr owner = NULL; int retval = 0; - if ( node ) { + if ( node != NULL ) { retval = xpc_PmmREFCNT(node)--; if ( xpc_PmmREFCNT(node) <= 0 ) { xs_warn( "NODE DELETATION\n" ); @@ -305,7 +309,7 @@ xs_warn(" return new perl node\n"); xs_warn( CLASS ); - if ( node->_private ) { + if ( node->_private != NULL ) { dfProxy = xpc_PmmNewNode(node); } else { @@ -467,7 +471,7 @@ void xpc_PmmFixOwnerList( xmlNodePtr list, xpc_ProxyNodePtr parent ) { - if ( list ) { + if ( list != NULL ) { xmlNodePtr iterator = list; while ( iterator != NULL ) { switch ( iterator->type ) { @@ -528,7 +532,7 @@ break; } - if ( xpc_PmmOWNER(nodetofix) ) { + if ( xpc_PmmOWNER(nodetofix) != NULL ) { oldParent = xpc_PmmOWNERPO(nodetofix); } @@ -546,7 +550,7 @@ xpc_PmmOWNER(nodetofix) = NULL; } - if ( oldParent && oldParent != nodetofix ) + if ( oldParent != NULL && oldParent != nodetofix ) xpc_PmmREFCNT_dec(oldParent); if ( xpc_PmmNODE(nodetofix)->type != XML_ATTRIBUTE_NODE @@ -605,7 +609,7 @@ { xmlParserCtxtPtr libnode = NULL; int retval = 0; - if ( node ) { + if ( node != NULL ) { retval = xpc_PmmREFCNT(node)--; if ( xpc_PmmREFCNT(node) <= 0 ) { xs_warn( "NODE DELETATION\n" ); @@ -689,21 +693,19 @@ xmlChar *retval = NULL; xmlBufferPtr in = NULL, out = NULL; - if ( charset == 1 ) { + if ( charset == XML_CHAR_ENCODING_UTF8 ) { /* warn("use UTF8 for encoding ... %s ", string); */ - return xmlStrdup( string ); - } - - if ( charset > 1 ) { - /* warn( "use document encoding %s (%d)", encoding, charset ); */ - coder= xmlGetCharEncodingHandler( charset ); - } + return xmlStrdup( string ); + } else if ( charset == XML_CHAR_ENCODING_ERROR ){ /* warn("no standard encoding %s\n", encoding); */ coder =xmlFindCharEncodingHandler( (const char *)encoding ); } - else { + else if ( charset == XML_CHAR_ENCODING_NONE ){ xs_warn("no encoding found \n"); + } else { + /* warn( "use document encoding %s (%d)", encoding, charset ); */ + coder= xmlGetCharEncodingHandler( charset ); } if ( coder != NULL ) { @@ -716,7 +718,7 @@ /* warn( "encoded string is %s" , retval); */ } else { - xs_warn( "b0rked encoiding!\n"); + /* warn( "b0rked encoiding!\n"); */ } xmlBufferFree( in ); @@ -735,21 +737,16 @@ xmlChar *retval = NULL; xmlBufferPtr in = NULL, out = NULL; - if ( charset == 1 ) { - - return xmlStrdup( string ); - } - - if ( charset > 1 ) { - /* warn( "use document encoding %s", encoding ); */ - coder= xmlGetCharEncodingHandler( charset ); - } + if ( charset == XML_CHAR_ENCODING_UTF8 ) { + return xmlStrdup( string ); + } else if ( charset == XML_CHAR_ENCODING_ERROR ){ - /* warn("no standard encoding\n"); */ - coder = xmlFindCharEncodingHandler( (const char *) encoding ); + coder =xmlFindCharEncodingHandler( (const char *)encoding ); } - else { - xs_warn("no encoding found\n"); + else if ( charset == XML_CHAR_ENCODING_NONE ){ + xs_warn("no encoding found \n"); + } else { + coder= xmlGetCharEncodingHandler( charset ); } if ( coder != NULL ) { @@ -759,7 +756,7 @@ xmlBufferCat( in, string ); if ( xmlCharEncOutFunc( coder, out, in ) >= 0 ) { - retval = xmlStrdup(out->content); + retval = xmlCharStrndup(xmlBufferContent(out), xmlBufferLength(out)); } else { xs_warn("decoding error \n"); @@ -805,7 +802,6 @@ xpc_PmmDecodeString( const char *encoding, const xmlChar *string){ char *ret=NULL; xmlCharEncoding enc; - xmlBufferPtr in = NULL, out = NULL; xmlCharEncodingHandlerPtr coder = NULL; if ( string != NULL ) { @@ -913,14 +909,23 @@ if ( refnode != NULL ) { xmlDocPtr real_doc = refnode->doc; - if ( real_doc && real_doc->encoding != NULL ) { + if ( real_doc != NULL && real_doc->encoding != NULL ) { - xmlChar * decoded = xpc_PmmFastDecodeString( xpc_PmmNodeEncoding(real_doc) , - (const xmlChar *)string, - (const xmlChar*)real_doc->encoding); + xmlChar * decoded = xpc_PmmDecodeString( (const xmlChar*)real_doc->encoding, + (const xmlChar *)string ); len = xmlStrlen( decoded ); - if ( real_doc->charset == XML_CHAR_ENCODING_UTF8 ) { + if ( xpc_PmmDocEncoding(real_doc) == XML_CHAR_ENCODING_UTF8 + /* most probably true, since libxml2 always + * sets doc->charset to UTF8, see tree.c: + * + * The in memory encoding is always UTF8 + * This field will never change and would + * be obsolete if not for binary compatibility. + */ + + && (real_doc->encoding == NULL || + xmlParseCharEncoding(real_doc->encoding)==XML_CHAR_ENCODING_UTF8 )) { /* create an UTF8 string. */ xs_warn("set UTF8 string"); /* create the SV */ @@ -960,7 +965,7 @@ perl. in this cases the library assumes, all strings are in UTF8. if a programmer likes to have the intelligent code, he needs to upgrade perl */ -#ifdef HAVE_UTF8 + if ( refnode != NULL ) { xmlDocPtr real_dom = refnode->doc; xs_warn("have node!"); @@ -976,15 +981,17 @@ xs_warn( "no undefs" ); #ifdef HAVE_UTF8 xs_warn( "use UTF8" ); - if( !DO_UTF8(scalar) && real_dom->encoding != NULL ) { + if( !DO_UTF8(scalar) && real_dom != NULL && real_dom->encoding != NULL ) { xs_warn( "string is not UTF8\n" ); #else - if ( real_dom->encoding != NULL ) { + if ( real_dom != NULL && real_dom->encoding != NULL ) { #endif xs_warn( "xpc_domEncodeString!" ); - ts= xpc_PmmFastEncodeString( xpc_PmmNodeEncoding(real_dom), - string, - (const xmlChar*)real_dom->encoding ); + /* if ( string == NULL || *string == 0 ) warn("string is empty" ); */ + + ts= xpc_PmmEncodeString( (const xmlChar*)real_dom->encoding, + string ); + xs_warn( "done!" ); if ( string != NULL ) { xmlFree(string); @@ -995,7 +1002,7 @@ xs_warn( "no encoding set, use UTF8!\n" ); } } - if ( string == NULL ) xs_warn( "string is NULL\n" ); + /* if ( string == NULL ) warn( "string is NULL\n" ); */ return string; } else { @@ -1008,7 +1015,6 @@ } } xs_warn("no encoding !!"); -#endif return xpc_Sv2C( scalar, NULL ); } Index: XPathContext.xs =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/XPathContext.xs,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- XPathContext.xs 21 Sep 2003 10:05:05 -0000 1.36 +++ XPathContext.xs 3 Nov 2003 18:09:38 -0000 1.37 @@ -25,7 +25,9 @@ static SV * xpc_LibXML_error = NULL; -#define xpc_LibXML_init_error() xpc_LibXML_error = NEWSV(0, 512); \ +/* NEWSV(0, 512); \ */ +#define xpc_LibXML_init_error() if (xpc_LibXML_error == NULL || !SvOK(xpc_LibXML_error)) \ + xpc_LibXML_error = NEWSV(0,512); \ sv_setpvn(xpc_LibXML_error, "", 0); \ xmlSetGenericErrorFunc( NULL , \ (xmlGenericErrorFunc)xpc_LibXML_error_handler); @@ -36,8 +38,10 @@ struct _XPathContextData { SV* node; - int lock; + int lock; /* currently unnecessary */ HV* pool; + SV* varLookup; + SV* varData; }; typedef struct _XPathContextData XPathContextData; typedef XPathContextData* XPathContextDataPtr; @@ -185,6 +189,61 @@ } +/* save XPath context and XPathContextDATA for recursion */ +static xmlXPathContextPtr +xpc_LibXML_save_context(xmlXPathContextPtr ctxt) +{ + xmlXPathContextPtr copy; + copy = xmlMalloc(sizeof(xmlXPathContext)); + if (copy) { + /* backup ctxt */ + memcpy(copy, ctxt, sizeof(xmlXPathContext)); + /* clear namespaces so that they are not freed and overwritten + by configure_namespaces */ + ctxt->namespaces = NULL; + /* backup data */ + XPathContextDATA(copy) = xmlMalloc(sizeof(XPathContextData)); + if (XPathContextDATA(copy)) { + memcpy(XPathContextDATA(copy), XPathContextDATA(ctxt),sizeof(XPathContextData)); + /* clear ctxt->pool, so that it is not used freed during re-entrance */ + XPathContextDATA(ctxt)->pool = NULL; + } + } + return copy; +} + +/* restore XPath context and XPathContextDATA from a saved copy */ +static void +xpc_LibXML_restore_context(xmlXPathContextPtr ctxt, xmlXPathContextPtr copy) +{ + /* cleanup */ + if (XPathContextDATA(ctxt)) { + /* cleanup newly created pool */ + if (XPathContextDATA(ctxt)->pool != NULL && + SvOK(XPathContextDATA(ctxt)->pool)) { + SvREFCNT_dec((SV *)XPathContextDATA(ctxt)->pool); + } + } + if (ctxt->namespaces) { + /* free namespaces allocated during recursion */ + xmlFree( ctxt->namespaces ); + } + + /* restore context */ + if (copy) { + /* 1st restore our data */ + if (XPathContextDATA(copy)) { + memcpy(XPathContextDATA(ctxt),XPathContextDATA(copy),sizeof(XPathContextData)); + xmlFree(XPathContextDATA(copy)); + XPathContextDATA(copy) = XPathContextDATA(ctxt); + } + /* now copy the rest */ + memcpy(ctxt, copy, sizeof(xmlXPathContext)); + xmlFree(copy); + } +} + + /* **************************************************************** * Variable Lookup * **************************************************************** */ @@ -195,37 +254,40 @@ const xmlChar *ns_uri) { xmlXPathObjectPtr ret; - SV ** lookup_func; - SV ** lookup_data; + xmlXPathContextPtr ctxt; + xmlXPathContextPtr copy; + XPathContextDataPtr data; I32 count; dSP; - SV * data; - SV ** fetch; - data = (SV *) varLookupData; - if (varLookupData == NULL || !SvROK(data) || - SvTYPE(SvRV(data)) != SVt_PVAV) { - croak("XPathContext: lost variable lookup data structure!"); - } - - lookup_func = av_fetch((AV *) SvRV(data),0,0 ); - if ( lookup_func == NULL || !SvROK(*lookup_func) || SvTYPE(SvRV(*lookup_func)) != SVt_PVCV ) { + ctxt = (xmlXPathContextPtr) varLookupData; + if ( ctxt == NULL ) + croak("XPathContext: missing xpath context"); + data = XPathContextDATA(ctxt); + if ( data == NULL ) + croak("XPathContext: missing xpath context private data"); + if ( data->varLookup == NULL || !SvROK(data->varLookup) || + SvTYPE(SvRV(data->varLookup)) != SVt_PVCV ) croak("XPathContext: lost variable lookup function!"); - } - lookup_data = av_fetch((AV *) SvRV(data),1,0 ); ENTER; SAVETMPS; PUSHMARK(SP); - XPUSHs( (lookup_data != NULL) ? *lookup_data : &PL_sv_undef ); + XPUSHs( (data->varData != NULL) ? data->varData : &PL_sv_undef ); XPUSHs(sv_2mortal(xpc_C2Sv(name,NULL))); XPUSHs(sv_2mortal(xpc_C2Sv(ns_uri,NULL))); - PUTBACK ; - count = perl_call_sv(*lookup_func, G_SCALAR|G_EVAL); + /* save context to allow recursive usage of XPathContext */ + copy = xpc_LibXML_save_context(ctxt); + PUTBACK ; + count = perl_call_sv(data->varLookup, G_SCALAR|G_EVAL); SPAGAIN; + + /* restore the xpath context */ + xpc_LibXML_restore_context(ctxt, copy); + if (SvTRUE(ERRSV)) { POPs; croak("XPathContext: error coming back from variable lookup function. %s", SvPV_nolen(ERRSV)); @@ -260,6 +322,7 @@ SV **perl_function; dSP; SV * data; + xmlXPathContextPtr copy; /* warn("entered xpc_LibXML_generic_extension_function for %s\n",ctxt->context->function); */ data = (SV *) ctxt->context->funcLookupData; @@ -362,14 +425,18 @@ xmlXPathFreeObject(obj); } + /* save context to allow recursive usage of XPathContext */ + copy = xpc_LibXML_save_context(ctxt->context); + /* call perl dispatcher */ PUTBACK; - perl_dispatch = sv_2mortal(newSVpv("XML::LibXML::XPathContext::_perl_dispatcher",0)); - count = perl_call_sv(perl_dispatch, G_SCALAR|G_EVAL); - + count = perl_call_sv(perl_dispatch, G_SCALAR|G_EVAL); SPAGAIN; + /* restore the xpath context */ + xpc_LibXML_restore_context(ctxt->context, copy); + if (SvTRUE(ERRSV)) { POPs; croak("XPathContext: error coming back from perl-dispatcher in pm file. %s", SvPV_nolen(ERRSV)); @@ -453,6 +520,8 @@ XPathContextDATA(ctxt)->lock = 0; XPathContextDATA(ctxt)->pool = NULL; + XPathContextDATA(ctxt)->varLookup = NULL; + XPathContextDATA(ctxt)->varData = NULL; xmlXPathRegisterFunc(ctxt, (const xmlChar *) "document", @@ -478,6 +547,14 @@ SvOK(XPathContextDATA(ctxt)->node)) { SvREFCNT_dec(XPathContextDATA(ctxt)->node); } + if (XPathContextDATA(ctxt)->varLookup != NULL && + SvOK(XPathContextDATA(ctxt)->varLookup)) { + SvREFCNT_dec(XPathContextDATA(ctxt)->varLookup); + } + if (XPathContextDATA(ctxt)->varData != NULL && + SvOK(XPathContextDATA(ctxt)->varData)) { + SvREFCNT_dec(XPathContextDATA(ctxt)->varData); + } if (XPathContextDATA(ctxt)->pool != NULL && SvOK(XPathContextDATA(ctxt)->pool)) { SvREFCNT_dec((SV *)XPathContextDATA(ctxt)->pool); @@ -488,10 +565,6 @@ if (ctxt->namespaces != NULL) { xmlFree( ctxt->namespaces ); } - if (ctxt->varLookupData != NULL && SvROK((SV*)ctxt->varLookupData) - && SvTYPE(SvRV((SV *)ctxt->varLookupData)) == SVt_PVAV) { - SvREFCNT_dec((SV *)ctxt->varLookupData); - } if (ctxt->funcLookupData != NULL && SvROK((SV*)ctxt->funcLookupData) && SvTYPE(SvRV((SV *)ctxt->funcLookupData)) == SVt_PVHV) { SvREFCNT_dec((SV *)ctxt->funcLookupData); @@ -517,6 +590,32 @@ OUTPUT: RETVAL +int +getContextPosition( self ) + SV * self + INIT: + xmlXPathContextPtr ctxt = (xmlXPathContextPtr)SvIV(SvRV(self)); + if ( ctxt == NULL ) { + croak("XPathContext: missing xpath context"); + } + CODE: + RETVAL = ctxt->proximityPosition; + OUTPUT: + RETVAL + +int +getContextSize( self ) + SV * self + INIT: + xmlXPathContextPtr ctxt = (xmlXPathContextPtr)SvIV(SvRV(self)); + if ( ctxt == NULL ) { + croak("XPathContext: missing xpath context"); + } + CODE: + RETVAL = ctxt->contextSize; + OUTPUT: + RETVAL + void setContextNode( self , pnode ) SV * self @@ -536,6 +635,38 @@ XPathContextDATA(ctxt)->node = NULL; } +void +setContextPosition( self , position ) + SV * self + int position + INIT: + xmlXPathContextPtr ctxt = (xmlXPathContextPtr)SvIV(SvRV(self)); + if ( ctxt == NULL ) + croak("XPathContext: missing xpath context"); + if ( position < 0 || position > ctxt->contextSize ) + croak("XPathContext: invalid position"); + PPCODE: + ctxt->proximityPosition = position; + +void +setContextSize( self , size ) + SV * self + int size + INIT: + xmlXPathContextPtr ctxt = (xmlXPathContextPtr)SvIV(SvRV(self)); + if ( ctxt == NULL ) + croak("XPathContext: missing xpath context"); + if ( size < -1 ) + croak("XPathContext: invalid size"); + PPCODE: + ctxt->contextSize = size; + if ( size == 0 ) + ctxt->proximityPosition = 0; + else if ( size > 0 ) + ctxt->proximityPosition = 1; + else + ctxt->proximityPosition = -1; + void registerNs( pxpath_context, prefix, ns_uri ) SV * pxpath_context @@ -583,23 +714,30 @@ getVarLookupData( self ) SV * self INIT: - SV ** lookup_data; xmlXPathContextPtr ctxt = (xmlXPathContextPtr)SvIV(SvRV(self)); if ( ctxt == NULL ) { croak("XPathContext: missing xpath context"); } - xpc_LibXML_configure_xpathcontext(ctxt); CODE: - if (ctxt->varLookupData != NULL && - SvROK((SV*)(ctxt->varLookupData)) && - SvTYPE(SvRV((SV*)(ctxt->varLookupData))) == SVt_PVAV) { - lookup_data = av_fetch((AV *) SvRV((SV*)(ctxt->varLookupData)),1,0); - if (lookup_data != NULL) { - SvREFCNT_inc(*lookup_data); - RETVAL = *lookup_data; - } else { - RETVAL = &PL_sv_undef; - } + if(XPathContextDATA(ctxt)->varData != NULL) { + RETVAL = newSVsv(XPathContextDATA(ctxt)->varData); + } else { + RETVAL = &PL_sv_undef; + } + OUTPUT: + RETVAL + +SV* +getVarLookupFunc( self ) + SV * self + INIT: + xmlXPathContextPtr ctxt = (xmlXPathContextPtr)SvIV(SvRV(self)); + if ( ctxt == NULL ) { + croak("XPathContext: missing xpath context"); + } + CODE: + if(XPathContextDATA(ctxt)->varData != NULL) { + RETVAL = newSVsv(XPathContextDATA(ctxt)->varLookup); } else { RETVAL = &PL_sv_undef; } @@ -613,38 +751,37 @@ SV * lookup_data PREINIT: xmlXPathContextPtr ctxt = NULL; + XPathContextDataPtr data = NULL; SV* pfdr; INIT: ctxt = (xmlXPathContextPtr)SvIV(SvRV(pxpath_context)); - if ( ctxt == NULL ) { + if ( ctxt == NULL ) croak("XPathContext: missing xpath context"); - } + data = XPathContextDATA(ctxt); + if ( data == NULL ) + croak("XPathContext: missing xpath context private data"); xpc_LibXML_configure_xpathcontext(ctxt); + /* free previous lookup function and data */ + if (data->varLookup && SvOK(data->varLookup)) + SvREFCNT_dec(data->varLookup); + if (data->varData && SvOK(data->varData)) + SvREFCNT_dec(data->varData); + data->varLookup=NULL; + data->varData=NULL; + PPCODE: if (SvOK(lookup_func)) { if ( SvROK(lookup_func) && SvTYPE(SvRV(lookup_func)) == SVt_PVCV ) { - pfdr = newRV_inc((SV*) newAV()); - av_push((AV *)SvRV(pfdr), newSVsv(lookup_func)); - av_push((AV *)SvRV(pfdr), newSVsv(lookup_data)); + data->varLookup = newSVsv(lookup_func); + if (SvOK(lookup_data)) + data->varData = newSVsv(lookup_data); + xmlXPathRegisterVariableLookup(ctxt, + xpc_LibXML_generic_variable_lookup, ctxt); + if (ctxt->varLookupData==NULL || ctxt->varLookupData != ctxt) { + croak( "XPathContext: registration failure" ); + } } else { croak("XPathContext: 1st argument is not a CODE reference"); } - } - if (ctxt->varLookupData != NULL) { - /* free previous lookup data */ - if (SvTYPE(SvRV((SV *)ctxt->varLookupData)) == SVt_PVAV) { - SvREFCNT_dec((SV *)ctxt->varLookupData); - ctxt->varLookupData = NULL; - ctxt->varLookupFunc = NULL; - } else { - croak("XPathContext: cannot register: varLookupData slot already occupied"); - } - } - PPCODE: - if (SvOK(lookup_func)) { - xmlXPathRegisterVariableLookup(ctxt, xpc_LibXML_generic_variable_lookup, pfdr); - if (ctxt->varLookupData==NULL || ctxt->varLookupData != pfdr) { - croak( "XPathContext: registration failure" ); - } } else { /* unregister */ xmlXPathRegisterVariableLookup(ctxt, NULL, NULL); @@ -801,7 +938,6 @@ } xmlFree(xpath); - sv_2mortal( xpc_LibXML_error ); xpc_LibXML_croak_error(); if ( nodelist ) { @@ -896,7 +1032,6 @@ xmlFree( xpath ); - sv_2mortal( xpc_LibXML_error ); xpc_LibXML_croak_error(); if (found) { Index: XPathContext.pm =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/XPathContext.pm,v retrieving revision 1.30 retrieving revision 1.31 diff -u -d -r1.30 -r1.31 --- XPathContext.pm 22 Sep 2003 08:02:56 -0000 1.30 +++ XPathContext.pm 3 Nov 2003 18:09:38 -0000 1.31 @@ -7,7 +7,7 @@ use XML::LibXML::NodeList; -$VERSION = '0.05'; +$VERSION = '0.06'; require DynaLoader; @ISA = qw(DynaLoader); @@ -55,15 +55,15 @@ $prev_node = $self->getContextNode(); $self->setContextNode($node); } - $self->_enter; +# $self->_enter; # lock my @ret; eval { @ret = $self->$method($xpath); }; - $self->_leave; + $self->_leave; # unlock and free node-pool $self->setContextNode($prev_node) if ref($node); - if ($@) { die $@; } + if ($@) { die "ERROR: $@"; } return @ret; } @@ -147,6 +147,11 @@ my $node = $xc->getContextNode; $xc->setContextNode($node); + my $position = $xc->getContextPosition; + $xc->setContextPosition($position); + my $size = $xc->getContextSize; + $xc->setContextSize($size); + $xc->registerNs($prefix, $namespace_uri); $xc->unregisterNs($prefix); my $namespace_uri = $xc->lookupNs($prefix); @@ -158,6 +163,8 @@ $xc->registerVarLookupFunc(sub { ... }, $data); $xc->unregisterVarLookupFunc($name); + $data = $xc->getVarLookupData(); + $sub = $xc->getVarLookupFunc(); my @nodes = $xc->findnodes($xpath); my @nodes = $xc->findnodes($xpath, $context_node); @@ -191,6 +198,10 @@ defining variable lookup functions in Perl. +=item 3 + +cheating the context about current proximity position and context size + =back =head1 EXAMPLES @@ -369,20 +380,49 @@ Set the current context node. -=back +=item B<setContextPosition($position)> -=head1 BUGS AND CAVEATS +Set the current proximity position. By default, this value is -1 (and +evaluating XPath function position() in the initial context raises an +XPath error), but can be set to any value up to context size. This +usually only serves to cheat the XPath engine to return given position +when position() XPath function is called. Setting this value to -1 +restores the default behavior. -XML::LibXML::XPathContext objects are not reentrant. It means you -cannot register a Perl function with a XML::LibXML::XPathContext -object if this Perl function uses itself the same -XML::LibXML::XPathContext object internally. +=item B<getContextPosition()> -For example, the following code will not work: +Get the current proximity position. - my $xc = XML::LibXML::XPathContext->new($node); - $xc->registerFunction('func', sub { $xc->findvalue('1') }); - my $result = $xc->findvalue('func()'); +=item B<setContextSize($size)> + +Set the current size. By default, this value is -1 (and evaluating +XPath function last() in the initial context raises an XPath error), +but can be set to any non-negative value. This usually only serves to +cheat the XPath engine to return the given value when last() XPath +function is called. If context size is set to 0, position is +automatically also set to 0. If context size is positive, position is +automatically set to 1. Setting context size to -1 restores the +default behavior. + +=item B<getContextPosition()> + +Get the current proximity position. + +=item B<setContextNode($node)> + +Set the current context node. + +=back + +=head1 BUGS AND CAVEATS + +From version 0.06, XML::LibXML::XPathContext objects B<are> reentrant, +meaning that you can call methods of an XML::LibXML::XPathContext even +from XPath extension functions registered with the same object or from +a variable lookup function. On the other hand, you should rather +avoid registering new extension functions, namespaces and a variable +lookup function from within extension functions and a variable lookup +function, unless you want to experience untested behavior. =head1 AUTHORS Index: README =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/README,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- README 25 Jul 2003 12:51:03 -0000 1.6 +++ README 3 Nov 2003 18:09:38 -0000 1.7 @@ -10,6 +10,11 @@ my $node = $xc->getContextNode; $xc->setContextNode($node); + my $position = $xc->getContextPosition; + $xc->setContextPosition($position); + my $size = $xc->getContextSize; + $xc->setContextSize($size); + $xc->registerNs($prefix, $namespace_uri); $xc->unregisterNs($prefix); my $namespace_uri = $xc->lookupNs($prefix); @@ -21,6 +26,8 @@ $xc->registerVarLookupFunc(sub { ... }, $data); $xc->unregisterVarLookupFunc($name); + $data = $xc->getVarLookupData(); + $sub = $xc->getVarLookupFunc(); my @nodes = $xc->findnodes($xpath); my @nodes = $xc->findnodes($xpath, $context_node); @@ -43,6 +50,9 @@ 3 defining variable lookup functions in Perl. + 3 cheating the context about current proximity position and context + size + EXAMPLES Find all paragraph nodes in XHTML document This example demonstrates *registerNs()* usage: @@ -190,17 +200,41 @@ setContextNode($node) Set the current context node. -BUGS AND CAVEATS - XML::LibXML::XPathContext objects are not reentrant. It means you cannot - register a Perl function with a XML::LibXML::XPathContext object if this - Perl function uses itself the same XML::LibXML::XPathContext object - internally. + setContextPosition($position) + Set the current proximity position. By default, this value is -1 + (and evaluating XPath function position() in the initial context + raises an XPath error), but can be set to any value up to context + size. This usually only serves to cheat the XPath engine to return + given position when position() XPath function is called. Setting + this value to -1 restores the default behavior. - For example, the following code will not work: + getContextPosition() + Get the current proximity position. - my $xc = XML::LibXML::XPathContext->new($node); - $xc->registerFunction('func', sub { $xc->findvalue('1') }); - my $result = $xc->findvalue('func()'); + setContextSize($size) + Set the current size. By default, this value is -1 (and evaluating + XPath function last() in the initial context raises an XPath error), + but can be set to any non-negative value. This usually only serves + to cheat the XPath engine to return the given value when last() + XPath function is called. If context size is set to 0, position is + automatically also set to 0. If context size is positive, position + is automatically set to 1. Setting context size to -1 restores the + default behavior. + + getContextPosition() + Get the current proximity position. + + setContextNode($node) + Set the current context node. + +BUGS AND CAVEATS + From version 0.06, XML::LibXML::XPathContext objects are reentrant, + meaning that you can call methods of an XML::LibXML::XPathContext even + from XPath extension functions registered with the same object or from a + variable lookup function. On the other hand, you should rather avoid + registering new extension functions, namespaces and a variable lookup + function from within extension functions and a variable lookup function, + unless you want to experience untested behavior. AUTHORS Based on XML::LibXML and XML::XSLT code by Matt Sergeant and Christian Index: Changes =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/Changes,v retrieving revision 1.12 retrieving revision 1.13 diff -u -d -r1.12 -r1.13 --- Changes 22 Sep 2003 08:02:26 -0000 1.12 +++ Changes 3 Nov 2003 18:09:38 -0000 1.13 @@ -2,6 +2,22 @@ Revision history for Perl module XML::LibXML::XPathContext. +0.06 Mon Nov 3 2003 + +* simplified variable lookup code to use a C structure instead of + a perl AV* + +* made XPathContext reentrant (by saving the state before + a callback and restoring it afterwards). + +* added get/setContextSize, get/setContextPosition + +* added getVarLookupFunc + +* added some tests and documentation for the new features + +* applied last LibXML patch for perl-libxml-mm.c + 0.05 Mon Sep 22 2003 * lookupNs() method added |
From: Petr P. <pa...@us...> - 2003-11-03 18:09:41
|
Update of /cvsroot/perl-xml/XML-LibXML-XPathContext/t In directory sc8-pr-cvs1:/tmp/cvs-serv27421/t Modified Files: 02-functions.t 01-variables.t 00-xpathcontext.t Log Message: * simplified variable lookup code to use a C structure instead of a perl AV* * made XPathContext reentrant (by saving the state before a callback and restoring it afterwards). * added get/setContextSize, get/setContextPosition * added getVarLookupFunc * added some tests and documentation for the new features * applied last LibXML patch for perl-libxml-mm.c Index: 02-functions.t =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/t/02-functions.t,v retrieving revision 1.7 retrieving revision 1.8 diff -u -d -r1.7 -r1.8 --- 02-functions.t 29 Mar 2003 15:45:48 -0000 1.7 +++ 02-functions.t 3 Nov 2003 18:09:38 -0000 1.8 @@ -1,6 +1,6 @@ # -*- cperl -*- use Test; -BEGIN { plan tests => 28 }; +BEGIN { plan tests => 32 }; use XML::LibXML; use XML::LibXML::XPathContext; @@ -67,17 +67,19 @@ eval { $xc->findvalue('foo:copy("bar")') }; ok ($@); -# test context locking mechanism -$xc->registerFunction('test-lock1', sub { $xc->find('1') }); -$xc->registerFunction('test-lock2', sub { $xc->findnodes('1') }); -eval { $xc->find('test-lock1()') }; -ok($@); -eval { $xc->findnodes('test-lock1()') }; -ok($@); -eval { $xc->find('test-lock2()') }; -ok($@); -eval { $xc->findnodes('test-lock2()') }; -ok($@); +# test context reentrance +$xc->registerFunction('test-lock1', sub { $xc->find('string(//node())') }); +$xc->registerFunction('test-lock2', sub { $xc->findnodes('//bar') }); +ok($xc->find('test-lock1()') eq $xc->find('string(//node())')); +ok($xc->find('count(//bar)=2')); +ok($xc->find('count(test-lock2())=count(//bar)')); +ok($xc->find('count(test-lock2()|//bar)=count(//bar)')); +ok($xc->findnodes('test-lock2()[2]')->pop()->isSameNode($xc->findnodes('//bar[2]'))); + +$xc->registerFunction('test-lock3', sub { $xc->findnodes('test-lock2(//bar)') }); +ok($xc->find('count(test-lock2())=count(test-lock3())')); +ok($xc->find('count(test-lock3())=count(//bar)')); +ok($xc->find('count(test-lock3()|//bar)=count(//bar)')); # function creating new nodes $xc->registerFunction('new-foo', Index: 01-variables.t =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/t/01-variables.t,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- 01-variables.t 4 Apr 2003 18:42:57 -0000 1.4 +++ 01-variables.t 3 Nov 2003 18:09:38 -0000 1.5 @@ -1,6 +1,6 @@ # -*- cperl -*- use Test; -BEGIN { plan tests => 33 }; +BEGIN { plan tests => 35 }; use XML::LibXML; use XML::LibXML::XPathContext; @@ -51,6 +51,7 @@ my $h2=\%variables; ok("$h1" eq "$h2" ); ok($h1 eq $xc->getVarLookupData); +ok(\&get_variable eq $xc->getVarLookupFunc); # test values returned by XPath queries ok($xc->find('$a') == 2); @@ -76,6 +77,7 @@ $xc->unregisterVarLookupFunc(); eval { $xc->find('$a') }; ok($@); +ok(!defined($xc->getVarLookupFunc())); my $foo='foo'; $xc->registerVarLookupFunc(sub {},$foo); Index: 00-xpathcontext.t =================================================================== RCS file: /cvsroot/perl-xml/XML-LibXML-XPathContext/t/00-xpathcontext.t,v retrieving revision 1.11 retrieving revision 1.12 diff -u -d -r1.11 -r1.12 --- 00-xpathcontext.t 22 Sep 2003 08:08:03 -0000 1.11 +++ 00-xpathcontext.t 3 Nov 2003 18:09:38 -0000 1.12 @@ -1,5 +1,5 @@ use Test; -BEGIN { plan tests => 30 }; +BEGIN { plan tests => 54 }; use XML::LibXML; use XML::LibXML::XPathContext; @@ -99,3 +99,46 @@ $xc5->setContextNode($doc); $xc5->findnodes('/'); ok(1); + +# check setting context position and size +ok($xc4->getContextPosition() == -1); +ok($xc4->getContextSize() == -1); +eval { $xc4->setContextPosition(4); }; +ok($@); +eval { $xc4->setContextPosition(-4); }; +ok($@); +eval { $xc4->setContextSize(-4); }; +ok($@); +eval { $xc4->findvalue('position()') }; +ok($@); +eval { $xc4->findvalue('last()') }; +ok($@); + +$xc4->setContextSize(0); +ok($xc4->getContextSize() == 0); +ok($xc4->getContextPosition() == 0); +ok($xc4->findvalue('position()')==0); +ok($xc4->findvalue('last()')==0); + +$xc4->setContextSize(4); +ok($xc4->getContextSize() == 4); +ok($xc4->getContextPosition() == 1); +ok($xc4->findvalue('last()')==4); +ok($xc4->findvalue('position()')==1); +eval { $xc4->setContextPosition(5); }; +ok($@); +ok($xc4->findvalue('position()')==1); +ok($xc4->getContextSize() == 4); +$xc4->setContextPosition(4); +ok($xc4->findvalue('position()')==4); +ok($xc4->findvalue('position()=last()')); + +$xc4->setContextSize(-1); +ok($xc4->getContextPosition() == -1); +ok($xc4->getContextSize() == -1); +eval { $xc4->findvalue('position()') }; +ok($@); +eval { $xc4->findvalue('last()') }; +ok($@); + + |