Thanks Jeremias. I think the main reason we are parsing the fodoc into a DOM is 
so we can serialize the FO out to a file for debugging (it's either that or do 
the transformation twice). I'm actually in the process of altering the HSSF 
stuff now so I can debug the GMR output. On your adive I will change both of 
them back to a stream source for production. Although I seem to remember 
experimenting extensively when we first started with SAX vs. DOM input sources 
using the FOP XSLTInputHandler, SAXHandler, etc. As I recall, we didn't see 
much difference in performance. But I will try it again for this round and let 
you know how it goes. Actually here is the old commented out code from these 
tests:

      File xmlFile  = new File(xmlFilename);
      File xsltFile = new File(xsltFilename);
      org.apache.fop.apps.InputHandler inputHandler2 = new 
org.apache.fop.apps.XSLTInputHandler(xmlFile, xsltFile);
      org.xml.sax.XMLReader parser2 = inputHandler2.getParser();
      driver.render(parser2, inputHandler2.getInputSource());

Is there a more efficient method I should try?

thx,
Matt



> >       org.w3c.dom.Document xmlDoc = dBuilder.parse(xmlFile);
> >       javax.xml.transform.dom.DOMSource xmlDomSource = new 
> javax.xml.transform.dom.DOMSource(xmlDoc);
> > 
> >       org.w3c.dom.Document xslDoc = dBuilder.parse(xsltFile);
> >       javax.xml.transform.dom.DOMSource xslDomSource = new 
> javax.xml.transform.dom.DOMSource(xslDoc);
> 
> Why do you parse the whole thing into a DOM? That's very inefficient
> when you subsequently give it to JAXP anyway. A StreamSource 
> would be a
> lot better!
> 
> Have a look at the Example*.java in the latest FOP distribution under
> examples/embedding.
> 
> > 
> >       javax.xml.transform.TransformerFactory tFactory 
> >          = javax.xml.transform.TransformerFactory.newInstance();
> >       javax.xml.transform.Templates templates = 
> tFactory.newTemplates(xslDomSource);
> >       javax.xml.transform.Transformer transformer = 
> templates.newTransformer();
> >   
> >       ByteArrayOutputStream out = new ByteArrayOutputStream();
> > 



> >       org.w3c.dom.Document foDoc = 
> (org.w3c.dom.Document)domResult.getNode();
> 
> Again, don't do that. Use SAX as with the HSSF serializer:
> 
>         Result result = new SAXResult(driver.getContentHandler());
>         transformer.transform(xml, result);
>         
> See how similar the code is to the one for HSSF?
> 
> >       org.apache.fop.apps.Driver driver = new 
> org.apache.fop.apps.Driver();
> >       driver.setErrorDump(true);
> >       driver.setRenderer(driver.RENDER_PDF);
> >       driver.setupDefaultMappings() ;
> >     driver.setOutputStream(out);
> >       driver.render(foDoc);
> > 
> >       response.setContentType("application/pdf");


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

Reply via email to