FOR LOOP in xpath reg-ex
for $item in (/root/Json[1]/item[*])
return
$item/account[1]/text()
the above statement return no.of items, whereas applying replacement is not working
for $item in (/root/Json[1]/item[*])
return
replace($item/account[1]/text(),'abc','xyz')
It returns only the top row.
Comments
-
the built-in Data Bank and Transformer tools currently support XPaths that return nodes from the original document and not strings or a combination of nodes and strings
The work around mentioned in various other threads on the forums involve using "parse-xml" function. For example:
for $item in (/root/Json[1]/item[*]) return parse-xml(concat("<root>", replace($item/account[1]/text(), "abc", "xyz"), "</root>"))/root/text()
0 -
As an aside, the "only fetches the first value" issue has to do with SOAtest using JAXP to evaluate the XPath. Some general information about this can also be found on stackoverflow. Internally, SOAtest would have to use a different XPath API under the hood.
0 -
the built-in Data Bank and Transformer tools currently support XPaths that return nodes from the original document and not strings or a combination of nodes and strings
For the next release, XPaths that return lists of strings will work as expected. Using "parse-xml" to convert the list of strings to a list of text nodes will no longer be needed.
0