.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "XML::SAX::Pipeline 3pm" .TH XML::SAX::Pipeline 3pm "2020-12-29" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" XML::SAX::Pipeline \- Manage a linear pipeline of SAX processors .SH "VERSION" .IX Header "VERSION" version 0.46 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 2 \& use XML::SAX::Machines qw( Pipeline ); ## Most common way \& use XML::Fitler::Foo; \& \& my $m = Pipeline( \& XML::Filter::Foo\->new, ## Create it manually \& "XML::Filter::Bar", ## Or let Pipeline load & create it \& "XML::Filter::Baz", \& { \& ## Normal options \& Handler => $h, \& } \& ); \& \& ## To choose the default parser automatically if XML::Filter::Foo \& ## does not implement a parse_file method, just pretend the Pipeline \& ## is a parser: \& $m\->parse_file( "blah" ); \& \& ## To feed the pipeline from an upstream processor, treat it like \& ## any other SAX filter: \& my $p = Some::SAX::Generator\->new( Handler => $m ); \& \& ## To read a file or the output from a subprocess: \& my $m = Pipeline( "outfile.txt" ); \& my $m = Pipeline( ..., "| xmllint \-\-format \-" ); .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" An XML::SAX::Pipeline is a linear sequence \s-1SAX\s0 processors. Events passed to the pipeline are received by the \f(CW\*(C`Intake\*(C'\fR end of the pipeline and the last filter to process events in the pipeline passes the events out the \f(CW\*(C`Exhaust\*(C'\fR to the filter set as the pipeline's handler: .PP .Vb 7 \& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ \& | An XML:SAX::Pipeline | \& | Intake | \& | +\-\-\-\-\-\-\-\-\-+ +\-\-\-\-\-\-\-\-\-+ +\-\-\-\-\-\-\-\-\-+ Exhaust | \& \-\-+\-\->| Stage_0 |\-\-\->| Stage_1 |\-\->...\-\->| Stage_N |\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-> \& | +\-\-\-\-\-\-\-\-\-+ +\-\-\-\-\-\-\-\-\-+ +\-\-\-\-\-\-\-\-\-+ | \& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ .Ve .PP As with all \s-1SAX\s0 machines, a pipeline can also create an ad hoc parser (using XML::SAX::ParserFactory) if you ask it to parse something and the first \s-1SAX\s0 processer in the pipeline can't handle a parse request: .PP .Vb 7 \& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ \& | An XML:SAX::Pipeline | \& | Intake | \& | +\-\-\-\-\-\-\-\-+ +\-\-\-\-\-\-\-\-\-+ +\-\-\-\-\-\-\-\-\-+ Exhaust | \& | | Parser |\-\->| Stage_0 |\-\->...\-\->| Stage_N |\-\-\-\-\-\-\-\-\-\-+\-\-\-\-\-> \& | +\-\-\-\-\-\-\-\-+ +\-\-\-\-\-\-\-\-\-+ +\-\-\-\-\-\-\-\-\-+ | \& +\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-+ .Ve .PP or if you specify an input file like so: .PP .Vb 5 \& my $m = Pipeline(qw( \& output_file.xml \& )); .Ve .PP And, thanks to Perl's magic open (see perlopentut), you can read and write from processes: .PP .Vb 6 \& my $m = Pipeline( \& "gen_xml.pl |", \& "XML::Filter::Bar", \& "XML::Filter::Baz", \& "| consume_xml.pl", \& ); .Ve .PP This can be used with an XML::SAX::Tap to place a handy debugging tap in a pipeline (or other machine): .PP .Vb 7 \& my $m = Pipeline( \& "output_file.xml", \& ); .Ve .SH "NAME" XML::SAX::Pipeline \- Manage a linear pipeline of SAX processors .SH "METHODS" .IX Header "METHODS" See XML::SAX::Machine for most of the methods. .IP "new" 4 .IX Item "new" .Vb 1 \& my $pipeline = XML::SAX::Pipeline\->new( @processors, \e%options ); .Ve .Sp Creates a pipeline and links all of the given processors together. Longhand for \fBPipeline()\fR. .SH "AUTHOR" .IX Header "AUTHOR" .Vb 1 \& Barrie Slaymaker .Ve .SH "COPYRIGHT" .IX Header "COPYRIGHT" .Vb 1 \& Copyright 2002, Barrie Slaymaker, All Rights Reserved. .Ve .PP You may use this module under the terms of the Artistic, \s-1GNU\s0 Public, or \s-1BSD\s0 licenses, your choice. .SH "AUTHORS" .IX Header "AUTHORS" .IP "\(bu" 4 Barry Slaymaker .IP "\(bu" 4 Chris Prather .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" This software is copyright (c) 2013 by Barry Slaymaker. .PP This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.