thanks for the prompt help Mehmood, but the same problem still persists. I did make slight changes to the code you sent me though (kept the ByteArrayOutputStream as is but changed the StringReader to a FileReader just for simplicity) before running it.
Do you get the error when running the Java code with the XML and XSL I have pasted in the mail ? Just to make sure my classpath is not messed up with the wrong jars :-) Anil. PS: I just noticed after sending the prev mail that the driver.setRenderer(driver.RENDER_TEXT) should be driver.setRenderer(driver.RENDER_PDF) But the problem remains even with that change. -----Original Message----- From: Shaikh, Mehmood [SMTP:[EMAIL PROTECTED] Sent: Friday, June 21, 2002 2:37 PM To: '[EMAIL PROTECTED]' Subject: RE: Using Xalan Transformer with FOP Driver problem Try this. // ------- // 1. Get a Source for XML document // ------- // a) from string Source strSource = new StreamSource(new StringReader(xmlData)); // ------- // 2. Get stylesheet transformer // ------- // from file, see above examples for other types of XSL input //TransformerFactory TransformerFactory transformerFactory = TransformerFactory.newInstance (); Templates template = transformerFactory.newTemplates( new StreamSource( xslLayout )); // note - template object is multi-threaded and should be cached if you // plan to use the same XSL repeatedly Transformer transformer = template.newTransformer(); // ------- // 3. Create FOP driver and set rendering mode and output stream // ------- Driver driver = new Driver(); driver.setRenderer(driver.RENDER_PDF); ByteArrayOutputStream baos = new ByteArrayOutputStream (); driver.setOutputStream( baos); // initialize logger - see sample code on FOP website driver.setLogger(setLogger()); // ------- // 4. Create SAXResult based on FOP Driver content handler // which will accept SAX events and build FOP tree // ------- Result saxResult = new SAXResult( driver.getContentHandler() ); // 5. Use the Transformer to transform an XML Source and // send the output to a Result object. Implicitely it will // create the FOP tree by firing SAX events. transformer.transform( strSource, saxResult ); // 6. Your user is already viewing the PDF! response.getOutputStream().flush(); response.getOutputStream().close();