Why don't you do it all in one pass?  I have a servlet, that calls
some bean to get XML document in a DOM format (actually JDOM), then
registers fop driver as receiver of SAX events and runs XSLT on the
JDOM tree.

            // 1. Generate XML tree
            Document xmlSummary = DataLoader.getSummary();

            // 2. Get stylesheet transformer
            Transformer transformer = transformerFactory.getTransformer(
<xsl-file> );

            // 3. Create FOP driver and set rendering mode and output stream
            org.apache.fop.apps.Driver driver = new
            driver.setOutputStream( out );

            // 4. Create SAXResult based on FOP Driver content handler which
will accept 
            // SAX events and build FOP tree
            javax.xml.transform.sax.SAXResult saxResult =
                new javax.xml.transform.sax.SAXResult(
driver.getContentHandler() );

            // 5. Use the Transformer to transform an XML Source and send
the output 
            // to a Result object.
            // Implicitely it will create the FOP tree by firing SAX events
            transformer.transform( new org.jdom.transform.JDOMSource( xml ),
saxResult );


-----Original Message-----
From: Savino, Matt C [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 19, 2001 4:33 PM
Subject: Does render(dom) actually work?

Hello everyone. By any chance can someone point me to some example code
which uses render(dom)?  No matter what combination of driver methods or Fop
versions (.17,.19,.20.1) I use I seem to get the same error:

building formatting object tree
setting up fonts
        at java.util.Hashtable.get(
        at org.apache.fop.apps.Driver.render(
        at FOtoPDF.applyFop(
        at FOtoPDF.main(

Here is the source I'm using under v.0.20.1:
      org.apache.fop.apps.Driver driver = new org.apache.fop.apps.Driver();
      driver.setOutputStream(new FileOutputStream(pdfFilename));
      driver.setupDefaultMappings() ;

I have tried it with and without any of the mapping methods.

I am building the Dom object from a file. The sax input handler created from
the same file works fine in render(parser, inputSource). I have read through
the dev archives and found a few suggestions but none helped. Is there some
configuration I'm missing? Or did this "break a long time ago" as someone
suggested in the archives?

I am hoping to use FOP in a major production app, but if I can't solve this
I may not be able to. I am currently receiving a DOM object (a small report)
from some database access classes. I then perform an XSLT transform which
outputs my FO input as another DOM object. I suppose I could pipe the output
of that to SAX? I'd really rather not have to do anything klugy like
serialize it to a stream and then feed it in as SAX. But I'll consider
anything that doesn't cause too much of a performace hit. We definitely
don't want to have temp files sitting around, for a host of reasons.

Thank you very much for your help.

Matt Savino

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