[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

Subject: RE: Converting Document object (DOM) into inputsource for XSL process ing in XT
From: "Maxime Levesque" <maximel@xxxxxxxxxxxxxx>
Date: Fri, 27 Aug 1999 10:20:20 -0700
domsource to inputsource
 The better approach is to use John Cowan's DOMParser

 (http://www.ccil.org/~cowan/XML/) (* thanks for the link Michael)


  InputSource domSource = new org.ccil.cowan.sax.DOMSource(yourDocument);

  Parser inputParser = new org.ccil.cowan.sax.DOMParser();

  Parser sheetParser = "... your favorite XML parser ...";

  XSLProcessorImpl xt = new XSLProcessorImpl();

  xt.setParser(inputParser, sheetParser);

  xt.parse(domSource);


 This will avoid the unnecessary 'flattening' and parsing.



> Do you mean that for small document (less than 10Kb), it's faster to
> transform DOM into byte[] and then reparse it  ? Did I understand
> well?

  Flattening the DOM tree onto byte[]s and reparsing it will always
be costly, what Dan was suggesting was to 'pipe' :

 (1)  DOM -> DOMWriter -> InputStreamWriter -> PipedOutputStream ->
PipedInputStream -> SAXParser

instead of  :

 (2)

  flattening :

  DOM -> DOMWriter -> InputStreamWriter -> byte[]

  and then inflating :

  byte[] -> ByteArrayInputStream -> SAXParser

  in two separate steps.

 (1) has the advantage of being memory efficient (the memory usage is the
size
     of the PipedInputStream's buffer).

  The overhead of (1) is that there is a that the threads are 'waiting' and
'notifying'
  a lot, but for big enough documents (2) will bust your memory.


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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.