xom-interest AT lists.ibiblio.org
Subject: XOM API for Processing XML with Java
List archive
Re: [XOM-interest] XSLTransform constructors are flawed
- From: Elliotte Rusty Harold <elharo AT metalab.unc.edu>
- To: xom-interest AT lists.ibiblio.org
- Subject: Re: [XOM-interest] XSLTransform constructors are flawed
- Date: Sat, 4 Sep 2004 07:50:39 -0400
At 7:07 AM -0400 9/4/04, Elliotte Rusty Harold wrote:
Last night I realized another reason to deprecate and eliminate the last four of these constructors. Each one of them creates anew Builder object. This is potentially quite an expensive operation. Whether it's expensive relative to compiling the stylesheet and running the transform depends on local circumstances, but in at least some circumstances it makes a lot more sense to reuse a builder if possible, rather than creating a new underlying XMLReader for each separate document.
And now that I've looked at the code rather than relying on my faulty imaginings of how this class works, I'm realizing I was 100% wrong. In fact I may have this all exactly backwards.
The XSLTransform constructor does not call new Builder(). Instead it just passes the Reader/InputStream/File/URL straight into TrAX which does whatever it does with it (presumably including parsing the stylesheet.) That still might involve loading an XMLReader. However, creating a Document object with a Builder does not avoid this problem!
When a Document object is passed to an XSLTransform constructor it is written into a StringBuffer which is then passed to TrAX as a StringReader. Thus it gets parsed twice. In any case, it is more efficient just to pass in the Reader/InputStream/File/URL rather than a Document.
Now that I look at this I recall it was a quick hack to get something working, that I always intended to revisit and fix later. Perhaps later is now. I need to explore this further, and see if there's some way I can eliminate the reserialization and double parse from the XSLTransform(Document) constructor.
In the meantime, I don't want to deprecate the File and URL constructors since they are noticeably better than the Document constructor. I do still want to deprecate the InputStream and Reader constructors for the initial reasons cited earlier (they don't allow relative URLs to be resolved) but I think I should replace them with ones that add a second argument for the base URL.
Anyway, that's what I'm thinking now. If I can figure out how to avoid the double parse in the XSLTransform(Document) constructor I may change this again; but at least two of the constructors are sticking around for the time being.
--
Elliotte Rusty Harold
elharo AT metalab.unc.edu
Effective XML (Addison-Wesley, 2003)
http://www.cafeconleche.org/books/effectivexml
http://www.amazon.com/exec/obidos/ISBN%3D0321150406/ref%3Dnosim/cafeaulaitA
-
[XOM-interest] XSLTransform constructors are flawed,
Elliotte Rusty Harold, 09/01/2004
-
Re: [XOM-interest] XSLTransform constructors are flawed,
John Cowan, 09/01/2004
-
Re: [XOM-interest] XSLTransform constructors are flawed,
Elliotte Rusty Harold, 09/04/2004
- Re: [XOM-interest] XSLTransform constructors are flawed, John Cowan, 09/04/2004
-
Re: [XOM-interest] XSLTransform constructors are flawed,
Elliotte Rusty Harold, 09/04/2004
-
Re: [XOM-interest] XSLTransform constructors are flawed,
Elliotte Rusty Harold, 09/04/2004
-
Re: [XOM-interest] XSLTransform constructors are flawed,
Elliotte Rusty Harold, 09/04/2004
-
Re: [XOM-interest] XSLTransform constructors are flawed,
John Cowan, 09/04/2004
- Re: [XOM-interest] XSLTransform constructors are flawed, Elliotte Rusty Harold, 09/04/2004
-
Re: [XOM-interest] XSLTransform constructors are flawed,
John Cowan, 09/04/2004
-
Re: [XOM-interest] XSLTransform constructors are flawed,
Elliotte Rusty Harold, 09/04/2004
- <Possible follow-up(s)>
- RE: [XOM-interest] XSLTransform constructors are flawed, McEniry, Michael, 09/04/2004
-
Re: [XOM-interest] XSLTransform constructors are flawed,
John Cowan, 09/01/2004
Archive powered by MHonArc 2.6.24.