Beefy Boxes and Bandwidth Generously Provided by pair Networks Bob
Problems? Is your data what you think it is?
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

As Matt mentioned, XML::SAX::ByRecord from the XML::SAX::Machines distribution might be useful here. Make sure you get at least XML-SAX-Machines-0.31, I fixed a bug in X::S::ByRecord to get this example working <:-/>.

ByRecord is designed for handling record oriented XML files one record at a time. It splits the document apart in to individual documents, one per record, and runs them through a pipeline of SAX processors, merging the resulting subdocuments back in to the body of the output document. Everything that's not a record is passed through verbatim. This should make things a bit easier on the old memory banks, reduce time to first output, and make it possible to use simpler stylesheets.

Here's a recipe that might get you started. It copys only the <state> records through to the output (the StateML file I fed it has several different record types). Feel free to email me and/or the perl-xml list if you have questions.

use XML::SAX::Machines 0.31; use XML::SAX::Machines qw( Pipeline ByRecord Tap ); use XML::Filter::XSLT; my $f =XML::Filter::XSLT->new( Source => { ByteStream => \*DATA } ); Pipeline( ByRecord( $f ), \*STDOUT )->parse_uri( $ARGV[0] ); ## "in-place upgrades" until some new releases hit CPAN ;) use IO::Handle; ## XML::LibXML needs this to read from DATA ## and this makes XML::Filter::XSLT machine compliant sub XML::Filter::XSLT::LibXSLT::set_handler { my $self = shift; $self->{Handler} = shift; $self->{Parser}->set_handler( $self->{Handler} ) if $self->{Parser}; } __END__ <xslt:transform version="1.0" xmlns:xslt="http://www.w3.org/1999/XSL/Transform" > <xslt:template match="state"> <xslt:copy-of select="."/> </xslt:template> </xslt:transform>

In reply to use XML::SAX::Machines qw( ByRecord ) Was: Mega XSLT Batch job - best approach? by Anonymous Monk
in thread Mega XSLT Batch job - best approach? by ajt

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others scrutinizing the Monastery: (8)
    As of 2014-04-17 02:42 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      April first is:







      Results (437 votes), past polls