[jdom-interest] jdom and fop
pdlnhrd at yahoo.com
pdlnhrd at yahoo.com
Wed Oct 30 16:55:53 PST 2002
I am completely new to using xml in java and doing transformations.
After a bit of research I concluded that JDOM was the way to go for
createing XML documents, but transforming them is something I haven't
figured out yet. This is what I am tyring to do: Create an XML
object in memory, transform object into a fo object using xsl, than
render object into pdf.
I have about 95% of it working, here is the code that I have so far:
Element root = new Element("users");
while (rset.next ()){
Element user = new Element("user");
user.addContent((new Element("firstname")).setText(rset.getString
("firstname") ));
user.addContent((new Element("lastname")).setText(rset.getString
("lastname")));
root.addContent(user);
}
Document doc = new Document(root);
con.close();
XMLOutputter xmlout = new XMLOutputter();
ByteArrayOutputStream output = new ByteArrayOutputStream();
response.setContentType("application/pdf");
Transformer transformer =
TransformerFactory.newInstance().newTransformer(new
StreamSource("/usr/local/home/pd/user.xsl"));
JDOMResult xmlResult = new JDOMResult();
transformer.transform(new JDOMSource(doc), xmlResult);
doc = xmlResult.getDocument();
org.apache.fop.apps.Driver pdfDriver = new
org.apache.fop.apps.Driver();
pdfDriver.setInputSource(doc);
pdfDriver.setOutputStream(output);
pdfDriver.setRenderer(org.apache.fop.apps.Driver.RENDER_PDF);
pdfDriver.run();
byte[] content = output.toByteArray();
response.setContentLength(content.length);
response.getOutputStream().write(content);
response.getOutputStream().flush();
here is the error I am getting:
pdfDriver.setInputSource(xmlResult);
<--------------------------------->
*** Error: No match was found for method
"setInputSource(org.jdom.transform.JDOMResult)".
from the api:
setInputSource(org.xml.sax.InputSource source)
Set the source for the FO document.
like I said, i am completely new to this and I am trying to make this
work by piecing bits of information that I have found all over the
place, there might be and easier way to do this... any information
would be helpfull or maybe even a tutorial taht someone knows of.
pdlnhrd
__________________________________________________
Do you Yahoo!?
HotJobs - Search new jobs daily now
http://hotjobs.yahoo.com/
More information about the jdom-interest
mailing list