Any xpath expression that returns anything but a nodeset will fail. For example these three queries all result in exception. boolean(//person) string(//person[first='John' and last='Smith']/first) count(//person[first='John' and last='Smith']) To support this the we will need to update the NodeSet implementation to support other datatypes. I've added unit tests to the test suite that expose this problem
Fixed, Closed.
Problem in XPathQueryResolver.ResultSet.prepareNextNode() when iterating over Collection and empty document i.e. '<?xml version="1.0" encoding="UTF-8"?>' is returned. Then the node returned by the document is null and a an exception is thrown at xp.execute(xpc, n, pfx) -- (exception attached at end). Checking for node != null fixes this problem. I'm not sure though how the empty document go into the DB in the first place. DBDocument d = (DBDocument) context.getDocument(keySet[keyPos++]); // dom2str(d) == "<?xml version="1.0" encoding="UTF-8"?>" if (d == null) { continue; } Node n = d.getDocumentElement(); // n == null if(n == null) continue; // added to fix the problem Exception thrown by xp.execute(xpc, n, pfx): java.lang.IllegalArgumentException: Node must be non-null for getDTMHandleFromNode at org.apache.xml.dtm.ref.DTMManagerDefault.getDTMHandleFromNode (DTMManagerDefault.java:543) at org.apache.xpath.XPathContext.getDTMHandleFromNode (XPathContext.java:220) at org.apache.xpath.XPath.execute(XPath.java:274) at org.apache.xindice.core.query.XPathQueryResolver$ResultSet.prepareNextNode (XPathQueryResolver.java:1211) at org.apache.xindice.core.query.XPathQueryResolver$ResultSet.getNextNode (XPathQueryResolver.java:1267) at org.apache.xindice.core.query.QueryUtil.queryResultsToDOM (QueryUtil.java:75) at org.apache.xindice.core.query.QueryUtil.queryResultsToDOM (QueryUtil.java:134) at org.apache.xindice.client.xmldb.embed.CollectionImpl.query (CollectionImpl.java:437) at org.apache.xindice.client.xmldb.XindiceCollection.query (XindiceCollection.java:259) at org.apache.xindice.client.xmldb.services.QueryService.query (QueryService.java:90) at edu.indiana.extreme.gsx.util.XindiceUtil.executeXPath (XindiceUtil.java:514) Thanks. --Yogesh
Thanks for your observation. Can you also turn on DEBUG and see may be there are some ignored exceptions preceding this?
Yogesh, any updates?
Added test for null getDocumentElement() with log statement.