No subject
Fri Aug 6 17:04:17 PDT 2004
as its internal format. Thus I belived that transforming into SAX events
directly would be faster.
We use XSL at a part of a internet application so we output to a Writer
instead of a documentbuilder, but otherwise that shouldn't matter.
Regards
Lasse
-----Original Message-----
From: Frank Kmiec [mailto:kmiec at inil.com]
Sent: Friday, January 26, 2001 1:34 PM
To: Lasse Lindgård
Subject: Re: [jdom-interest] JDOM -> Xalan using SAX
A naiive question, I'm sure, but ... what is the benefit of using the
transformer classes? Wouldn't it be faster to simply use XMLOutputter -->
Piped Output --> Piped Input --> DocumentBuilder?
--Frank
----- Original Message -----
From: "Lasse Lindgård" <lasse at lintor.dk>
To: <jdom-interest at jdom.org>
Sent: Thursday, January 25, 2001 1:19 PM
Subject: [jdom-interest] JDOM -> Xalan using SAX
> I just hacked this code together and I thought that I would submit it.
> I wrote it this way because my old code (using Xalan 1.2 and the
> DOMOutputter) seemed to be sluggish.
> I didn't get a chance to profile this code just yet, but it might or might
> not be faster than the original DOMOutputter code.
>
> I hope that someone can suggest some improvements. I would have thought
that
> the code was faster than the old.
>
> Enjoy
> /Lasse
>
> public final static void transformXalan2SAX(Document jdom, String
> stylesheet, PrintWriter out)
> throws IOException, TransformerConfigurationException, SAXException,
> JDOMException {
> // Instantiate a TransformerFactory.
> TransformerFactory tFactory = TransformerFactory.newInstance();
> Honestly it seems a bit slower - but I don't know where the bottleneck is
> yet.
>
> // Cast the TransformerFactory.
> SAXTransformerFactory saxTFactory = ((SAXTransformerFactory) tFactory);
> // Create a ContentHandler to handle parsing of the stylesheet.
> TemplatesHandler templatesHandler = saxTFactory.newTemplatesHandler();
>
> // Create an XMLReader and set its ContentHandler.
> XMLReader reader = org.xml.sax.helpers.XMLReaderFactory.createXMLReader();
> reader.setContentHandler(templatesHandler);
>
> // Parse the stylesheet.
> reader.parse(stylesheet);
>
> //Get the Templates object from the ContentHandler.
> Templates templates = templatesHandler.getTemplates();
> // Create a ContentHandler to handle parsing of the XML source.
> TransformerHandler handler = saxTFactory.newTransformerHandler(templates);
> reader.setContentHandler(handler);
>
> Result result = new javax.xml.transform.stream.StreamResult(out);
> handler.setResult(result);
>
> SAXOutputter jdomOut = new SAXOutputter(handler);
> jdomOut.output(jdom);
> }
>
> _______________________________________________
> 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