tags:

views:

24

answers:

1

I have code written that converts my Document to a string prior to printing

        TransformerFactory tf = TransformerFactory.newInstance();
        Transformer trans = tf.newTransformer();
        trans.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
        trans.setOutputProperty(OutputKeys.INDENT, "yes");


        //create string from xml tree
        StringWriter sw = new StringWriter();
        StreamResult result = new StreamResult(sw);
        DOMSource source = new DOMSource(doc);
        trans.transform(source, result);
        xmlString = sw.toString();

This works perfectly in a standalone program. I have cut and pasted this code directly into a module running under jakarta-tomcat-5.0.28 (JDK 1.5) and it stops prior to the TransformerFactory.newInstance(). Is there something that I need to tell my jvm under jakarta about where to find the appropriate classes? BTW, the call never returns, it just stops with no response.

+1  A: 

What error do you get? It sounds like you need to have a Java XML library on your classpath, if you run under Java 6 you have JAXP TransformerFactory in your classpath by default, otherwise you will need to add Xalan/SAX etc. to your classpath.

Jon Freedman
no error, no response, nothing - it just stops. I'm running JDK 1.5 - I'll scare up a Xalan and see what that does.
KevinDTimm
HUGE thanks, very much, installation of xalan does the trick!
KevinDTimm