/usr/share/perl5/XML/SAX/Pipeline.pm is in libxml-sax-machines-perl 0.46-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 | package XML::SAX::Pipeline;
{
$XML::SAX::Pipeline::VERSION = '0.46';
}
# ABSTRACT: Manage a linear pipeline of SAX processors
use base qw( XML::SAX::Machine );
use strict;
use Carp;
sub new {
my $proto = shift;
my $options = @_ && ref $_[-1] eq "HASH" ? pop : {};
my $stage_number = 0;
my @machine_spec = map [ "Stage_" . $stage_number++, $_ ], @_;
push @{$machine_spec[$_]}, $_ + 1 for 0..$#machine_spec-1 ;
$machine_spec[0]->[0] = "Intake" if @machine_spec;
push @{$machine_spec[-1]}, "Exhaust" if @machine_spec;
return $proto->SUPER::new( @machine_spec, $options );
}
1;
__END__
=pod
=head1 NAME
XML::SAX::Pipeline - Manage a linear pipeline of SAX processors
=head1 VERSION
version 0.46
=head1 SYNOPSIS
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( "<infile.txt" );
my $m = Pipeline( "spew_xml |" );
## To send output to a file handle, file, or process:
my $m = Pipeline( ..., \*STDOUT );
my $m = Pipeline( ..., ">outfile.txt" );
my $m = Pipeline( ..., "| xmllint --format -" );
=head1 DESCRIPTION
An XML::SAX::Pipeline is a linear sequence SAX processors. Events
passed to the pipeline are received by the C<Intake> end of the pipeline
and the last filter to process events in the pipeline passes the events
out the C<Exhaust> to the filter set as the pipeline's handler:
+-----------------------------------------------------------+
| An XML:SAX::Pipeline |
| Intake |
| +---------+ +---------+ +---------+ Exhaust |
--+-->| Stage_0 |--->| Stage_1 |-->...-->| Stage_N |----------+----->
| +---------+ +---------+ +---------+ |
+-----------------------------------------------------------+
As with all SAX machines, a pipeline can also create an ad hoc parser
(using L<XML::SAX::ParserFactory>) if you ask it to parse something and
the first SAX processer in the pipeline can't handle a parse request:
+-------------------------------------------------------+
| An XML:SAX::Pipeline |
| Intake |
| +--------+ +---------+ +---------+ Exhaust |
| | Parser |-->| Stage_0 |-->...-->| Stage_N |----------+----->
| +--------+ +---------+ +---------+ |
+-------------------------------------------------------+
or if you specify an input file like so:
my $m = Pipeline(qw(
<input_file.xml
XML::Filter::Bar
XML::Filter::Baz
));
Pipelines (and machines) can also create ad hoc XML::SAX::Writer
instances when you specify an output file handle (as shown in the
SYNOPSIS) or an output file:
my $m = Pipeline(qw(
XML::Filter::Bar
XML::Filter::Baz
>output_file.xml
));
And, thanks to Perl's magic open (see L<perlopentut>), you can read
and write from processes:
my $m = Pipeline(
"gen_xml.pl |",
"XML::Filter::Bar",
"XML::Filter::Baz",
"| consume_xml.pl",
);
This can be used with an L<XML::SAX::Tap> to place a handy debugging
tap in a pipeline (or other machine):
my $m = Pipeline(
"<input_file.xml"
"XML::Filter::Bar",
Tap( "| xmllint --format -" ),
"XML::Filter::Baz",
">output_file.xml",
);
=head1 NAME
XML::SAX::Pipeline - Manage a linear pipeline of SAX processors
=head1 METHODS
See L<XML::SAX::Machine> for most of the methods.
=over
=item new
my $pipeline = XML::SAX::Pipeline->new( @processors, \%options );
Creates a pipeline and links all of the given processors together. Longhand
for Pipeline().
=back
=head1 AUTHOR
Barrie Slaymaker <barries@slaysys.com>
=head1 COPYRIGHT
Copyright 2002, Barrie Slaymaker, All Rights Reserved.
You may use this module under the terms of the Artistic, GNU Public,
or BSD licenses, your choice.
=head1 AUTHORS
=over 4
=item *
Barry Slaymaker
=item *
Chris Prather <chris@prather.org>
=back
=head1 COPYRIGHT AND LICENSE
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.
=cut
|