java.lang.NullPointerException while streaming
Added by Gerben Abbink over 10 years ago
Hi,
I get a NullPointerException while transforming an XSLT Stylesheet with an xsl:stream instruction. I have included the XSLT and XML files and the stack dump (see attachments). I am using SaxonEE9-5-1-5J on Windows 7 64-bit.
There are no problems if I uncomment the xsl:stream instruction.
Here is a small part of the XLST (see attachment):
<xsl:output method="xml"/>
<xsl:template match="/">
<xsl:stream href="Example1.xml">
<count>
<xsl:for-each select="BookCatalogue">
<xsl:iterate select="Book">
Here is a small part of my Java code:
XsltTransformer transformer = executable.load();
transformer.setBaseOutputURI(xsltInputData.getURL());
transformer.setDestination(getDestination(transformer, outputStream));
transformer.setSource(new XMLBlueprintSAXSource(xmlInputData, entityResolver, errorWriter));
transformer.transform(); <-- exception occurs here.
Here is a small part of the stack dump (see attachments):
com.saxonica.stream.watch.WatchManager.startDocument(WatchManager.java:134)
net.sf.saxon.event.ProxyReceiver.startDocument(ProxyReceiver.java:109)
net.sf.saxon.event.StartTagBuffer.startDocument(StartTagBuffer.java:89)
What's going on?
- Gerben
Example1.xsl (759 Bytes) Example1.xsl | |||
Example1.xml (937 Bytes) Example1.xml | |||
Stack.txt (920 Bytes) Stack.txt |
Replies (5)
Please register to reply
RE: java.lang.NullPointerException while streaming - Added by Michael Kay over 10 years ago
Many thanks for reporting it. I'll transfer it across to the bugs area.
I'm not greatly surprised; we've written a very large number of tests for streaming since 9.5 was released, and we know that quite a few of them fail on 9.5: either by reporting that constructs are unstreamable, or by crashing. Our focus has been to get it all working on 9.6, but we will fix problems reported by users when we can.
RE: java.lang.NullPointerException while streaming - Added by Michael Kay over 10 years ago
Please track this here:
RE: java.lang.NullPointerException while streaming - Added by Michael Kay over 10 years ago
I'm currently not able to reproduce this. It's working fine for me, giving the output 3 as expected. So we need to find out more about how you are running it to see if we can isolate the cause.
The stack trace shows it failing in the streaming code, but isn't helpful. The line number indicates a line that on first inspection seems to have no possible way to throw an NPE. (So either first inspection is wrong, or the line number is wrong). It's right at the beginning of processing the source file, so I wonder if it's something like a failure to read or open the source file; but that's certainly not evident from the stack trace.
Can you reproduce the problem if you run this from the command line?
I'm not sure why you are using match="/" on the initial template - the source document doesn't seem to be used, in which case I generally use name="main" and run with -it:main in preference.
RE: java.lang.NullPointerException while streaming - Added by Gerben Abbink over 10 years ago
It took me a while, but i think i have found the source of the problem:
Configuration configuration = new com.saxonica.config.EnterpriseConfiguration();
// exception if not commented, no exception if commented.
configuration.setConfigurationProperty(FeatureKeys.OPTIMIZATION_LEVEL, String.valueOf(Optimizer.NO_OPTIMIZATION));
If i use configuration.setConfigurationProperty() i get an exception in XsltTransformer.transform() in combination with xsl:stream (see XSLT and XML in previous email). If i comment the line i get no exception.
See attachment for small demo that shows the exception.
RE: java.lang.NullPointerException while streaming - Added by Michael Kay over 10 years ago
Great, thanks.
Yes, it doesn't surprise me that streaming breaks if optimization is turned off; preparing an expression for streaming is quite tied up with the optimization process. I'll probably fix this e.g. by ignoring the optimization setting when processing streamed constructs.
Michael Kay
Please register to reply