Project

Profile

Help

Problem with transformation

Added by Anonymous over 19 years ago

Legacy ID: #3098202 Legacy Poster: vguiraud (vguiraud)

Hello, I use Saxon 8.4 to make a XSL transformation. I call the method "transform" of the class "Controller". The input for the source tree is an instance of DOMSource. The transfomation failed with the exception : Hit uncaught exception java.lang.NullPointerException java.lang.NullPointerException at net.sf.saxon.event.Emitter.setOutputProperties(Emitter.java:96) at net.sf.saxon.event.ResultWrapper.getReceiver(ResultWrapper.java:36) at net.sf.saxon.expr.XPathContextMinor.changeOutputDestination(XPathContextMinor.java:496) at net.sf.saxon.Controller.transformDocument(Controller.java:1446) at net.sf.saxon.Controller.transform(Controller.java:1276) It seems that the method "getPipelineConfiguration" returns null. The same program (with the same input source and the same destination for the result) works with Saxon 8.3 Thanks for you help.


Replies (3)

Please register to reply

RE: Problem with transformation - Added by Anonymous over 19 years ago

Legacy ID: #3098344 Legacy Poster: Michael Kay (mhkay)

I'm puzzled by the stack trace, because the line numbers don't make sense. For example, line 496 in XPathContextMinor is in the comments right at the end of the file. Are you sure this is Saxon 8.4? Is there any chance you could show me what your program is actually doing, or ideally, provide enough information to reproduce it? In particular, what kind of Result object are you passing to the transform() method? Michael Kay

RE: Problem with transformation - Added by Anonymous over 19 years ago

Legacy ID: #3099825 Legacy Poster: vguiraud (vguiraud)

Hello, Here is the code which produces the exception : ======================================================================= StreamResult iStreamResult = new StreamResult(new CharArrayWriter()); XMLEmitter iResult = new XMLEmitter(); iResult.setStreamResult(iStreamResult); DOMSource iSource = new DOMSource(...); System.setProperty("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl"); TransformerFactory iTfactory = TransformerFactory.newInstance(); Templates iTemplates = iTfactory.newTemplates(new StreamSource(new File("...")); iTemplates.newTransformer().transform(iSource, iResult); ======================================================================= Here is the stack trace of the execution : java.lang.NullPointerException at net.sf.saxon.event.Emitter.setOutputProperties(Emitter.java:96) at net.sf.saxon.event.ResultWrapper.getReceiver(ResultWrapper.java:36) at net.sf.saxon.expr.XPathContextMinor.changeOutputDestination(XPathContextMinor.java:364) at net.sf.saxon.Controller.transformDocument(Controller.java:1355) at net.sf.saxon.Controller.transform(Controller.java:1195) I compared the source of the method Emitter.setOutputProperties between the 8.3 and 8.4 version. The only difference between them is the call of the method Emitter.getPipelineConfiguration which returns null in my configuration (the input source of the transformation is a DOMSource and the output is an instance of XMLEmitter). I hope this explanation will help you to find the reason of a such exception. Thanks.

RE: Problem with transformation - Added by Anonymous over 19 years ago

Legacy ID: #3100252 Legacy Poster: Michael Kay (mhkay)

You shouldn't be creating an XMLEmitter yourself: it's not part of the public API. What you're attempting can be done entirely within the scope of the JAXP interfaces. To invoke the XML output method, just do Transformer t = iTemplates.newTransformer(); t.setOutputProperty(OutputKeys.METHOD, "xml"); t.transform(iSource, iResult); There are examples of correct use of the JAXP interface in the sample application TraxExamples.java in the samples/java directory. Michael Kay

    (1-3/3)

    Please register to reply