Feature #1467
TBX: 0.7.7, add getXpathResponse method iterator
Statut: | New | Début: | 02/09/2015 | |
---|---|---|---|---|
Priorité: | Normal | Echéance: | ||
Assigné à: | - | % réalisé: | 0% |
|
Catégorie: | Toolbox | Temps passé: | - | |
Version cible: | TXM 0.X.X |
Description
Currently, the XPathResult.groovy script/class API provides only two 'all in memory' model methods:
is replaced by:
The Groovy code calling streamingGetXpathResponses can then iterate the results with:
- 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() }
Historique
#1 Mis à jour par Matthieu Decorde il y a environ 10 ans
- Version cible changé de TXM 0.7.8 à TXM 0.8.0a (split/restructuration)
#2 Mis à jour par Serge Heiden il y a presque 10 ans
- Description mis à jour (diff)
#3 Mis à jour par Serge Heiden il y a presque 10 ans
- Description mis à jour (diff)
#4 Mis à jour par Serge Heiden il y a presque 10 ans
- Description mis à jour (diff)
#5 Mis à jour par Sebastien Jacquot il y a plus de 7 ans
- Version cible changé de TXM 0.8.0a (split/restructuration) à TXM 0.8.0
#6 Mis à jour par Matthieu Decorde il y a plus de 6 ans
- Version cible changé de TXM 0.8.0 à TXM 0.X.X