Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

munging xml to transformit with xsl

by morfeas (Novice)
on Feb 08, 2005 at 08:52 UTC ( #428964=perlquestion: print w/replies, xml ) Need Help??
morfeas has asked for the wisdom of the Perl Monks concerning the following question:

Dear all, is there any knowledge on how to munge a huge XML, process it using xsl, without the need to load all the XML to mem? The objective is to be able to use Sablotron in order to xslt very large xmls, with time optimisation. How come the xslt cannot read only parts of xml, transfom them and continue?

Replies are listed 'Best First'.
Re: munging xml to transformit with xsl
by gellyfish (Monsignor) on Feb 08, 2005 at 10:09 UTC

    Unfortunately an XSLT processor will almost certaoinly always need to be in memory an per the XSLT 1.0 Spec "The data model used by XSLT is the same as that used by XPath.." and XPath says: "XPath operates on an XML document as a tree.". Having a tree structure would imply the requirement of having the entire parsed document in memory.


Re: munging xml to transformit with xsl
by rg0now (Chaplain) on Feb 08, 2005 at 15:03 UTC
    As noone has pointed it out before, I have to call your attention to SAX (Simple API for XML). SAX is an alternative to DOM specially crafted to inetrpret huge XML files.

    On the one hand, it gives you a pretty simple API to work on XML files abstracting them as streams thus avoiding the need to load the entire DOM tree into memory. On the other hand, it does not give you the full power of XSLT and most of the programmers (quite sincerely, I am amongst them) find it a bit hard to work with its event-driven interface as compared to the good old DOM-style tree-model.

    However, if your transformations needed to be applied to your largish XML file are not overly difficult, then you definitely should consider rewriting your XSLT transformations as simple SAX-based scripts (see for example XML::LibXML::SAX for a good SAX parser for Perl).


Re: munging xml to transformit with xsl
by perlsen (Chaplain) on Feb 08, 2005 at 09:09 UTC


    Did u try, the folowing modules


    it can transform for ur requirement

      XML::XSLT will be more memory and processor intensive than the others because it is all Perl.


Re: munging xml to transformit with xsl
by Solo (Deacon) on Feb 08, 2005 at 14:31 UTC
    How come the xslt cannot read only parts of xml, transfom them and continue?

    Why not divide the XML document into 'acceptably' sized chunks and feed those to Sablotron?


    You said you wanted to be around when I made a mistake; well, this could be it, sweetheart.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://428964]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2017-11-19 05:55 GMT
Find Nodes?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:

    Results (278 votes). Check out past polls.