This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Using FOP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Using FOP" Watch "Using FOP" New topic

Using FOP

Mark Spritzler

Joined: Feb 05, 2001
Posts: 17249

OK, I have a Servlet that can take form parameters, do a query to the database, make the data into XML, and uses XSLT To transform it into HTML which is sends back through the HTTPServletResponse object. This works perfectly.
Now I am trying to transform that same XML using XSL:FO to become a PDF document that gets sent to the browser via the HTTPServletResponse.
The big problem is that in order to do this FOP requires any object you send to it as being a File. You can't pass InputStream, or StreamSource or Source objects. Well my data, except for the XSL file used to transform the XML to FO, is in streams and not saved in files. I don't want them to be in files because this is ad-hoc, and temp files don't work because multiple users might overwrite even temp files.
Here's my servlet code

You will notice in renderPDF, I gave up and said OK, OK if you have to have a file, I will make one. But it still doesn't work.

Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
William Brogden
Author and all-around good cowpoke

Joined: Mar 22, 2000
Posts: 12756
Cocoon manages this without writing a separate document file. You might take a look at how they do it
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17249

Thanks Bill.
I also am seeing that FOP also has to use Avalon's Logging, and you need to have that package as well to get it to work.
I am going to look at Cocoon. Hopefully it is more intuitive that FOP.
I agree. Here's the link:
subject: Using FOP
Similar Threads
transforming xml from string source
problem in XSL Transformation
Servlet, XML response and XSL
URGENT!!!! Xalan problem in Servlet with JRun
https problem