#317 NPE with JAXP XPath selecting () as string

v8.3
closed
5
2012-10-08
2005-02-23
Michael Kay
No

If the JAXP XPath API is used to run a path expression
whose result is an empty sequence, and the result is
requested as a string, a NullPointerException occurs:
typically

Exception in thread "main" java.lang.NullPointerException
at
net.sf.saxon.xpath.XPathExpressionImpl.evaluate(XPathExpressionImpl.java:222)
at
net.sf.saxon.xpath.XPathExpressionImpl.evaluate(XPathExpressionImpl.java:267)

Source fix:

in net.sf.saxon.xpath.XPathExpressionImpl line 222, change

            Item first = iter.next();
            return first.getStringValue();

to

            Item first = iter.next();
            if (first == null) return "";
            return first.getStringValue();

Michael Kay

Discussion

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks