RE: Embedded FOP question.
Thanks for your help! I needed to change it to use a ByteArray so that I could set the content length for IE. Other than that it worked great. Thanks again. Mike -Original Message- From: J.Pietschmann [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 25, 2002 4:51 PM To: [EMAIL PROTECTED] Subject: Re: Embedded FOP question. [EMAIL PROTECTED] wrote: I've been using the FopServlet as the basis for my servlet app which takes a DOM document, stores it to an xml file, then uses XSLTInputHandler to convert to fo and output the pdf. Now I'm getting to the point where I want to eliminate the xml file and convert using the DOM object or a serialized string of the xml. It looks to me like it can't be done with the XSLTInputHandler class because it requires java.io.File parameters. I'm looking at XSLTransform to transform the DOM document input to a DOM document containing FO output using the xsl file. Just wondering if this is the best approach and then how to best use the FO DOM document to output the pdf. If anyone knows where I can find some good sample code (or if you have a sample yourself), I would appreciate the tips. There is sample code in the archive at http://marc.theaimsgroup.com/?l=fop-userr=1w=2# http://marc.theaimsgroup.com/?l=fop-devr=1w=2# For producing and rendering a DOM, look up javax.xml.transform.dom.DOMResult in the JAXP documentation coming with your XSLT processor and look for render(Document) in src/org/apache/fop/apps/Driver.java Unless you need to manipulate the intermediate DOM, it is usually more effective to use SAX to tie the XSLT processor to the FOP driver, for example http://marc.theaimsgroup.com/?l=fop-userm=102400770318682w=2 J.Pietschmann
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?
Problem with javax.xml.transform.Transformer
I have two instances of Tomcat. One that has my development webapps and it is Tomcat 4.0.3. Another is empty and it is 4.0.4-b3. I put the FopServlet in the 4.0.4-b3 version and tested it out and it worked fine after some problems were resolved. Now, I've simply moved it into the webapps for my development server (4.0.3) and I start getting an error with a ClassNotFound exception on javax.xml.transform.Transformer. Anybody have any ideas? In both cases the xalan.jar is in my WEB-INF/lib directory. Thanks, Mike For futher information, here is the stack trace: javax.servlet.ServletException: javax.xml.transform.Transformer at FopServlet.renderXML(FopServlet.java:127) at FopServlet.doGet(FopServlet.java:68) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application FilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh ain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja va:243) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 66) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja va:190) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 66) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:180 ) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 66) at org.apache.catalina.valves.ErrorDispatcherValve.invoke(ErrorDispatcherValve. java:170) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 64) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:170 ) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 64) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:468) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 64) at org.apache.catalina.authenticator.SingleSignOn.invoke(SingleSignOn.java:392) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 64) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java :174) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 66) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java: 1012) at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1107 ) at java.lang.Thread.run(Thread.java:484) root cause org.apache.fop.apps.FOPException: javax.xml.transform.Transformer at org.apache.fop.apps.XSLTInputHandler.getParser(XSLTInputHandler.java:107) at FopServlet.renderXML(FopServlet.java:119) at FopServlet.doGet(FopServlet.java:68) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Application FilterChain.java:247) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterCh ain.java:193) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.ja va:243) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 66) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.ja va:190) at org.apache.catalina.core.StandardPipeline.invokeNext(StandardPipeline.java:5 66) at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:472) at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:943) at org.apache.catalina.core.StandardContext.invoke(StandardContext.java:2343) at
RE: Fop Servlet Problems
Did you try giving the fo file a path? For example when I ran this I gave it fo=c:\temp\simple.fo and it worked (assuming my fo file was found in c:\temp. Of course, an absolute path isn't so good for servlets, but you get the idea. Mike -Original Message- From: gary cor [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 18, 2002 6:46 PM To: [EMAIL PROTECTED] Subject: Fop Servlet Problems Dear All, I am up and running with my first ever servlets in Tomcat4.03 (although they only run in the examples folder). So, I put all five of the latest version of the jar files as instructed in FOP servlets into the lib directory ( avalon-framework-4.1.2.jar batik-all-1.5b1.jar fop-0.20.3rc.jar logkit-1.0.1.jar and xalan-2.3.1.jar) and complied servlets OK as well. However, following this I've tried everything I can think possible to make a servelt produce a pdf from fo and still no joy and very soar eyes now as well! First I ran them without an fo file but they error as follows: http://localhost:8080/examples/servlet/FopPrintServlet? or http://localhost:8080/examples/servlet/FopServlet? Results in: FopServlet Error No 'fo' or 'xml/xsl' request param given. So then I assume I it is just a case of not finding an file.fo but when I try to give in one http://localhost:8080/examples/servlet/FopServlet?fo=border.fo and it always causes a status 500 internal service error (maybe something to do with it running only in the examples folder I have no idea!). I also found a mail a while ago from the group saying to put the fo files in the C:\Apache-Tomcat\bin file but still I get the same errors. Please can someone help? G. PS. I have also found a servlet in saxon for FOP has anyone tried this out is it easier to get working! _ Send and receive Hotmail on your mobile device: http://mobile.msn.com
RE: Fop Servlet Problems
If it goes white, I would also try: fo=c:\border.fodummy=.pdf. I recently was able to resolve a white screen problem with ie because it didn't recognize that its response was pdf without this pdf extension. -Original Message- From: gary cor [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 19, 2002 5:41 AM To: [EMAIL PROTECTED] Subject: RE: Fop Servlet Problems Mike, I haven't access to it right now. But I did try fo=c:\borber.fo and the web browser goes white with the FopServlet only but no PDF anywhere. I haven't access to it now but I'll try it again later, I think I probably do it with escaping next ie. fo=c%3a\borber.fo Cheers G. From: [EMAIL PROTECTED] Reply-To: [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: RE: Fop Servlet Problems Date: Tue, 18 Jun 2002 18:57:08 -0700 Did you try giving the fo file a path? For example when I ran this I gave it fo=c:\temp\simple.fo and it worked (assuming my fo file was found in c:\temp. Of course, an absolute path isn't so good for servlets, but you get the idea. Mike -Original Message- From: gary cor [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 18, 2002 6:46 PM To: [EMAIL PROTECTED] Subject: Fop Servlet Problems Dear All, I am up and running with my first ever servlets in Tomcat4.03 (although they only run in the examples folder). So, I put all five of the latest version of the jar files as instructed in FOP servlets into the lib directory ( avalon-framework-4.1.2.jar batik-all-1.5b1.jar fop-0.20.3rc.jar logkit-1.0.1.jar and xalan-2.3.1.jar) and complied servlets OK as well. However, following this I've tried everything I can think possible to make a servelt produce a pdf from fo and still no joy and very soar eyes now as well! First I ran them without an fo file but they error as follows: http://localhost:8080/examples/servlet/FopPrintServlet? or http://localhost:8080/examples/servlet/FopServlet? Results in: FopServlet Error No 'fo' or 'xml/xsl' request param given. So then I assume I it is just a case of not finding an file.fo but when I try to give in one http://localhost:8080/examples/servlet/FopServlet?fo=border.fo and it always causes a status 500 internal service error (maybe something to do with it running only in the examples folder I have no idea!). I also found a mail a while ago from the group saying to put the fo files in the C:\Apache-Tomcat\bin file but still I get the same errors. Please can someone help? G. PS. I have also found a servlet in saxon for FOP has anyone tried this out is it easier to get working! _ Send and receive Hotmail on your mobile device: http://mobile.msn.com _ Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.
RE: Newbie questions ...
I'll give it a try, the FopServlet.java comments say to use 2.0.0 though, thanks! -Original Message- From: Kumar, Sunil [mailto:[EMAIL PROTECTED] Sent: Monday, June 17, 2002 4:28 PM To: [EMAIL PROTECTED] Subject: RE: Newbie questions ... use xalann-3.1.x jar file -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Monday, June 17, 2002 3:27 PM To: [EMAIL PROTECTED] Subject: RE: Newbie questions ... I'm new to FOP and have a couple of questions. I'm trying to take a XML and convert it to FO using XSLT in order to display PDF from a servlet. I started with a static FO file and used the FopServlet to display it. This worked fine. However, I've tried using the XML/XSL parameters and I always get an error on the XSLTInputHandler which is caused by Provider org.apache.xalan.processor.TransformerFactoryImpl not found. I have put xalan-2.0.0.jar in my WEB-INF/lib directory. The URL I used to get this was: http://localhost/fop/servlet/fop?xml=C:\jakarta\fop-0.20.3\docs\xml-docs\f op\running.xmlxsl=C:\jakarta\fop-0.20.3\docs\xml-docs\xml2pdf.xsl Also, I'm putting the stack trace at the bottom of this email if anyone wants a look at it. My second question has to do with which XML object to use. Right now, I just have my XML in a file, but I want to generate it on the fly. The documentation says you can do this with DOM or SAX. Is there any problem doing it with JDOM? If not, does anyone know where I can find an example. Thank you, Mike Witt Stack Trace: Error: 500 Location: /fop/servlet/fop Internal Servlet Error: javax.servlet.ServletException at FopServlet.renderXML(FopServlet.java:125) at FopServlet.doGet(FopServlet.java:67) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405) at org.apache.tomcat.core.Handler.service(Handler.java:287) at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372) at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java: 812) at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758) at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(Htt pConnectionHandler.java:213) at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416) at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501) at java.lang.Thread.run(Thread.java:484) Root cause: org.apache.fop.apps.FOPException at org.apache.fop.apps.XSLTInputHandler.getParser(XSLTInputHandler.java:109) at FopServlet.renderXML(FopServlet.java:118) at FopServlet.doGet(FopServlet.java:67) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405) at org.apache.tomcat.core.Handler.service(Handler.java:287) at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372) at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java: 812) at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758) at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(Htt pConnectionHandler.java:213) at org.apache.tomcat.service.TcpWorkerThread.runIt(PoolTcpEndpoint.java:416) at org.apache.tomcat.util.ThreadPool$ControlRunnable.run(ThreadPool.java:501) at java.lang.Thread.run(Thread.java:484) - java.lang.reflect.InvocationTargetException: javax.xml.transform.TransformerFactoryConfigurationError: Provider org.apache.xalan.processor.TransformerFactoryImpl not found at javax.xml.transform.TransformerFactory.newInstance(TransformerFactory.java :110) at org.apache.fop.apps.TraxInputHandler.getXMLFilter(TraxInputHandler.java:72 ) at java.lang.reflect.Method.invoke(Native Method) at org.apache.fop.apps.XSLTInputHandler.getParser(XSLTInputHandler.java:102) at FopServlet.renderXML(FopServlet.java:118) at FopServlet.doGet(FopServlet.java:67) at javax.servlet.http.HttpServlet.service(HttpServlet.java:740) at javax.servlet.http.HttpServlet.service(HttpServlet.java:853) at org.apache.tomcat.core.ServletWrapper.doService(ServletWrapper.java:405) at org.apache.tomcat.core.Handler.service(Handler.java:287) at org.apache.tomcat.core.ServletWrapper.service(ServletWrapper.java:372) at org.apache.tomcat.core.ContextManager.internalService(ContextManager.java: 812) at org.apache.tomcat.core.ContextManager.service(ContextManager.java:758) at org.apache.tomcat.service.http.HttpConnectionHandler.processConnection(Htt
The newbie questions continue ...
Thanks for the answers to my previous questions. I've gotten past my earlier errors and now have a new set of problems. I have created a HelloWorld xml file and a xsl file and attempted to use FopServlet to display it in pdf. Unfortunately it only displays a blank pdf page. So, I downloaded saxon.exe and converted the file manually, then used FopServlet to display the resulting fo file. This file displayed my HelloWorld message just fine. Any thoughts? Thanks for any help, Mike Here are my files: helloworld.xml: ?xml version=1.0 encoding=UTF-8 ? hello helloworldHello World!/helloworld /hello helloworld.xsl: ?xml version=1.0? xsl:stylesheet xmlns:xsl=http://www.w3.org/1999/XSL/Transform; version=1.0 xmlns:fo=http://www.w3.org/1999/XSL/Format; xsl:template match=/ fo:root xmlns:fo=http://www.w3.org/1999/XSL/Format; fo:layout-master-set fo:simple-page-master master-name=only fo:region-body region-name=xsl-region-body margin-top=0.7in padding=6pt / fo:region-before region-name=xsl-region-before extent=0.7in / fo:region-after region-name=xsl-region-after extent=0.7in / /fo:simple-page-master /fo:layout-master-set fo:page-sequence master-reference=only fo:flow flow-name=xsl-region-body fo:block font-size=20pt font-family=serif line-height=30pt xsl:value-of select=/hello/helloworld/ /fo:block /fo:flow /fo:page-sequence /fo:root /xsl:template /xsl:stylesheet helloworld.fo: ?xml version=1.0 encoding=utf-8? fo:root xmlns:fo=http://www.w3.org/1999/XSL/Format; fo:layout-master-set fo:simple-page-master master-name=only fo:region-body region-name=xsl-region-body margin-top=0.7in padding=6pt/ fo:region-before region-name=xsl-region-before extent=0.7in/ fo:region-after region-name=xsl-region-after extent=0.7in/ /fo:simple-page-master /fo:layout-master-set fo:page-sequence master-reference=only fo:flow flow-name=xsl-region-body fo:block font-size=20pt font-family=serif line-height=30pt Hello World! /fo:block /fo:flow /fo:page-sequence /fo:root
RE: The newbie questions continue ...
Thanks for pointing this out! I put the dummy=.pdf on my URL and it worked. Question though, why does the fo test always seem to work and the xml/xsl test never work? Mike -Original Message- From: Oleg Tkachenko [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 18, 2002 2:54 PM To: [EMAIL PROTECTED] Subject: Re: The newbie questions continue ... That can be something wrong in code (show us what have you changed in FopServlet) or just usual IE bug (see http://marc.theaimsgroup.com/?l=fop-userm=102084375612518w=2). Kumar, Sunil wrote: I was able to create a pdf file in a servlet using fop successfully but when i set content type to application/pdf and write the pdf content to response object the pdf doesn't show up in the browser ( instead an empty page is shown) -Original Message- From: Oleg Tkachenko [mailto:[EMAIL PROTECTED] Sent: Tuesday, June 18, 2002 1:06 PM To: [EMAIL PROTECTED] Subject: Re: The newbie questions continue ... [EMAIL PROTECTED] wrote: I have created a HelloWorld xml file and a xsl file and attempted to use FopServlet to display it in pdf. Unfortunately it only displays a blank pdf page. Probably something wrong with servlet's parameters? Show us how do you invoke servlet. Make sure servlat is able to find your xml and xsl. -- Oleg Tkachenko Multiconn International Ltd, Israel