Feature #1467

TBX: 0.7.7, add getXpathResponse method iterator

Added by Serge Heiden over 3 years ago. Updated 28 days ago.

Status:New Start date:09/02/2015
Priority:Normal Due date:
Assignee:- % Done:

0%

Category:Toolbox Spent time: -
Target version:TXM X.X

Description

Currently, 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.

Solution

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)
            xresult.add((nodes.item(i).getNodeValue()));
        }
        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() }

History

#1 Updated by Matthieu Decorde over 3 years ago

  • Target version changed from TXM 0.7.8 to TXM 0.8.0a (split/restructuration)

#2 Updated by Serge Heiden over 3 years ago

  • Description updated (diff)

#3 Updated by Serge Heiden over 3 years ago

  • Description updated (diff)

#4 Updated by Serge Heiden over 3 years ago

  • Description updated (diff)

#5 Updated by Sebastien Jacquot 10 months ago

  • Target version changed from TXM 0.8.0a (split/restructuration) to TXM 0.8.0

#6 Updated by Matthieu Decorde 28 days ago

  • Target version changed from TXM 0.8.0 to TXM X.X

Also available in: Atom PDF