[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: Converting Document object (DOM) into inputsource for XSL processing in XT


Subject: RE: Converting Document object (DOM) into inputsource for XSL processing in XT
From: "Maxime Levesque" <maximel@xxxxxxxxxxxxxx>
Date: Thu, 26 Aug 1999 13:20:32 -0700


  You could write a "DOM to SAX tree walker", i.e. a class
that implements org.xml.sax.Parser and that traverses a DOM
tree in pre order, and for each Element node visited : 

 1) call the 'startElement' method on the DocumentHandler

 2) visit all children elements

 3) call the 'endElement' method on the DocumentHandler

 I've started to write such a class, but I didn't
need it so it is untested, if you want the source,
send me a mail...


> Hi folks,
> 
> Currently, I'm working with DOM (SUN project X implementation) as a
> represention of my Object. As I wish to submit the source tree through
> an XSL style sheet using XT (for performance reason), I do need to
> convert the DOM object into it equivalent inputsource as expressed in
> the above java code :
> 
> ByteArrayOutputStream docOutputStream = new ByteArrayOutputStream();
> ((XmlDocument)myDOMDocument).write(docOutputStream);
> ByteArrayInputStream docInputStream = new
> ByteArrayInputStream(docOutputStream.toByteArray());
> InputSource inputSource = new InputSource(docInputStream);
> myXslProcessor.parse(inputSource);
> 
> Is there a better way to handle these opreations, since they're time
> consuming in resource and memory. 
> 
> Beside this, I tried using DOM directly with XSL:P processor, but it
> wasn't faster than XT solution, so I'm deducting that it take longer
> to work with DOM that to parse again the XML document and then work
> with it internal and lightweight representation, is it true ?
> 
> Thank for any reply, I would really appreciate.
> 
> Sebastien Sahuc
> ssahuc@xxxxxxxxxxxxxx
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords