ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> perl-xml
perl-xml
Re: [ANNOUNCE] XML::SAX::2Simple
by Barrie Slaymaker other posts by this author
Jan 16 2002 4:56PM messages near this date
view in the new Beta List Site
RE: [ANNOUNCE] XML::SAX::2Simple | RE: [ANNOUNCE] XML::SAX::2Simple
On Wed, Jan 16, 2002 at 09:20:38AM -0000, Grant McLean wrote:
>  
>  This is all within XML::Simple.pm with no requirement for extra module
>  namespace.

Very cool :).  Two feature requests are:

1. Allow a data handler like the "DataHandler" shown in the announe for
2Simple.  Since SAX is about event processing, it makes sense to be able
to fire off events (sub calls) when Simple builds an object (see
examples below).

2. Allow a that handler to reemit the object as a new XML document via
SAX, sorta like this:

    my $h = XML::Handler::Foo-> new();

    my $xp = XML::Simple-> new(
        Handler =>  $h,
        DataHandler =>  sub {
            my ( $simple, $ref ) = @_;
            
            ....do something to / with $ref-> ...

            $simple-> XMLOut( $ref );
        },
    );

    $p = XML::SAX::ParserFactory-> parser( Handler => $xp );

That would be quite powerful.  Hmmm, if you provide a set_handler()
method like XML::SAX::Base's (assuming you're not already subclassing it
to leverage its various event passing features), then this becomes a
neat way to transmogrify record oriented XML:

    ByRecord(
        XML::Simple-> new(
            DataHandler =>  sub {
            my ( $simple, $ref ) = @_;
            
            ....do something to / with $ref-> ...

            $simple-> XMLOut( $ref );
            },
        ),
        \*STDOUT
    )-> parse( \*STDIN );

or plain ol' XML:

    Pipeline(
        XML::Simple-> new(
            DataHandler =>  sub {
            my ( $simple, $ref ) = @_;
            
            ....do something to / with $ref-> ...

            $simple-> XMLOut( $ref );
            },
        ),
        \*STDOUT
    )-> parse( \*STDIN );

I'd love to retire XML::Handler::2Simple in favor of the forthcoming
XML::Simple.

Sincerely yours in feeping creaturitus,

Barrie
_______________________________________________
Perl-XML mailing list
Perl-XML@[...].com
http://listserv.ActiveState.com/mailman/listinfo/perl-xml
Thread:
Grant McLean
Barrie Slaymaker

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved