Amit,

I did as you asked and here is the resulting exceptions.  I'm stumped.

/******************************************************************************/
javax.xml.transform.TransformerConfigurationException: javax.xml.parsers.FactoryConfigurationError: com.sun.xml.p
        at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:815)
        at org.apache.fop.tools.xslt.TraxTransform.getTransformer(TraxTransform.java:50)
        at org.apache.fop.tools.xslt.TraxTransform.transform(TraxTransform.java:100)
        at org.apache.fop.tools.xslt.TraxTransform.transform(TraxTransform.java:80)
        at java.lang.reflect.Method.invoke(Native Method)
        at org.apache.fop.tools.xslt.XSLTransform.transform(XSLTransform.java:76)
        at org.apache.fop.tools.xslt.XSLTransform.transform(XSLTransform.java:49)
        at PDFTest.<init>(PDFTest.java:87)
        at PDFTest.main(PDFTest.java:107)
---------
javax.xml.transform.TransformerException: javax.xml.parsers.FactoryConfigurationError: com.sun.xml.parser.SAXPars
        at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:813)
        at org.apache.fop.tools.xslt.TraxTransform.getTransformer(TraxTransform.java:50)
        at org.apache.fop.tools.xslt.TraxTransform.transform(TraxTransform.java:100)
        at org.apache.fop.tools.xslt.TraxTransform.transform(TraxTransform.java:80)
        at java.lang.reflect.Method.invoke(Native Method)
        at org.apache.fop.tools.xslt.XSLTransform.transform(XSLTransform.java:76)
        at org.apache.fop.tools.xslt.XSLTransform.transform(XSLTransform.java:49)
        at PDFTest.<init>(PDFTest.java:87)
        at PDFTest.main(PDFTest.java:107)
---------
org.xml.sax.SAXException: javax.xml.parsers.FactoryConfigurationError: com.sun.xml.parser.SAXParserFactoryImpl
        at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:771)
        at org.apache.fop.tools.xslt.TraxTransform.getTransformer(TraxTransform.java:50)
        at org.apache.fop.tools.xslt.TraxTransform.transform(TraxTransform.java:100)
        at org.apache.fop.tools.xslt.TraxTransform.transform(TraxTransform.java:80)
        at java.lang.reflect.Method.invoke(Native Method)
        at org.apache.fop.tools.xslt.XSLTransform.transform(XSLTransform.java:76)
        at org.apache.fop.tools.xslt.XSLTransform.transform(XSLTransform.java:49)
        at PDFTest.<init>(PDFTest.java:87)
        at PDFTest.main(PDFTest.java:107)
---------
org.xml.sax.SAXException: javax.xml.parsers.FactoryConfigurationError: com.sun.xml.parser.SAXParserFactoryImpl
        at org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:771)
        at org.apache.fop.tools.xslt.TraxTransform.getTransformer(TraxTransform.java:50)
        at org.apache.fop.tools.xslt.TraxTransform.transform(TraxTransform.java:100)
        at org.apache.fop.tools.xslt.TraxTransform.transform(TraxTransform.java:80)
        at java.lang.reflect.Method.invoke(Native Method)
        at org.apache.fop.tools.xslt.XSLTransform.transform(XSLTransform.java:76)
        at org.apache.fop.tools.xslt.XSLTransform.transform(XSLTransform.java:49)
        at PDFTest.<init>(PDFTest.java:87)
        at PDFTest.main(PDFTest.java:107)
java.lang.reflect.InvocationTargetException: java.lang.NullPointerException
        at org.apache.fop.tools.xslt.TraxTransform.transform(TraxTransform.java:102)
        at org.apache.fop.tools.xslt.TraxTransform.transform(TraxTransform.java:80)
        at java.lang.reflect.Method.invoke(Native Method)
        at org.apache.fop.tools.xslt.XSLTransform.transform(XSLTransform.java:76)
        at org.apache.fop.tools.xslt.XSLTransform.transform(XSLTransform.java:49)
        at PDFTest.<init>(PDFTest.java:87)
        at PDFTest.main(PDFTest.java:107)
[ERROR]: Logger not set
[INFO]: building formatting object tree
/****************************************************************************************/

Cheers...Paul
 

Amit wrote:

Paul I haven't had much luck with XSLTInputHandler
For some reason I could never get it working. I used org.apache.fop.tools.xslt.XSLTransform instead and
everything works great.
I have attached my code for a servlet, so to use it in your application substitute all the
ByArrayOutputStream to FilOutputStream and it should work.
I haven't tried it but if you have problems I'll try it give you feedback if neccessary.

/*----------------------Code snippet begin ---------------------------*/

String xmlFile="file:C:\\yourfile.xml";
String xmlFile="file:C:\\yourfile.xsl";
java.io.Reader reader;
Writer writer = new StringWriter();
try{
ByteArrayOutputStream out = new ByteArrayOutputStream();
  XSLTransform.transform(xmlFile,
                                       xslFile, writer);

  writer.flush();
            writer.close();

  reader = new StringReader(writer.toString());

      Driver driver = new Driver(new InputSource(reader), out);
      driver.setRenderer(Driver.RENDER_PDF);
          driver.run();
            byte[] content = out.toByteArray();
            response.setContentType("application/pdf");
            response.setContentLength(content.length);
            response.getOutputStream().write(content);
            response.getOutputStream().flush();

} catch (Exception ex) {
            throw new ServletException(ex);
        }

/* ------------------------------------------------------------------------*/

Paul Kowlessar wrote:

> Hi Amit,
>
> I'm sorry; I should have mentioned that these errors occur while running the standalone application
> as well.  As to your question, I want to use Fop within an application on the client side.
>
> Cheers...Paul
>
> Amit wrote:
>
> > Paul,
> > There is already a class which will take the xml, xsl files and outpu a pdf!
> > There is also a batch file (if you or unix a shell script) which will do this for you.
> > It is is in your fop installation directory and is called fop.bat (fop.sh on unix).
> > This is for a standalone application. Are you trying to create a servlet which will out put PDF
> > files with the xml and xsl files as input?
> >
> > Amit
> >
> > Paul Kowlessar wrote:
> >
> > > Hi,
> > >
> > > I have just downloaded FOP 0.20.2 and have included the appropriate jars
> > > into my classpath. To test my installation, I have created a simple
> > > program based on the code in the "Embedding FOP" page.  Here is the
> > > code:
> > > /********************************************/
> > > import java.util.*;
> > > import java.io.*;
> > > import java.io.FileOutputStream;
> > > import org.apache.fop.apps.*;
> > > import org.xml.sax.*;
> > > import org.apache.avalon.framework.logger.*;
> > > import org.apache.log.*;
> > >
> > > public class PDFTest
> > > {
> > >   public PDFTest()
> > >   {
> > >    Logger log = null;
> > >    Hierarchy hierarchy = Hierarchy.getDefaultHierarchy();
> > >    log = hierarchy.getLoggerFor("fop");
> > >    log.setPriority(Priority.WARN);
> > >
> > >    String xmlFile = "c:\\worktemp\\01M10_YVR_FA.xml";
> > >    String xslFile = "c:\\worktemp\\bidreport.xsl";
> > >    String pdfFile = "c:\\worktemp\\outFile.pdf";
> > >    FileOutputStream output = null;
> > >    try{
> > >        output = new FileOutputStream(pdfFile);
> > >        Driver driver = new Driver();
> > >        driver.setLogger(log);
> > >        driver.setRenderer(Driver.RENDER_PDF);
> > >        XSLTInputHandler inputHandler = new XSLTInputHandler(new
> > > File(xmlFile), newFile(xslFile));
> > >        org.xml.sax.XMLReader parser = inputHandler.getParser();
> > >        driver.setOutputStream(output);
> > >        driver.render(parser,inputHandler.getInputSource());
> > >    }catch (Exception ex){
> > >        ex.printStackTrace();
> > >    }
> > >   }
> > >
> > >  public static void main(String[] args)
> > >  {
> > >   PDFTest test = new PDFTest();
> > >  }
> > > }
> > > /*************************************************************/
> > >
> > > This file compiles with no problem.  However, when I try to run it the
> > > following errors are encountered:
> > >
> > > org.apache.fop.apps.FOPException
> > >         at
> > > org.apache.fop.apps.XSLTInputHandler.getParser(XSLTInputHandler.java:109)
> > >
> > >         at PDFTest.<init>(PDFTest.java:29)
> > >         at PDFTest.main(PDFTest.java:41)
> > >
> > > ---------
> > >
> > > java.lang.reflect.InvocationTargetException:
> > > org.apache.fop.apps.FOPException:
> > > javax.xml.parsers.FactoryConfigurationE
> > >         at
> > > org.apache.fop.apps.TraxInputHandler.getXMLFilter(TraxInputHandler.java:103)
> > >
> > >         at java.lang.reflect.Method.invoke(Native Method)
> > >         at
> > > org.apache.fop.apps.XSLTInputHandler.getParser(XSLTInputHandler.java:102)
> > >
> > >         at PDFTest.<init>(PDFTest.java:29)
> > >         at PDFTest.main(PDFTest.java:41)
> > >
> > > ---------
> > >
> > > ---------
> > >
> > > org.apache.fop.apps.FOPException:
> > > javax.xml.parsers.FactoryConfigurationError:
> > > com.sun.xml.parser.SAXParserFactoryImpl
> > >         at
> > > org.apache.fop.apps.TraxInputHandler.getXMLFilter(TraxInputHandler.java:103)
> > >
> > >         at java.lang.reflect.Method.invoke(Native Method)
> > >         at
> > > org.apache.fop.apps.XSLTInputHandler.getParser(XSLTInputHandler.java:102)
> > >
> > >         at PDFTest.<init>(PDFTest.java:29)
> > >         at PDFTest.main(PDFTest.java:41)
> > >
> > > ---------
> > >
> > > javax.xml.transform.TransformerConfigurationException:
> > > javax.xml.parsers.FactoryConfigurationError: com.sun.xml.parser
> > >         at
> > > org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:815)
> > >
> > >         at
> > > org.apache.xalan.processor.TransformerFactoryImpl.newXMLFilter(TransformerFactoryImpl.java:486)
> > >
> > >         at
> > > org.apache.fop.apps.TraxInputHandler.getXMLFilter(TraxInputHandler.java:84)
> > >
> > >         at java.lang.reflect.Method.invoke(Native Method)
> > >         at
> > > org.apache.fop.apps.XSLTInputHandler.getParser(XSLTInputHandler.java:102)
> > >
> > >         at PDFTest.<init>(PDFTest.java:29)
> > >         at PDFTest.main(PDFTest.java:41)
> > > ---------
> > > javax.xml.transform.TransformerException:
> > > javax.xml.parsers.FactoryConfigurationError:
> > > com.sun.xml.parser.SAXParserFac
> > >         at
> > > org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:813)
> > >
> > >         at
> > > org.apache.xalan.processor.TransformerFactoryImpl.newXMLFilter(TransformerFactoryImpl.java:486)
> > >
> > >         at
> > > org.apache.fop.apps.TraxInputHandler.getXMLFilter(TraxInputHandler.java:84)
> > >
> > >         at java.lang.reflect.Method.invoke(Native Method)
> > >         at
> > > org.apache.fop.apps.XSLTInputHandler.getParser(XSLTInputHandler.java:102)
> > >
> > >         at PDFTest.<init>(PDFTest.java:29)
> > >         at PDFTest.main(PDFTest.java:41)
> > > ---------
> > > org.xml.sax.SAXException: javax.xml.parsers.FactoryConfigurationError:
> > > com.sun.xml.parser.SAXParserFactoryImpl
> > >         at
> > > org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:771)
> > >
> > >         at
> > > org.apache.xalan.processor.TransformerFactoryImpl.newXMLFilter(TransformerFactoryImpl.java:486)
> > >
> > >         at
> > > org.apache.fop.apps.TraxInputHandler.getXMLFilter(TraxInputHandler.java:84)
> > >
> > >         at java.lang.reflect.Method.invoke(Native Method)
> > >         at
> > > org.apache.fop.apps.XSLTInputHandler.getParser(XSLTInputHandler.java:102)
> > >
> > >         at PDFTest.<init>(PDFTest.java:29)
> > >         at PDFTest.main(PDFTest.java:41)
> > > ---------
> > > org.xml.sax.SAXException: javax.xml.parsers.FactoryConfigurationError:
> > > com.sun.xml.parser.SAXParserFactoryImpl
> > >         at
> > > org.apache.xalan.processor.TransformerFactoryImpl.newTemplates(TransformerFactoryImpl.java:771)
> > >
> > >         at
> > > org.apache.xalan.processor.TransformerFactoryImpl.newXMLFilter(TransformerFactoryImpl.java:486)
> > >
> > >         at
> > > org.apache.fop.apps.TraxInputHandler.getXMLFilter(TraxInputHandler.java:84)
> > >
> > >         at java.lang.reflect.Method.invoke(Native Method)
> > >         at
> > > org.apache.fop.apps.XSLTInputHandler.getParser(XSLTInputHandler.java:102)
> > >
> > >         at PDFTest.<init>(PDFTest.java:29)
> > >         at PDFTest.main(PDFTest.java:41)
> > >
> > > Has anyone encountered this problem before?  If so, please reply with
> > > your solution.
> > > Thanks in advance.
> > >
> > > Cheers...Paul
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, email: [EMAIL PROTECTED]
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, email: [EMAIL PROTECTED]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, email: [EMAIL PROTECTED]

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to