| 1 | #!/usr/bin/perl | ||
| 2 | package SOAP::WSDL::Expat::MessageStreamParser; | ||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | use XML::Parser::Expat; | ||
| 6 | use SOAP::WSDL::Expat::MessageParser; | ||
| 7 | use base qw(SOAP::WSDL::Expat::MessageParser); | ||
| 8 | |||
| 9 | our $VERSION = 3.004; | ||
| 10 | |||
| 11 | sub parse_start { | ||
| 12 | my $self = shift; | ||
| 13 | $self->{ parser } = $_[0]->_initialize( XML::Parser::ExpatNB->new( Namespaces => 1 ) ); | ||
| 14 | } | ||
| 15 | sub init; | ||
| 16 | *init = \&parse_start; | ||
| 17 | |||
| 18 | sub parse_more { | ||
| 19 | $_[0]->{ parser }->parse_more( $_[1] ); | ||
| 20 | } | ||
| 21 | |||
| 22 | sub parse_done { | ||
| 23 | $_[0]->{ parser }->parse_done(); | ||
| 24 | $_[0]->{ parser }->release(); | ||
| 25 | } | ||
| 26 | |||
| 27 | 1; | ||
| 28 | |||
| 29 | =pod | ||
| 30 | |||
| 31 | =head1 NAME | ||
| 32 | |||
| 33 | SOAP::WSDL::Expat::MessageStreamParser - Convert SOAP messages to custom object trees | ||
| 34 | |||
| 35 | =head1 SYNOPSIS | ||
| 36 | |||
| 37 | my $lwp = LWP::UserAgent->new(); | ||
| 38 | |||
| 39 | my $parser = SOAP::WSDL::Expat::MessageParser->new({ | ||
| 40 | class_resolver => 'My::Resolver' | ||
| 41 | }); | ||
| 42 | my $chunk_parser = $parser->init(); | ||
| 43 | # process response while it comes in, trying to read 32k chunks. | ||
| 44 | $lwp->request( $request, sub { $chunk_parser->parse_more($_[0]) } , 32468 ); | ||
| 45 | $chunk_parser->parse_done(); | ||
| 46 | |||
| 47 | my $obj = $parser->get_data(); | ||
| 48 | |||
| 49 | =head1 DESCRIPTION | ||
| 50 | |||
| 51 | ExpatNB based parser for parsing huge documents. | ||
| 52 | |||
| 53 | See L<SOAP::WSDL::Manual::Parser> for details. | ||
| 54 | |||
| 55 | =head1 Bugs and Limitations | ||
| 56 | |||
| 57 | See SOAP::WSDL::Expat::MessageParser | ||
| 58 | |||
| 59 | =head1 AUTHOR | ||
| 60 | |||
| 61 | Martin Kutter E<lt>martin.kutter fen-net.deE<gt> | ||
| 62 | |||
| 63 | =head1 LICENSE AND COPYRIGHT | ||
| 64 | |||
| 65 | Copyright 2007 Martin Kutter. | ||
| 66 | |||
| 67 | This file is part of SOAP-WSDL. You may distribute/modify it under | ||
| 68 | the same terms as perl itself | ||
| 69 | |||
| 70 | =head1 REPOSITORY INFORMATION | ||
| 71 | |||
| 72 | $Rev: 851 $ | ||
| 73 | $LastChangedBy: kutterma $ | ||
| 74 | $Id: MessageStreamParser.pm 851 2009-05-15 22:45:18Z kutterma $ | ||
| 75 | $HeadURL: https://soap-wsdl.svn.sourceforge.net/svnroot/soap-wsdl/SOAP-WSDL/trunk/lib/SOAP/WSDL/Expat/MessageStreamParser.pm $ | ||
| 76 | |||
| 77 | =cut |