[jdom-interest] JDOM->Xalan question

Shaun Smith shauns at pixology.com
Thu Mar 1 03:41:53 PST 2001


I think that the most efficient way of talking to Xalan is to
send SAX events directly to its handler, using SAXOutputter.  Thanks
to everyone who worked on that for JDOM-B6 by the way!
Doing it that way should cause the least performance penalty;
JDOM->DOM->Transform
is definitely heavier (on memory at least) than JDOM->SAX->Transform.
Use it like this:
	obtain TransformerHandler from Xalan
	Create new SAXOutputter, pass the TransformerHandler in constructor
	Set a destination for the result from TransformerHandler
	Call the SAXOutputter.output( Document ) method

Shaun.



-----Original Message-----
From: Eric Rosenberg [mailto:eric at computerwizards.com]
Sent: 01 March 2001 05:54
To: jdom-interest at jdom.org
Subject: [jdom-interest] JDOM->Xalan question


Hi,

I'm implementing an application where I need to build a XML document in
memory, then apply an XSL transform to it and return the resulting
document. My current implementation builds the XML document as a big
String, this String is then passed to Xerces/Xalan for
parsing/transform, and the result is turned into a String and returned.

This has proven to be a less then ideal for several reasons. Instead of
a big String I would like to build the XML document directly in memory
and then apply the transform to it. My thought is that doing this would
potentially save me the step of parsing the string that I am
constructing, since the XML document would already be a DOM object.

I recently ran across JDOM while reading Java World and it occurred to
me that this may be a good fit for my problem. My idea was to build the
document in memory using JDOM and then feed it to Xalan to do the
transform. The API for building the document seems a lot simpler using
JDOM then trying to build it as a straight DOM object. However, I was
curious as to how much of a performance penalty, if any, I am going to
incur by building a JDOM Document in memory, and then transforming it
into a DOM object instead of just building the DOM object directly.

I am also curious as to what is the most efficient mechanism to
implement the processing chain of JDOM->Xalan. I noticed in the FAQ you
mentioned that you should just write out the JDOM object to a Stream and
feed that to XSLTInputSource, but is there a better way to do
this? Would it be faster to convert the JDOM object to a DOM object and
pass that to XSLTInputSource directly?

I'd appreciate any information that you could provide.

Thank You,
Eric Rosenberg

_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com



More information about the jdom-interest mailing list