Using a org.w3c.dom.Document as indata to the Driver

Hi!

I would like to read a fo file to a DOM tree on startup.
Do some changes to it on runtime and then produce pdf and ps from it.

I am using version 0.20.1 of fop.

My try:

---
// Fetch xml -> dom tree
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = dbf.newDocumentBuilder();
Document doc = docBuilder.parse(FOfilename);

//... some changes to the DOM tree shall be done here (but I aint doing
any changes yet

Driver driver = new Driver();
driver.setRenderer(Driver.RENDER_PDF);
driver.setOutputStream(new FileOutputStream());

driver.render(doc); // -> returns fault, se below

//driver.setInputSource(new DocumentInputSource(doc));
// -> gives the same fault

/*
  //This works (but it doesn't use the preparsed dom tree
  driver.setInputSource(new InputSource(aPDFfilename));
  driver.run();
*/
---

The error I get is:
java.lang.NullPointerException
	at java.util.Hashtable.get(Hashtable.java:320)
	at org.apache.fop.fo.FOTreeBuilder.startElement(FOTreeBuilder.java:191)
	at org.apache.fop.tools.DocumentReader.parse(DocumentReader.java:444)
	at org.apache.fop.apps.Driver.render(Driver.java:449)
	at Avi.main(Avi.java:61) (my file)


I can only find old examples where a method Driver.format() is used...
and they does not use dom trees as indata.

Thankful for any help!

 
__________________________
Erik Melkersson, UNIT
melker@unit.liu.se, 013-285794
http://www.unit.liu.se/

Received on Thursday, 4 October 2001 08:31:19 UTC