Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

xml::filter::tee(3pm) [debian man page]

XML::Filter::Tee(3pm)					User Contributed Perl Documentation				     XML::Filter::Tee(3pm)

NAME
XML::Filter::Tee - Send SAX events to multiple processor, with switching SYNOPSIS
my $t = XML::Filter::Tee->new( { Handler => $h0 }, { Handler => $h1 }, { Handler => $h2 }, ... ); ## Altering the handlers list: $t->set_handlers( $h0, $h1, $h2, $h3 ); ## Controlling flow to a handler by number and by reference: $t->disable_handler( 0 ); $t->enable_handler( 0 ); $t->disable_handler( $h0 ); $t->enable_handler( $h0 ); ## Use in a SAX machine (though see L<XML::SAX::Pipeline> and ## L<XML::SAX::Tap> for a more convenient way to build a machine ## like this): my $m = Machine( [ Intake => "XML::Filter::Tee" => qw( A B ) ], [ A => ">>log.xml" ], [ B => *OUTPUT ], ); DESCRIPTION
XML::Filter::Tee is a SAX filter that passes each event it receives on to a list of downstream handlers. It's like XML::Filter::SAXT in that the events are not buffered; each event is sent first to the tap, and then to the branch (this is different from XML::SAX::Dispatcher, which buffers the events). Unlike XML::Filter::SAXT, it allows it's list of handlers to be reconfigured (via "set_handlers") and it allows control over which handlers are allowed to receive events. These features are designed to make XML::Filter::Tee instances more useful with SAX machines, but they to add some overhead relative to XML::Filter::SAXT. The events are not copied, since they may be data structures that are difficult or impossibly to copy properly, like parts of a C-based DOM implementation. This means that the handlers must not alter the events or later handlers will see the alterations. METHODS
new my $t = XML::Filter::Tee->new( { Handler => $h0 }, { Handler => $h1 }, { Handler => $h2 }, ... ); set_handlers $t->set_handlers( $h0, $h1, $h2 ); $t->set_handlers( { Handler => $h0, }, { Handler => $h1, }, ); Replaces the current list of handlers with new ones. Can also name handlers to make enabling/disabling them by name easier: $m->set_handlers( { Handler => $validator, Name => "Validator", }, { Handler => $outputer, }, ); $m->disable_handler( "Validator" ); disable_handler $t->disable_handler( 0 ); ## By location $t->disable_handler( "Validator" ); ## By name $t->disable_handler( $h0 ); ## By reference Stops sending events to the indicated handler. enable_handler $t->enable_handler( 0 ); ## By location $t->enable_handler( "Validator" ); ## By name $t->enable_handler( $h0 ); ## By reference Stops sending events to the indicated handler. AUTHOR
Barrie Slaymaker <barries@slaysys.com> COPYRIGHT
Copyright 2002, Barrie Slaymaker, All Rights Reserved You may use this module under the terms of the Artistic, GNU Public, or BSD licenses, as you choose. perl v5.10.0 2009-06-11 XML::Filter::Tee(3pm)

Check Out this Related Man Page

XML::Filter::DocSplitter(3pm)				User Contributed Perl Documentation			     XML::Filter::DocSplitter(3pm)

NAME
XML::Filter::DocSplitter - Multipass processing of documents SYNOPSIS
## See XML::SAX::???? for an easier way to use this filter. use XML::SAX::Machines qw( Machine ) ; my $m = Machine( [ Intake => "XML::Filter::DocSplitter" => qw( Filter ) ], [ Filter => "My::Filter" => qw( Merger ) ], [ Merger => "XML::Filter::Merger" => qw( Output ) ], [ Output => *STDOUT ], ); ## Let the distributor coordinate with the merger ## XML::SAX::Manifold does this for you. $m->Intake->set_aggregator( $m->Merger ); $m->parse_file( "foo" ); DESCRIPTION
XML::Filter::DocSplitter is a SAX filter that allows you to apply a filter to repeated sections of a document. It splits a document up at a predefined elements in to multiple documents and the filter is run on each document. The result can be left as a stream of separate documents or combined back in to a single document using a filter like XML::SAX::Merger. By default, the input document is split in all children of the root element. By that reckoning, this document has three sub-documents in it: <doc> <subdoc> .... </subdoc> <subdoc> .... </subdoc> <subdoc> .... </subdoc> </doc> When using without an aggregator, all events up to the first record are lost; with an aggregator, they are passed directly in to the aggregator as the "first" document. All elements between the records (the " " text nodes, in this case) are also passed directly to the merger (these will arrive between the end_document and start_document calls for each of the records), as are all events from the last record until the end of the input document. This means that the first document, as seen by the merger, is incomplete; it's missing it's end_element, which is passed later. The approach of passing events from the input document right on through to the merger differs from the way XML::Filter::Distributor works. This class is derived from XML::SAX::Base, see that for details. METHODS
new my $d = XML::Filter::DocSplitter->new( Handler => $h, Aggregator => $a, ## optional ); set_aggregator $h->set_aggregator( $a ); Sets the SAX filter that will stitch the resulting subdocuments back together. Set to "undef" to prevent such stitchery. The aggregator should support the "start_manifold_document", "end_manifold_document", and "set_include_all_roots" methods as described in XML::Filter::Merger. get_aggregator my $a = $h->get_aggregator; Gets the SAX filter that will stitch the resulting subdocuments back together. set_split_path $h->set_split_path( "/a/b/c" ); Sets the pattern to use when splitting the document. Patterns are a tiny little subset of the XPath language: Pattern Description ======= =========== /*/* splits the document on children of the root elt (default) //record splits each <record> elt in to a document /*/record splits each <record> child of the root elt /a/b/c/d splits each of the <d> elts in to a document get_split_path my $a = $h->get_split_path; LIMITATIONS
Can only feed a single aggregator at the moment :). I can fix this with a bit of effort. AUTHOR
Barrie Slaymaker <barries@slaysys.com> COPYRIGHT
Copyright 2000, Barrie Slaymaker, All Rights Reserved. You may use this module under the terms of the Artistic, GPL, or the BSD licenses. perl v5.10.0 2009-09-02 XML::Filter::DocSplitter(3pm)
Man Page