I resolved my problem with pointers from J.Pietschmann. Here is my code:
public static void renderXML(Document document, String xslFile,
HttpServletResponse response)
throws ServletException {
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
response.setContentType("application/pdf");
Driver driver =new Driver();
//driver.setOutputStream(response.getOutputStream());
driver.setOutputStream(out);
driver.setRenderer(Driver.RENDER_PDF);
Transformer
transformer=TransformerFactory.newInstance().newTransformer(new
StreamSource(xslFile));
transformer.transform(new DOMSource(document), new
SAXResult(driver.getContentHandler()));
byte[] content = out.toByteArray();
response.setContentLength(content.length);
response.getOutputStream().write(content);
response.getOutputStream().flush();
} catch (Exception ex) {
throw new ServletException(ex);
}
}
HTH, Mike
-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 25, 2002 2:45 PM
To: [EMAIL PROTECTED]
Subject: RE: FOPServlet and XML string
I'm having the same issues, so if you find a solution, please post. But, it
seems like you could use the XALAN function XSLTransform to convert a DOM
document or a string using an XSL file to either a FO file or another DOM
document. XSLTInputHandler will only take java.io.File parameters, but I've
seen examples of using the JAXP Transformer to do the job as well. See:
http://www.devx.com/xml/articles/vp101201/vp101201-1.asp. It seems as if
this could be modified to use a StringReader and/or StringWriter. Let me
know if you have any luck.
Mike
-----Original Message-----
From: Mo, Jennifer [mailto:[EMAIL PROTECTED]
Sent: Tuesday, June 25, 2002 2:17 PM
To: [EMAIL PROTECTED]
Subject: FOPServlet and XML string
Does anyone know how to modify the FOPServlet so that it takes in a XML
string instead of a XML file? The XSLTInputHandler class (which inherits
from InputHandler) seems to only take in a file but not a String. i'm stuck.
Any ideas or suggestion?