GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
XML::Filter::Distributor(3) User Contributed Perl Documentation XML::Filter::Distributor(3)

XML::Filter::Distributor - Multipass processing of documents

version 0.46

    ## See XML::SAX::Manifold for an easier way to use this filter.

    use XML::SAX::Machines qw( Machine ) ;

    ## See the wondrous ASCII ART below for help visualizing this
    ## XML::SAX::Manifold makes this a lot easier.
    my $m = Machine(
        [ Intake => "XML::Filter::Distributor" => qw( V TOC Body ) ],
            [ V      => "My::Validator" ],
            [ TOC    => "My::TOCExtractor" => qw( Merger ) ],
            [ Body   => "My::BodyMasseuse" => 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" );

XML::Filter::Distributor is a SAX filter that allows "multipass" processing of a document by sending the document through several channels of SAX processors one channel at a time. A channel may be a single SAX processor or a machine like a pipeline (see XML::SAX::Pipeline).

This can be used to send the source document through one entire processing chain before beginning the next one, for instance if the first channel is a validator or linter that throws exceptions on error.

It can also be used to run the document through multiple processing chains and glue all of the chains' output documents back together with something like XML::Filter::Merger. The SYNOPSIS does both.

This differs from XML::Filter::SAXT in that the channels are prioritized and each channel receives all events for a document before the next channel receives any events. XML::Filter::Distributor buffers all events while feeding them to the highest priority channel ($processor1 in the synopsis), and replays them for each lower priority channel one at a time.

The event flow for the example in the SYNOPSIS would look like, with the numbers next to the connection arrow indicating when the document's events flow along that arrow.

                            +-------------+
                         +->| Validator   |
                       1/   +-------------+
                       /
          1   +-------+ 2   +--------------+ 2    +--------+      
 upstream ----| Dist. |---->| TOCExtractor |--*-->| Merger |-> STDOUT
              +-------+     +--------------+ /    +--------+   
                       \3                   /3
                        \   +--------------+
                         +->| BodyMasseuse |
                            +--------------+                         |

Here's the timing of the event flows:

   1: upstream -> Dist ->  Validator
   2:             Dist -> TOCExtractorc -> Merger -> STDOUT
   3:             Dist -> BodyMassseuse -> Merger -> STDOUT

When the document arrives from upstream, the events all arrive during time period 1 and are buffered and also passed through processor 1. After all events have been received (as indicated by an "end_document" event from upstream), all events are then played back through processor 2, and then through processor 3.

XML::Filter::Distributor - Multipass processing of documents

new
    my $d = XML::Filter::Distributor->new(
        { Handler => $h1 },
        { Handler => $h2 },
        ...
    );
    

A channel may be any SAX machine, frequently they are pipelines.

set_handlers
    $p->set_handlers( $handler1, $handler2 );
    

Provided for compatability with other SAX processors, use set_handlers instead.

set_handler
Provided for compatability with other SAX processors, use set_handlers instead.

Can only feed a single aggregator at the moment :). I can fix this with a bit of effort.

    Barrie Slaymaker <barries@slaysys.com>

    Copyright 2000, Barrie Slaymaker, All Rights Reserved.

You may use this module under the terms of the Artistic, GPL, or the BSD licenses.

  • Barry Slaymaker
  • Chris Prather <chris@prather.org>

This software is copyright (c) 2013 by Barry Slaymaker.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

Hey! The above document had some coding errors, which are explained below:
Around line 270:
You forgot a '=back' before '=head1'
2013-08-19 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.