Non-updating Expressions: copy/modify/return. Multiple for-clauses inside modify
Hi all, hi Christian, for my queries I have to modify some legacy xml-documents. The copy/modify/return-expression works fine with one for-clause. But I have to modify different elements. I can't figure out, how to chain the for-clauses. Working Example: copy $doc := $document modify ( let $first_elements := $doc//element-name for $element in $first_elements let $target := $element/@target let $htm_anchor := substring-after($target, '#') return replace value of node $element/@target with 'xyz' || $htm_anchor ) return $doc This is working for one for-clause. But I have to do a lot more with different elements for example: let $second_element := $doc//element-name-second for $ele in $second_elements let $... return ... The returning document should contain all modifications. How can I chain the for-clauses inside modify? Thanks for a hint in advance. Günter
Hi Günter, The chaining of update operations just got easier with the extension of our "update" operator [1,2]. I’d be interested in your feedback. Cheers, Christian [1] http://docs.basex.org/wiki/XQuery_Update#update [2] http://files.basex.org/releases/latest/ On Fri, Apr 29, 2016 at 1:16 PM, Günter Dunz-Wolff <kleist@mail.dunzwolff.de> wrote:
Hi all, hi Christian,
for my queries I have to modify some legacy xml-documents. The copy/modify/return-expression works fine with one for-clause. But I have to modify different elements. I can't figure out, how to chain the for-clauses.
Working Example:
copy $doc := $document modify ( let $first_elements := $doc//element-name for $element in $first_elements let $target := $element/@target let $htm_anchor := substring-after($target, '#') return replace value of node $element/@target with 'xyz' || $htm_anchor ) return $doc
This is working for one for-clause. But I have to do a lot more with different elements for example:
let $second_element := $doc//element-name-second for $ele in $second_elements let $... return ...
The returning document should contain all modifications. How can I chain the for-clauses inside modify?
Thanks for a hint in advance.
Günter
Hi Christian, thanks for the hint. I'll try it after updating my system. Looks promising. Cheers, Günter
Am 29.04.2016 um 13:39 schrieb Christian Grün <christian.gruen@gmail.com>:
Hi Günter,
The chaining of update operations just got easier with the extension of our "update" operator [1,2]. I’d be interested in your feedback.
Cheers, Christian
[1] http://docs.basex.org/wiki/XQuery_Update#update [2] http://files.basex.org/releases/latest/
On Fri, Apr 29, 2016 at 1:16 PM, Günter Dunz-Wolff <kleist@mail.dunzwolff.de> wrote:
Hi all, hi Christian,
for my queries I have to modify some legacy xml-documents. The copy/modify/return-expression works fine with one for-clause. But I have to modify different elements. I can't figure out, how to chain the for-clauses.
Working Example:
copy $doc := $document modify ( let $first_elements := $doc//element-name for $element in $first_elements let $target := $element/@target let $htm_anchor := substring-after($target, '#') return replace value of node $element/@target with 'xyz' || $htm_anchor ) return $doc
This is working for one for-clause. But I have to do a lot more with different elements for example:
let $second_element := $doc//element-name-second for $ele in $second_elements let $... return ...
The returning document should contain all modifications. How can I chain the for-clauses inside modify?
Thanks for a hint in advance.
Günter
participants (2)
-
Christian Grün -
Günter Dunz-Wolff