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
[ANNOUNCE] XML::Filter::Merger: Easier merging yet...
by Barrie Slaymaker other posts by this author
Sep 6 2002 2:31PM messages near this date
view in the new Beta List Site
RE: XML::Schema, anyone? | weired XML::LibXML bug
XML-SAX-Machines v0.38 provides a merger that lets you do:

    $h-> start_document( {} );
    $h-> start_element( { Name => "foo1" } );
    $p-> parse_string( "<foo2><baz /></foo2>" );
    $h-> end_element( { Name => "foo1" } );
    $h-> end_document( {} );

to get:

    <foo1> <baz /></foo1>} ;

and, more importantly for my needs, you can subclass it to build in
your own XInclude-like functionality:

    package Subclass;

    use vars qw( @ISA );

    @ISA = qw( XML::Filter::Merger );

    sub characters {
        my $self = shift;

        my $r = $self-> SUPER::characters( @_ );

        $self-> set_include_all_roots( 1 );

        XML::SAX::PurePerl-> new( Handler => $self )->parse_string( "<hey/>" );
        return $r;
    }

    1;

That inserts a "<hey /> " after each characters() event.  Useless, but it
should give you the idea.

- Barrie
_______________________________________________
Perl-XML mailing list
Perl-XML@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

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