But if the responses are mailed directly to you, how will the rest of us benifit from your mistakes? :)
-----Original Message----- From: Roger L. Costello [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 27, 2002 2:27 PM To: [EMAIL PROTECTED]; Costello,Roger L. Subject: Invoking XALAN from a Java servlet Hi Folks, [NOTE: Please mail responses directly to me. Thanks!] Below is Java code to invoke XALAN with two in-memory strings, representing the XML and Stylesheet respectively. I know that this code works. I have a program which invokes this method and it works great. However, when I use this code within a Java servlet it fails. I have traced it down to this statement: Transformer transformer = tFactory.newTransformer(xsl_ss); The javadocs mention this for the newTransformer() method: "Care must be given not to use this object in multiple threads running concurrently". I am not running multiple threads in my servlet. So, I can't imagine that that is the problem. I am really clueless as to what could be going wrong. Any help would be much appreciated. [I am using Tomcat 4.0.3 as the Web server.] /Roger // This code shows how to invoke xalan by passing to it the // xml and xsl as in-memory strings public static String doTransform(String xml, String xsl) throws TransformerException, TransformerConfigurationException, FileNotFoundException, IOException { TransformerFactory tFactory = TransformerFactory.newInstance(); StringReader xsl_sr = new StringReader(xsl); StreamSource xsl_ss = new StreamSource(xsl_sr); ** the following statement is where it fails ** Transformer transformer = tFactory.newTransformer(xsl_ss); StringReader xml_sr = new StringReader(xml); StreamSource xml_ss = new StreamSource(xml_sr); StringWriter out_sw = new StringWriter(); StreamResult out_sr = new StreamResult(out_sw); transformer.transform(xml_ss, out_sr); return out_sw.toString(); }