XML::S...peline(3pm)

πŸ“¦
version 0.46 Β· 2 versions
  • 0.46 Β· debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking (latest)
  • 0.46 Β· ubuntu jammy
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

XML::SAX::Pipeline β€” Manage a linear pipeline of SAX processors

okay so this is the page for XML::SAX::Pipeline, straight out of the User Contributed Perl Documentation corner of the world. Say hi to your new bestie for gluing SAX processors together in a little line πŸ’…


✨ VERSION ✨

version 0.46 β€” she's been around a minute and she's still iconic 🫢


🌸 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 -" );

literally every way you'd ever wanna wire one up, all in one place. obsessed 😭


πŸ¦‹ DESCRIPTION πŸ¦‹

So an XML::SAX::Pipeline is a linear sequence of SAX processors. Events get handed to the "Intake" end of the pipeline, and the last filter in the line β€” the one that's actually processing events β€” pushes them out the "Exhaust" end, straight to whatever filter is set as the pipeline's handler. it's giving assembly line but make it XML ✨

   +-----------------------------------------------------------+
   |                 An XML:SAX::Pipeline                      |
   |    Intake                                                 |
   |   +---------+    +---------+         +---------+  Exhaust |
 --+-->| Stage_0 |--->| Stage_1 |-->...-->| Stage_N |----------+----->
   |   +---------+    +---------+         +---------+          |
   +-----------------------------------------------------------+

Same energy as all SAX machines, bestie: a pipeline can also spin up an ad hoc parser (it uses XML::SAX::ParserFactory) if you ask it to parse something and the very 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 just hand it an input file like this:

    my $m = Pipeline(qw(
        <input_file.xml
        XML::Filter::Bar
        XML::Filter::Baz
    ));

Pipelines (and machines, hi) can also make ad hoc XML::SAX::Writer instances when you specify an output file handle (peep the SYNOPSIS, it's right there) or an output file:

    my $m = Pipeline(qw(
        XML::Filter::Bar
        XML::Filter::Baz
        >output_file.xml
    ));

And thanks to Perl's magic open (go read perlopentut, it's a whole vibe), you can read and write from processes:

    my $m = Pipeline(
        "gen_xml.pl |",
        "XML::Filter::Bar",
        "XML::Filter::Baz",
        "| consume_xml.pl",
    );

This plays so nicely with an XML::SAX::Tap if you wanna drop a handy lil debugging tap into a pipeline (or any other machine, she's not picky):

    my $m = Pipeline(
        "<input_file.xml"
        "XML::Filter::Bar",
        Tap( "| xmllint --format -" ),
        "XML::Filter::Baz",
        ">output_file.xml",
    );

πŸ’œ NAME πŸ’œ

XML::SAX::Pipeline β€” Manage a linear pipeline of SAX processors

(yes bestie, she said it again. the original said it twice, so we said it twice. no notes πŸ’€)


πŸŽ€ METHODS πŸŽ€

Most of the methods live over in XML::SAX::Machine, so go say hey to that page for the full menu. Here's the one that's actually here:

✨ new ✨

        my $pipeline = XML::SAX::Pipeline->new( @processors, \%options );

Creates a pipeline and links all of the given processors together. This is the longhand version of Pipeline(). Same thing, just written out all proper-like πŸ‘‘


πŸ‘‘ AUTHOR πŸ‘‘

    Barrie Slaymaker <barries@slaysys.com>

    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, pick your fighter 🫢


🌈 AUTHORS 🌈

  • 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.


and that's the whole page, bestie πŸŽ€ she ships as perl v5.34.0, dated 2022-06-28, and she lives under the name XML::S...peline(3pm) β€” go forth and pipeline, mwah πŸ’–βœ¨
πŸ“¦ where this page comes from