Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Performance issue: Java and XSLT

843834Dec 19 2006 — edited Feb 20 2007
I have a performance issue concerning Java and XSLT: my goal is to transform an xml file (source.xml)
by using a given xsl file (transformation.xsl). As result I would like to get a String object, in which the result
of the transformation (html-code) is in, so that I can display it in a browser. The problem is the long time
it takes for the code below to run through.


xml = new File("C:\\source.xml");
xmlSource = new StreamSource(xml);

xslt = new File("C:\\transformation.xsl");
StreamSource xsltSource = new StreamSource(xslt);

TransformerFactory transFact = TransformerFactory.newInstance();
trans = transFact.newTransformer(xsltSource);

StringWriter stringWriter = new StringWriter();
StreamResult streamResult = new StreamResult(stringWriter);
trans.transform(xmlSource, streamResult);

String output = stringWriter.toString();
stringWriter.close();

Before, I made the same transformation in an xml development environment, named Cooktop
(see http://xmlcooktop.com/). The transformation took about 2 seconds. With the code above in Java it
takes about 20 seconds.

Is there a way to make the transformation in Java faster?

Thanks in advance,

Marcello
Oldenburg, Germany
xerxez@gmx.de
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 20 2007
Added on Dec 19 2006
12 comments
474 views