[jdom-interest] JDOM and XSL

Jan Peter Hecking jan at netgaroo.com
Fri Feb 9 06:50:33 PST 2001


On Fri, Feb 09, 2001 at 10:18:14AM -0000, Edoardo Comar wrote:
> Brett McLaughlin wrote :
> > I actually agree - now I can see you turning the resultant,
> > styled, XML into
> > JDOM, like so:
> > XML -> XSLT -> XML -> JDOM
> > to work with. Or, if the XML at the beginning is dynamic, you might have:
> > JDOM -> XSLT -> XML -> JDOM
> I've easily found examples of code for performing the first transformation,
> but for the second, the JDOM FAQ suggest a streaming approach : if my source
> or stylesheet or both are JDOM document, I'd have to use the outputter to
> stream the JDOM docs back to XML.
> Is then more efficient to have xalan work on DOM documents than on JDOM
> documents ?

The most efficient solution to transform a JDOM source into a JDOM
result seems to be
JDOM -> SAX -> XSLT -> XML -> JDOM
I've attached example code for this set of transformations.
Even better - performance wise - would probably the following set of
transformations
JDOM -> SAX -> XSLT -> SAX -> JDOM
This could probably be accomplished by using the SAXHandler that is
used internaly by the SAXBuilder.

Brett and/or Jason, would it be possible to make the SAXHandler
class public so that one could use it like this:

import javax.xml.transform.sax.SAXResult;
Document document = new Document();
SAXResult res = new SAXResult( new SAXHandler( document ) );
// fire off SAX events
// -> document is build by the SAXHandler
// work with document

I've only had a quick look at the SAXHandler so there might be
problems to this approach I didn't see.

bye,
Jan

-- 
Jan Peter Hecking                  jhecking at netgaroo.com
University of Rostock     Department of Computer Science
Homepage: http://www.informatik.uni-rostock.de/~jhecking



More information about the jdom-interest mailing list