r21555 - in /branches/upstream/libxml-sax-expat-incremental-perl: ./ current/ current/lib/ current/lib/XML/ current/lib/XML/SAX/ current/lib/XML/SAX/Expat/ current/t/
gregoa at users.alioth.debian.org
gregoa at users.alioth.debian.org
Sun Jun 15 16:05:20 UTC 2008
Author: gregoa
Date: Sun Jun 15 16:05:20 2008
New Revision: 21555
URL: http://svn.debian.org/wsvn/?sc=1&rev=21555
Log:
[svn-inject] Installing original source of libxml-sax-expat-incremental-perl
Added:
branches/upstream/libxml-sax-expat-incremental-perl/
branches/upstream/libxml-sax-expat-incremental-perl/current/
branches/upstream/libxml-sax-expat-incremental-perl/current/MANIFEST
branches/upstream/libxml-sax-expat-incremental-perl/current/META.yml
branches/upstream/libxml-sax-expat-incremental-perl/current/Makefile.PL
branches/upstream/libxml-sax-expat-incremental-perl/current/SIGNATURE
branches/upstream/libxml-sax-expat-incremental-perl/current/lib/
branches/upstream/libxml-sax-expat-incremental-perl/current/lib/XML/
branches/upstream/libxml-sax-expat-incremental-perl/current/lib/XML/SAX/
branches/upstream/libxml-sax-expat-incremental-perl/current/lib/XML/SAX/Expat/
branches/upstream/libxml-sax-expat-incremental-perl/current/lib/XML/SAX/Expat/Incremental.pm
branches/upstream/libxml-sax-expat-incremental-perl/current/t/
branches/upstream/libxml-sax-expat-incremental-perl/current/t/basic.t
branches/upstream/libxml-sax-expat-incremental-perl/current/t/dist.t
branches/upstream/libxml-sax-expat-incremental-perl/current/t/incr.t
Added: branches/upstream/libxml-sax-expat-incremental-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-sax-expat-incremental-perl/current/MANIFEST?rev=21555&op=file
==============================================================================
--- branches/upstream/libxml-sax-expat-incremental-perl/current/MANIFEST (added)
+++ branches/upstream/libxml-sax-expat-incremental-perl/current/MANIFEST Sun Jun 15 16:05:20 2008
@@ -1,0 +1,8 @@
+lib/XML/SAX/Expat/Incremental.pm
+Makefile.PL
+MANIFEST This list of files
+META.yml
+SIGNATURE
+t/basic.t
+t/dist.t
+t/incr.t
Added: branches/upstream/libxml-sax-expat-incremental-perl/current/META.yml
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-sax-expat-incremental-perl/current/META.yml?rev=21555&op=file
==============================================================================
--- branches/upstream/libxml-sax-expat-incremental-perl/current/META.yml (added)
+++ branches/upstream/libxml-sax-expat-incremental-perl/current/META.yml Sun Jun 15 16:05:20 2008
@@ -1,0 +1,14 @@
+# http://module-build.sourceforge.net/META-spec.html
+#XXXXXXX This is a prototype!!! It will change in the future!!! XXXXX#
+name: XML-SAX-Expat-Incremental
+version: 0.04
+version_from: lib/XML/SAX/Expat/Incremental.pm
+installdirs: site
+requires:
+ Test::Exception: 0
+ Test::More: 0
+ XML::Parser: 0
+ XML::SAX::Expat: 0
+
+distribution_type: module
+generated_by: ExtUtils::MakeMaker version 6.30
Added: branches/upstream/libxml-sax-expat-incremental-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-sax-expat-incremental-perl/current/Makefile.PL?rev=21555&op=file
==============================================================================
--- branches/upstream/libxml-sax-expat-incremental-perl/current/Makefile.PL (added)
+++ branches/upstream/libxml-sax-expat-incremental-perl/current/Makefile.PL Sun Jun 15 16:05:20 2008
@@ -1,0 +1,37 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+use ExtUtils::MakeMaker;
+WriteMakefile(
+ NAME => 'XML::SAX::Expat::Incremental',
+ VERSION_FROM => 'lib/XML/SAX/Expat/Incremental.pm',
+ (eval { ExtUtils::MakeMaker->VERSION("6.18") } ? (SIGN => 1) : ()),
+ AUTHOR => 'Yuval Kogman',
+ ABSTRACT => 'Incremental/non-blocking SAX Driver for Expat',
+ PREREQ_PM => {
+ "XML::SAX::Expat" => '0', # which implies
+ "XML::Parser" => '0',
+ "Test::Exception" => '0',
+ "Test::More" => '0',
+ },
+);
+
+__END__
+# according to: https://rt.cpan.org/Ticket/Display.html?id=13764 this is broken
+
+## add ourselves to the list of installed parsers
+sub MY::install {
+ package MY;
+ my $script = shift->SUPER::install(@_);
+ $script =~ s/install :: (.*)$/install :: $1 install_sax_expat_inc/m;
+ $script .= <<"INSTALL";
+
+install_sax_expat_inc :
+\t\@\$(PERL) -MXML::SAX -e "XML::SAX->add_parser(q(XML::SAX::Expat::Incremental))->save_parsers()"
+
+INSTALL
+
+ return $script;
+}
+
Added: branches/upstream/libxml-sax-expat-incremental-perl/current/SIGNATURE
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-sax-expat-incremental-perl/current/SIGNATURE?rev=21555&op=file
==============================================================================
--- branches/upstream/libxml-sax-expat-incremental-perl/current/SIGNATURE (added)
+++ branches/upstream/libxml-sax-expat-incremental-perl/current/SIGNATURE Sun Jun 15 16:05:20 2008
@@ -1,0 +1,30 @@
+This file contains message digests of all files listed in MANIFEST,
+signed via the Module::Signature module, version 0.44.
+
+To verify the content in this distribution, first make sure you have
+Module::Signature installed, then type:
+
+ % cpansign -v
+
+It will check each file's integrity, as well as the signature's
+validity. If "==> Signature verified OK! <==" is not displayed,
+the distribution may already have been compromised, and you should
+not run its Makefile.PL or Build.PL.
+
+-----BEGIN PGP SIGNED MESSAGE-----
+Hash: SHA1
+
+SHA1 ed3514f56e7f080f849372730b39a36b31ec78be MANIFEST
+SHA1 483ca7c17deb393e33852c1406eea8982d1ebec3 META.yml
+SHA1 9770a7f921af4d62b2146fbc78f9505453136e13 Makefile.PL
+SHA1 f4c4584a995ddc9066819f05eaa4d7b838a94c91 lib/XML/SAX/Expat/Incremental.pm
+SHA1 f7376fd5701446ceb6c9249e43946ef1800fa115 t/basic.t
+SHA1 c04440d94389ed001b94cdec72080305ed7d9648 t/dist.t
+SHA1 6da947e3423e6f4abc55da961452185b636bc3c0 t/incr.t
+-----BEGIN PGP SIGNATURE-----
+Version: GnuPG v1.4.1 (Darwin)
+
+iD8DBQFC3l0sVCwRwOvSdBgRAvRpAJoCZhJsaFKTsEQNrl26LNnC4hVl/gCfUBBu
++RezgHjgW2FgXS5WpGQft+I=
+=biL8
+-----END PGP SIGNATURE-----
Added: branches/upstream/libxml-sax-expat-incremental-perl/current/lib/XML/SAX/Expat/Incremental.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-sax-expat-incremental-perl/current/lib/XML/SAX/Expat/Incremental.pm?rev=21555&op=file
==============================================================================
--- branches/upstream/libxml-sax-expat-incremental-perl/current/lib/XML/SAX/Expat/Incremental.pm (added)
+++ branches/upstream/libxml-sax-expat-incremental-perl/current/lib/XML/SAX/Expat/Incremental.pm Sun Jun 15 16:05:20 2008
@@ -1,0 +1,224 @@
+#!/usr/bin/perl -w
+
+package XML::SAX::Expat::Incremental;
+use base qw/XML::SAX::Expat/;
+
+use strict;
+#use warnings;
+
+use vars qw/$VERSION/;
+$VERSION = "0.04";
+
+use XML::Parser ();
+use Carp qw/croak/;
+
+sub parse {
+ my $p = shift;
+ my $opts = $p->get_options(@_);
+
+ if ($p->{Parent}){
+ return $p->{Parent}->parse($opts);
+ } else {
+ if (defined $opts->{Source}{String}){
+ return $p->_parse_string($opts->{Source}{String});
+ } else {
+ croak "The only thing I know how to parse is a string. You have to fetch the data for me yourself.";
+ }
+ }
+}
+
+sub parse_more {
+ my $p = shift;
+ $p->parse_string(@_);
+}
+
+sub _parse_string {
+ my $p = shift;
+ my $xml = shift;
+
+ $p->parse_start unless $p->{_parsing};
+
+ $p->_expat_obj->parse_more($xml);
+}
+
+sub parse_start {
+ my $p = shift;
+ my $opt = shift;
+
+ croak "Can't parse_start - Already started"
+ if $p->{_parsing};
+
+ $p->{_parsing} = 1;
+
+ $p->_really_create_parser($opt);
+ $p->_expat_obj($p->_parser_obj->parse_start);
+}
+
+sub parse_done {
+ my $p = shift;
+
+ croak "Can't parse_done - Havn't started parsing. Call parse_start or just parse first."
+ unless $p->{_parsing};
+
+ undef $p->{_parsing};
+
+ $p->_expat_obj->parse_done;
+}
+
+
+
+sub _really_create_parser { # we only create the parser when parse_start is called
+ my $p = shift;
+ my $opt = shift;
+ $p->{_xml_parser_obj} ||= $p->SUPER::_create_parser($opt);
+}
+
+sub _create_parser { # this is defined by XML::SAX::Expat
+ my $p = shift;
+ $p->_expat_obj;
+}
+
+sub _expat_obj {
+ my $p = shift;
+ $p->{_expat_nb_obj} = shift if @_;
+ $p->{_expat_nb_obj};
+}
+
+sub _parser_obj {
+ my $p = shift;
+ $p->{_xml_parser_obj} = shift if @_;
+ $p->{_xml_parser_obj};
+}
+
+__PACKAGE__
+
+__END__
+
+=pod
+
+=head1 NAME
+
+XML::SAX::Expat::Incremental - XML::SAX::Expat subclass for non-blocking (incremental)
+parsing, with
+L<XML::Parser::ExpatNB|XML::Parser::Expat/"XML::Parser::ExpatNB Methods">.
+
+=head1 SYNOPSIS
+
+ use XML::SAX::Expat::Incremental;
+
+ # don't do this, use XML::SAX::ParserFactory
+ my $p = XML::SAX::Expat::Incremental->new( Handler => MyHandler->new );
+
+ $p->parse_start;
+
+ while (<DATA>){
+ $p->parse_more($_); # or $p->parse_string($_);
+ }
+
+ $p->parse_done;
+
+=head1 DESCRIPTION
+
+Most XML parsers give a callback interface within an encapsulated loop. That
+is, you call
+
+ $p->parse_whatever($whatever);
+
+And eventually, when C<$whatever> is depleted by the parser, C<< $p->parse >>
+will return.
+
+Sometimes you don't want the parser to control the loop for you. For example,
+if you need to retrieve your XML in chunks in a funny way, you might need to do
+something like
+
+ my $doc = '';
+ while (defined(my $buffer = get_more_xml())) {
+ $doc .= $buffer;
+ }
+
+ $p->parse_string($doc);
+
+which is not very convenient, or efficient. You could use L<perltie> to tie a
+filehandle which does this for you, but that only works some of the time (for
+example, say you have two inputs coming in simultaneously).
+
+L<XML::Parser::ExpatNB|XML::Parser::Expat/"XML::Parser::ExpatNB Methods">
+solves this by providing three methods:
+
+=over 4
+
+=item parse_start
+
+=item parse_more
+
+=item parse_done
+
+=back
+
+This interface lets you move the loop to outside the parser, retaining control.
+
+The callbacks are executed in the same manner, just that now, when there is no
+left to parse, instead of taking more data from a source on it's own, the
+parser returns control to you.
+
+ $p->parse_start; # you can omit this - parse_start will
+ # be called automatically as needed
+
+ while(defined(my $buffer = get_more_xml())) {
+ $p->parse_more($buffer);
+ }
+
+ $p->parse_done;
+
+This module is a subclass of L<XML::SAX::Expat> which is to
+L<XML::Parser::ExpatXS> as L<XML::SAX::Expat> is to L<XML::Parser> itself.
+
+=head1 METHODS
+
+=over 4
+
+=item parse_string STRING
+
+=item parse_more STRING
+
+These have the same effect, except that parse_more actually calls parse_string
+with @_. You might want to use parse_string because in theory it's more
+efficient.
+
+This simply continues parsing with the new string, and sends SAX events for the
+data that is complete in the string.
+
+=item parse_start
+
+This calls parse_start on the underlying XML::Parser::ExpatNB object. It's
+called implicitly when you first call parse_string, though, so you don't have
+to worry about it.
+
+=item parse_done
+
+This calls parse_done on the underlying XML::Parser::ExpatNB object. You use it
+to tell the parser you have no more data to give it.
+
+=item parse
+
+This is used internally as a sort of parse-anything method. Don't use it,
+instead use C<parse_string>, which invokes this method correctly, and takes
+simpler options.
+
+=back
+
+=head1 SEE ALSO
+
+L<XML::Parser>, L<XML::SAX>, L<XML::SAX::Expat>, L<XML::SAX::ExpatNB>
+
+=head1 AUTHOR
+
+Yuval Kogman <nothingmuch at woobling.org>
+
+=head1 COPYRIGHT & LICENSE
+
+ Copyright (c) 2005 Yuval Kogman. All rights reserved
+ This program is free software; you can redistribute
+ it and/or modify it under the same terms as Perl itself.
+
+=cut
Added: branches/upstream/libxml-sax-expat-incremental-perl/current/t/basic.t
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-sax-expat-incremental-perl/current/t/basic.t?rev=21555&op=file
==============================================================================
--- branches/upstream/libxml-sax-expat-incremental-perl/current/t/basic.t (added)
+++ branches/upstream/libxml-sax-expat-incremental-perl/current/t/basic.t Sun Jun 15 16:05:20 2008
@@ -1,0 +1,27 @@
+#!/usr/bin/perl
+
+# pretty much the example test from L<XML::SAX>
+
+use Test::More tests => 3;
+
+use XML::SAX;
+use XML::SAX::PurePerl::DebugHandler;
+
+XML::SAX->add_parser(q(XML::SAX::Expat::Incremental));
+
+local $XML::SAX::ParserPackage = 'XML::SAX::Expat::Incremental';
+
+isa_ok(
+ my $handler = XML::SAX::PurePerl::DebugHandler->new(),
+ "XML::SAX::PurePerl::DebugHandler",
+);
+
+isa_ok(
+ my $parser = XML::SAX::ParserFactory->parser(Handler => $handler),
+ "XML::SAX::Expat::Incremental",
+);
+
+$parser->parse_string("<tag/>");
+
+ok($handler->{seen}{start_element}, "parsed something");
+
Added: branches/upstream/libxml-sax-expat-incremental-perl/current/t/dist.t
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-sax-expat-incremental-perl/current/t/dist.t?rev=21555&op=file
==============================================================================
--- branches/upstream/libxml-sax-expat-incremental-perl/current/t/dist.t (added)
+++ branches/upstream/libxml-sax-expat-incremental-perl/current/t/dist.t Sun Jun 15 16:05:20 2008
@@ -1,0 +1,12 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More;
+
+BEGIN {
+ eval "use Test::Distribution not => 'description'";
+ plan skip_all => "Test::Distribution must be installed" if $@;
+}
+
Added: branches/upstream/libxml-sax-expat-incremental-perl/current/t/incr.t
URL: http://svn.debian.org/wsvn/branches/upstream/libxml-sax-expat-incremental-perl/current/t/incr.t?rev=21555&op=file
==============================================================================
--- branches/upstream/libxml-sax-expat-incremental-perl/current/t/incr.t (added)
+++ branches/upstream/libxml-sax-expat-incremental-perl/current/t/incr.t Sun Jun 15 16:05:20 2008
@@ -1,0 +1,78 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More tests => 16;
+use Test::Exception;
+
+use XML::SAX;
+use XML::SAX::PurePerl::DebugHandler;
+
+XML::SAX->add_parser(q(XML::SAX::Expat::Incremental));
+
+local $XML::SAX::ParserPackage = 'XML::SAX::Expat::Incremental';
+
+isa_ok(
+ my $handler = XML::SAX::PurePerl::DebugHandler->new(),
+ "XML::SAX::PurePerl::DebugHandler",
+);
+
+isa_ok(
+ my $parser = XML::SAX::ParserFactory->parser(Handler => $handler),
+ "XML::SAX::Expat::Incremental",
+);
+
+dies_ok {
+ $parser->parse_file(\*DATA)
+} "can't parse from filehandle";
+
+dies_ok {
+ $parser->parse_done;
+} "can't parse_done without having started";
+
+my @lines = <DATA>;
+
+$parser->parse_string(shift @lines);
+
+is($handler->{seen}{start_element}, 1, "parsed one elem");
+ok(!$handler->{seen}{end_element}, "nothing ended yet");
+
+dies_ok {
+ $parser->parse_start;
+} "can't start after having started";
+
+$parser->parse_string(shift @lines);
+
+is($handler->{seen}{start_element}, 3, "two elements started");
+is($handler->{seen}{end_element}, 2, "two closed");
+
+$parser->parse_string(shift @lines);
+
+is($handler->{seen}{start_element}, 4, "one more opened");
+ok($handler->{seen}{characters}, "at least some character data by now");
+is($handler->{seen}{end_element}, 3, "one more closed");
+
+my $line = shift @lines;
+
+$parser->parse_string(substr($line, 0, 3, '')); # "</x"
+
+is($handler->{seen}{end_element}, 3, "nothing closed after adding half a close tag");
+
+$parser->parse_string($line);
+
+is($handler->{seen}{end_element}, $handler->{seen}{start_element}, "root element closed");
+
+$parser->parse_done;
+
+ok($handler->{seen}{end_document}, "document ended");
+
+lives_ok {
+ $parser->parse_start;
+} "now that we're done we can start a new parse";
+
+__DATA__
+<xml>
+ <foo/><gorch/>
+ <bar>ding</bar>
+</xml>
More information about the Pkg-perl-cvs-commits
mailing list