This is how i thought to do it and that someone else (Lakshmi) made working :) using DOM instead of (File)Streams.
-Teemu -----Forwarded message----- Lähettäjä: Lakshmi Anantharaman [SMTP:[EMAIL PROTECTED] Lähetetty: 18. tammikuuta 2002 22:26 Vastaanottaja: Fop-User (E-mail) Aihe: FOP and DOM Success I tried for long and with the help of fop-dev archive got my FOP servlet to work with a DOM . Here comes the code . I hope it is useful to someone down the line ! public void renderXML(HttpServletResponse response) throws ServletException { try { //Instantiate a DocumentBuilderFactory, needed for parsing XML documents from text format DocumentBuilderFactory dFactory = DocumentBuilderFactory.newInstance(); // And setNamespaceAware, which is required when parsing xsl files dFactory.setNamespaceAware(true); //Use the DocumentBuilderFactory to create a DocumentBuilder. DocumentBuilder dBuilder = dFactory.newDocumentBuilder(); /**************************************************************/ FileInputStream xmlfile = new FileInputStream("c:\\bea\\wlserver6.0\\contact.xml" ); Document xmlDoc = dBuilder.parse(xmlfile); javax.xml.transform.dom.DOMSource xmlDomSource = new javax.xml.transform.dom.DOMSource(xmlDoc); /************************************************************/ /************************************************************/ FileInputStream xsltFile = new FileInputStream("contactFO.xsl"); org.w3c.dom.Document xslDoc = dBuilder.parse(xsltFile); javax.xml.transform.dom.DOMSource xslDomSource = new javax.xml.transform.dom.DOMSource(xslDoc); javax.xml.transform.TransformerFactory tFactory = javax.xml.transform.TransformerFactory.newInstance(); javax.xml.transform.Templates templates = tFactory.newTemplates(xslDomSource); javax.xml.transform.Transformer transformer = templates.newTransformer(); /*************************************************************/ javax.xml.transform.dom.DOMResult foDomResult = new javax.xml.transform.dom.DOMResult(); transformer.transform(xmlDomSource, foDomResult); // Avoiding this step was what gave the null pointer exception ! org.w3c.dom.Document foDoc =(org.w3c.dom.Document)foDomResult.getNode(); ByteArrayOutputStream out = new ByteArrayOutputStream(); response.setContentType("application/pdf"); org.apache.fop.apps.Driver driver = new org.apache.fop.apps.Driver(); driver.setErrorDump(true); driver.setRenderer(driver.RENDER_PDF); driver.setupDefaultMappings() ; driver.setOutputStream(out); driver.render(foDoc); byte[] content = out.toByteArray(); response.setContentLength(content.length); response.getOutputStream().write(content); response.getOutputStream().flush(); }catch(FileNotFoundException fnf) { fnf.printStackTrace(); } catch (Exception ex) { throw new ServletException(ex); } } Lakshmi > -----Alkuperäinen viesti----- > Lähettäjä: Ryan Howe [SMTP:[EMAIL PROTECTED] > Lähetetty: 12. helmikuuta 2002 3:01 > Vastaanottaja: [EMAIL PROTECTED] > Aihe: Pipe XSLT Transform to FOP > > Hello, > > I have an application which currently will transform a Vector > of Document objects out to HTML files. We would like to be able > to modify this application to allow the process to create PDF files > instead of HTML files. > > I have been looking for a way to pipe the output of my Transformer > into the Input of the FOP Driver object. Unfortunately, I have been > unable to see any way of doing this except to persist the Transformer > output to file and then provide this file to the FOP Driver object. > > Could anyone point me in the right direction of how I could transform > my XML to PDF without creating an intermediate file? > > Thank You > > > > _________________________________________________________ > > Do You Yahoo!? > > Get your free @yahoo.com address at http://mail.yahoo.com > >