Hi Xavier,

The exception is thrown on this line because of the method call on a null rootFObj object reference.

416: BookmarkTree bookmarkTree = rootFObj.getBookmarkTree();

Although not sure why the rootFObj reference is null...

I am new to the fop project and still finding my way but will do my best to find some answers to your problem.

Do you have the XSLT source document?
Do you have the code creates the DOMSource object and which calls convertDocumentToPDF? To try and answer your question about the rootFObj. I believe it represents and object reference representation of the parent node (the fo::root node) of the page sequence node (fo::page-sequence) in your document.

Adrian.

Xavier Ottolini wrote:
Hi,

I want to build a PDF file with a XSL transformation. I use FOP 0.93 on Tomcat 4.3 (Windows)
1) I load the XSLT
2) I create a DOM Document
3) I create de DOMSource Element
4) I process the XSL transformation

public ByteArrayOutputStream convertDocumentToPDF(DOMSource source, String xsltPath) throws IOException, FOPException, TransformerException, Exception {
FOUserAgent foUserAgent = fopFactory.newFOUserAgent();
// configure foUserAgent as desired

// Setup output
ByteArrayOutputStream out = new ByteArrayOutputStream();

try {
// Construct fop with desired output format
Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, foUserAgent, out);

// Setup XSLT
TransformerFactory factory = TransformerFactory.newInstance();
//Setup Transformer
System.out.println("xsltPath:"+ xsltPath);
File xslFile = new File(xsltPath);
Source xsltSrc = new StreamSource(xslFile);
Transformer transformer = factory.newTransformer(xsltSrc);

// Resulting SAX events (the generated FO) must be piped through to FOP
Result res = new SAXResult(fop.getDefaultHandler());
if(source == null) throw new Exception("Document DOMSource est null");
// Start XSLT transformation and FOP processing
Line 180 ---> transformer.transform(source, res);
fop = null;
} finally {
out.close();
}
return out;
}

The problem is that ther is an error on the line
transformer.transform(source, res);

Here is the detail of the error message
java.lang.NullPointerException at org.apache.fop.area.AreaTreeHandler.endDocument(AreaTreeHandler.java: 416)
at org.apache.fop.fo.FOTreeBuilder.endDocument(FOTreeBuilder.java:171)
at org.apache.xalan.transformer.ResultTreeHandler.endDocument(ResultTreeHandler.java:192) at org.apache.xalan.transformer.TransformerImpl.transformNode(TransformerImpl.java:1224) at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:668) at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1129) at org.apache.xalan.transformer.TransformerImpl.transform(TransformerImpl.java:1107) at com.adelis.roederer.fop.DecompteSante.convertDocumentToPDF(DecompteSante.java:180)

I looked at the source of the endDocument method of the AreaTreeHandler class. I did not understant why is the Exception thrown :
/**
* End the document.
*
* @throws SAXException if there is some error
*/
public void endDocument() throws SAXException {

finishPrevPageSequence(null);
// process fo:bookmark-tree
Line 416 : --> BookmarkTree bookmarkTree = rootFObj.getBookmarkTree();

Has anybody any idea ? What is this rootFObj ?

Regards,

Xavier



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

Reply via email to