Event::XML::Sync.3pm

Langue: en

Version: 2004-02-19 (mandriva - 01/05/08)

Section: 3 (Bibliothèques de fonctions)

NAME

Event::XML::Sync - Synchronizing XML data using module Event

SYNOPSIS

use Event::XML::Sync;

Event::XML::Sync->new( cmd => ``mytagger'',
                       twig =>  [ 
                        twig_handlers => { token => \&token_process }] 
                     );

sub token_process {
  my ($t,$token) = @_;
  my $self = $t->{sync};
  my $form = $token->att('form');
  $self->process($token,``$form\n''); }

sub XML::Twig::Elt::sync {
  my $token = shift;
  my $sync = shift;
  my $input = shift;
  my @info = split(/\t+/,$input);
  $token->set_att('tag',$info[1]);
  $sync->flush($token); }

DESCRIPTION

This module may be used to receive an XML stream analyzed by XML::Twig, using XML::Twig handlers to send bits of information to a child process, get some information back from the child process and synchronize this information within the original stream.

METHODS

The module provides an object-oriented interface as follows:

new [hash-ref]

Used to create and run an event loop, start the child process and start parsing the input stream. The function may be passed either a hash or a reference to a hash. The keys below are meaningful to the component, all others are passed to the provided callbacks.

cmd [string]
The child command.
data [Stream]
The input data (by default <>).
callbacks [hash-ref]
This hash reference contains mappings for the events the component will generate. Callers can set these values to callbacks (code references). For instance, a callback for event 'done' may be set, triggered when the child process is closed (the default done callback flush the remaining twig to output, printing the remaining XML parts).
twig [hash-ref]
This hash reference contains mapping to be sent to the Twig component (see XML::Twig).
parser
This list reference contains mapping to be sent to the XML parser (see XML::Parser).

process [closure] [in]

This method is used to send information in to the child process. Upon reception of information out returned by the child process, method sync will be called on closure with argument sync (the synchronization structure) and out.

delayed_run [closure]

The method is used to delay the execution of an action until completion of pending synchronized actions (started with method process). When there is no pending synchronized action, method run is called on closure.

AUTHOR

Eric de la Clergerie <Eric.De_La_Clergerie@inria.fr>

DATE

$Date: 2004/02/19 14:10:35 $

VERSION

$Revision: 1.2 $

POD ERRORS

Hey! The above document had some coding errors, which are explained below:
Around line 243:
'=item' outside of any '=over'
Around line 271:
You forgot a '=back' before '=head1'