Newkid wrote:
Can any one let me know whether one can create an PDF file with the
following options:
a. Reading XML file from the stream, passing XSL which is stored in the
webdirectory and storing it in some other directory?
b. Reading XML from the database, passing XSL which is stored in the
webdirectory and output the pdf as a stream?
Technically: yes for both questions. However, this is based
on a woefully broad set of assumptions on what you probably
mean. Which is, based on experience with this kind of questions,
slightly different from what you actually mean.
Ok, the assumptions are:
- You develop a web application based on Java servlets
- For question a, you want to read an XML document from a
servlet input stream, transform it using an XSL style sheet
read from a file belonging to the web application, render
the result to PDF and store it as a file somewhere else.
- For question b, you read a complete XML document from the
database, transform/render it and send to the servlet's
output stream.
Usually, follow-up questions include
- How do I get the XSL transformation? Possible answers:
Either put in a jar in the lib directory (i.e. on the
classpath) and load it as a resource, or put it into the
content area and try to use getRealPath to resolve the
file system path. Both methods have drawbacks.
- How do I get the XML from the database into the transformation?
Answer: ask someone how the get it as a string, then use a
StringSource.
- Why doesn't FOP like the XML read from the database? Answer:
It's the XML parser which barfs for a variety of possible reasons:
- you didn't store a proper XML document in the database field
- the database mangled the character encoding
- the XML was double escaped by an automatism which tried to
be helpful, but wasn't
- your server runs an old Java version and your XML triggered a
known bug in the parser included in the JRE.
- Why doesn't the browser show the PDF? Actually, the question should
be: How do I debug this? Answer: develop and test each step
separately. Develop the transformation outside of the web
application. Make sure you get the same XML out of the database
which you put in. Put only everything together and in the web
application once you are sure every step works. Don't do small
fixes for the XSL transformation in the web application
environment, develop it in the external environment, run the
automated regression tests (you write automated regression
tests, do you?), then deploy it.
I still wonder where the solaris box factlet fits in.
J.Pietschmann
-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]