Feature #1467

Updated by Serge Heiden over 4 years ago


the XPathResult.groovy script/class API provides only two 'all in memory' model methods:
* getXpathResponse returns the first match of an XPath
* getXpathResponses returns all the string values of the matches of an XPath as an array of strings

To be able to process large XML files with lots of elements matching a given XPath, we need to add to the API a way not to store the intermediate array of strings in memory. The new method can limit the memory consumption used to transmit the result to only the one used for the list of DOM result nodes.

B) the getXpathResponse* methods cannot return elements attribute values, for example for XPaths returning attribute values

h3. Solution A)

Add a new streamingGetXpathResponses method with the code of getXpathResponses where:
NodeList nodes = (NodeList) result;
for (int i = 0; i < nodes.getLength(); i++) {
//println nodes.item(i)
return xresult
is replaced by:
NodeList nodes = (NodeList) result
return nodes

The Groovy code calling streamingGetXpathResponses can then iterate the results with:
nodes.each { println it.getNodeValue() }

h3. Solution B)

Check in those methods the type of values returned by the XPath processor.