XML::Filter::Cache - a SAX2 recorder/playback mechanism
use XML::SAX; use XML::Filter::Cache; use XML::SAX::Writer; my $writer = XML::SAX::Writer->new; my $filter = XML::Filter::Cache->new( Handler => $writer, Key => "foo.xml", ); my $parser = XML::SAX::ParserFactory->new(Handler => $filter); $parser->parse_uri("foo.xml"); # caches $filter->playback; # un-caches
This is a very simple filter module for SAX2 events. By default it caches events into a big binary file on disk (the cache files are generally much larger than the original XML at the moment, but I'll work on that), but the storage backend is pluggable. It uses Storable to do the freeze/thaw thing, and at the moment this is not pluggin replaceable, simply because there's no better tool for the task at hand.
There's only one method you need to remember:
playback, which will play the SAX events to the Handler from the cache.
Key parameter to new() is optional - however if you do not supply it, your parser must call set_document_locator so that XML::Filter::Cache can pick up a
Key from the SystemId value.
This is free software, you may use it under the same terms as Perl itself.
Matt Sergeant, firstname.lastname@example.org. Please send all bugs to rt.cpan.org, either via the web interface, or by emailing bug-XML-Filter-Cache@rt.cpan.org