We have a function like this: private void subFonts(SVGDocument doc) { final XPathResult res = (XPathResult) ((XPathEvaluator) doc).evaluate(".//*[local-name()=\"text\"]", doc.getRootElement(), null, XPathResult.ORDERED_NODE_ITERATOR_TYPE, null); for (Node node = res.iterateNext(); node != null; node = res.iterateNext()) {
This used to work with Batik 1.14, but broke when we upgraded to 1.17. Under 1.17, this throws a NullPointerException in res.iterateNext(); because res's iterator is null. I've investigated a little bit and found that the implementation of AbstractDocument.XPathExpr.evaluate has changed, and the code path for ORDERED_NODE_ITERATOR_TYPE creates a new Result((Node) xpath.evaluate(contextNode, XPathConstants.NODE), type); (AbstractDocument.java line 2259 in the 1.17 release) The iterator of a Result is only set when the constructor is called with a NodeList, not a Node, so while I'm not certain that this is the problem, it does seem suspicious. I'm pretty sure that an XPathResult should support iteration when evaluate is called with ORDERED_NODE_ITERATOR_TYPE, so I do believe that our code was correct and 1.14 had the correct behavior here.