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

--
Pour préservez l’environnement n’imprimez cet e-mail qu’en cas de nécessité.

Xavier Ottolini
Développeur multimédia

Adelis
37 rue d'Engwiller
67350 La Walck
France
Téléphone : +33 (0) 3 69 20 29 02
Télécopie : +33 (0) 3 88 72 29 19
http://www.adelis.com



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

Reply via email to