README for XML-SAX-Machines

XML::SAX::Machines is a collection of APIs that allow complex SAX machines to be constructed without a huge amount of extra typing.

This distribution contains three kinds of modules: machines, helpers, and filters. Here's how they are laid out:

All of the XML::Filter::* classes are useful outside of the machines that use them. For instance, XML::Filter::DocSplitter has been used (not by me) in a Pipeline to split a huge record oriented file in to individual files containing single records (using a custom class derived from XML::SAX::Writer). XML::Filter::Merger is useful as a general way to implement <XInclude> style processing when XInclude is not a good fit.

See the examples/ directory for, well, examples (and feel free to write up creative examples, eventually I'd like to compile a cookbook).

To give a more concrete idea of how SAX machines are typically used, here's how to build a pipeline of SAX processors:

use XML::SAX::Machines qw( Pipeline ); use My::SAX::Filter2;

my $p = Pipeline(

        "My::SAX::Filter1",
        My::SAX::Filter2->new( ... ),
        \$output

);

$p->parse_uri( $ARGV[0] );

That loads (if need be) XML::SAX::Writer and calls it's new() function with an Output => \$output option, calls the passed-in instance of XML::SAX::Filter2 and calls its set_handler() method to point it to the XML::SAX::Writer that was just created, and then loads (if need be) My::SAX::Filter1 and calls it's new() function with a Handler => option pointing to the XML::SAX::Filter2 instance.