Hello,

we've experimenting with fop as an PDF renderer and would like to
upgrde to fop0.20. As this is only a part of a larger framework,
we used to use the TraX Result Wrappers to pass along our input to
fop. Somehow I do not understand the latest FOP-API changes:

The call sequence we used succesfully with fop0.17(?), 0.18 and 0.19
was, like

    Result res = obtainResult(XMLServletRequestStatus status, OutputStream
out)    
    // 
    // ... Do s.th. to "fill" the result
    //
    Driver driver = status.getDriver();
    driver.format();
    driver.render();

with the method obtainResult() defined like

    protected Result obtainResult(XMLServletRequestStatus status,
                                                        OutputStream out)
        throws IOException
    {
        if(!status.isFOStyle())
        {
            return new StreamResult(out);
        }
        else
        {
            Driver driver = new Driver();
            String version = org.apache.fop.apps.Version.getVersion();
 
driver.setRenderer("org.apache.fop.render.pdf.PDFRenderer",version);
 
driver.addElementMapping("org.apache.fop.fo.StandardElementMapping");
        
driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");
        
driver.addPropertyList("org.apache.fop.fo.StandardPropertyListMapping");
        
driver.addPropertyList("org.apache.fop.svg.SVGPropertyListMapping");

            driver.setOutputStream(out);
            status.setDriver(driver);
            return new SAXResult(driver.getContentHandler());
        }
    }

as it turned out, some of those API ceased to exist, though marked as
deprecated
in the JavaDoc. So I reworked obtainResult() to this:

    protected Result obtainResult(XMLServletRequestStatus status,
                                                        OutputStream out)
        throws IOException
    {
        if(!status.isFOStyle())
        {
            return new StreamResult(out);
        }
        else
        {
            Driver driver = new Driver();
            String version = org.apache.fop.apps.Version.getVersion();
            // as of version 0.20.1
 
//driver.setRenderer("org.apache.fop.render.pdf.PDFRenderer",version);
            org.apache.fop.render.Renderer rend = new
org.apache.fop.render.pdf.PDFRenderer();
            log.msg("Renderer = "+rend);
            driver.setRenderer(rend);
        
driver.addElementMapping("org.apache.fop.fo.StandardElementMapping");
        
driver.addElementMapping("org.apache.fop.svg.SVGElementMapping");
            // as of version 0.20.1
                //
driver.addPropertyList("org.apache.fop.fo.StandardPropertyListMapping");
                //
driver.addPropertyList("org.apache.fop.svg.SVGPropertyListMapping");
            driver.setOutputStream(out);
            status.setDriver(driver);
            return new SAXResult(driver.getContentHandler());
        }
    }

This compiles, so at least it uses only known API's, but plugin it into 
the surrounding environment, I end up with this:

java.lang.NullPointerException
        at
org.apache.fop.fo.FOTreeBuilder.startDocument(FOTreeBuilder.java:167)
        at
com.icl.saxon.output.ContentHandlerProxy.startDocument(ContentHandlerProxy.j
ava:80)
        at
com.icl.saxon.output.ProxyEmitter.startDocument(ProxyEmitter.java:61)
        at com.icl.saxon.output.Outputter.open(Outputter.java:58)
        at
com.icl.saxon.output.GeneralOutputter.setOutputDestination(GeneralOutputter.
java:70)
        at
com.icl.saxon.Controller.changeOutputDestination(Controller.java:403)
        at com.icl.saxon.Controller.transformDocument(Controller.java:1036)
        at com.icl.saxon.Controller.transform(Controller.java:917)
        at
de.coi.xml.xslt.FileTransformerPool$PoolableTransformer.transform(FileTransf
ormerPool.java:562)
        at de.coi.servlet.XMLServlet.doGet(XMLServlet.java:302)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:102)
        at javax.servlet.http.HttpServlet.service(HttpServlet.java:83)
        at com.caucho.server.http.Invocation.service(Invocation.java:325)
        at
com.caucho.server.http.CacheInvocation.service(CacheInvocation.java:121)
        at
com.caucho.server.http.HttpRequest.handleRequest(HttpRequest.java:239)
        at
com.caucho.server.http.HttpRequest.handleConnection(HttpRequest.java:157)
        at com.caucho.server.TcpConnection.run(TcpConnection.java:140)
        at java.lang.Thread.run(Thread.java:484)

Which looks like the streamRenderer member in FOTreeBuilder has not been
initialized.

Before I start sifting thru the whole code, any quick clue from a guru?

You might also note that I actually don't think I need SVG, put I didn't get
the
older fops to works without it. 

Thank you very much,

Frank

--
Dr. Frank Sven Nestel
Principal Software Engineer

COI GmbH    Erlanger Straße 62, D-91074 Herzogenaurach
Phone +49 (0) 9132 82 4611 
http://www.coi.de, mailto:[EMAIL PROTECTED]
          COI - Solutions for Documents


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

Reply via email to