Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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?

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

    Hi,

    Did u try, the folowing modules

      XML::XSLT
      XML::Sablotron
      XML::LibXSLT
      XML::LibXML

    it can transform for ur requirement

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

      /J\

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.

    /J\

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?

    --Solo

    --
    You said you wanted to be around when I made a mistake; well, this could be it, sweetheart.
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).

    rg0now

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://428964]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (10)
As of 2014-07-30 06:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (229 votes), past polls