XML::SAX::ByRecord can record oriented processing of (data) documents.
use XML::SAX::Machines qw( ByRecord ) ;
my $m = ByRecord(
Handler => $h, ## optional
$m->parse_uri( "foo.xml" );
XML::SAX::ByRecord is a SAX machine that treats a document as a series of records. Everything before and after the records is emitted as-is while the records are excerpted in to little mini-documents and run one at a time through the filter pipeline contained in ByRecord.
The output is a document that has the same exact things before, after, and between the records that the input document did, but which has run each record through a filter. So if a document has 10 records in it, the per-record filter pipeline will see 10 sets of ( start_document, body of record, end_document ) events. An example is below.
This has several use cases:
┬· Big, record oriented documents
Big documents can be treated a record at a time with various DOM oriented processors like XML::Filter::XSLT.
┬· Streaming XML
Small sections of an XML stream can be run through a document processor without holding up the stream.
┬· Record oriented style sheets / processors
Sometimes it's just plain easier to write a style sheet or ┬· SAX filter that applies to a single record at at time, rather than having to run through a series of records.