[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: Converting Document object (DOM) into inputsource for XS
My experiments with piping streams is that unless the size of your stream is too big for your memory, your the performance is better when shoving it in a byte array... > Have you looked at using the PipedInputStream and PipedOutputStream > combination? To gain the advantage, you would need to have two Threads. > The first thread would create a PipedOutputStream and write your > DOM document > to the stream. The second thread would create a PipedInputStream, > using the > previously created PipedOutputStream in the constructor. > > The advantage is you avoid having to convert the whole DOM tree > to a byte array > before sending it off to the the XSL processor. With the piped > streams, the XSL > processor could start processing the XML before the DOM tree is fully > converted. > > What I don't know is if the overhead of spawning a new Thread is > worse than > creating the byte arrary. As the file gets larger however, the > piped streams > would have more of an advantage. > > The code would look something like this. > > PipedOutputStream pipeOut = new PipedOutputStream(); > DOMWriter dw = new DOMWriter(pipeOut, (XmlDocument)myDOMDocument); > dw.start(); > PipedInputStream pipeIn = new PipedInputStream(pipeOut); > InputSource inputSource = new InputSource(pipeIn); > myXslProcessor.parse(inputSource); > > public class DOMwriter extends Thread { > OutputStream mOut; > XmlDocument mDoc; > DOMwriter(OutputStream out, XmlDocument doc) { > mOut = out; > mDoc = doc; > } > public void run() { > mDoc.write(mOut); > } > } > > > > > 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 > >-- End of excerpt from Sebastien Sahuc > > Dan > > -- > <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> > <> Dan Machak <> machak@xxxxxxxxxxxx <> > <> MS T27A-1 <> 650-604-2388 (VOICE) <> > <> NASA Ames Research Center <> 650-604-3957 (FAX) <> > <> Moffett Field, CA 94035-1000 <> <> > <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> > > > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list > XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|