XUDY0016 error
Hello,
I get this error: [XUDY0016] Documents in path '...' can only be replaced once.
Code : XUDY0016 Description : In a replace expression, a target is replaced more than once. Examples : let $a := <x>x</x>/node() return (replace node $a with <a/>, replace node $a with <b/>)
Is there a BaseX option to allow multiple "replace" in one query on the same document ?
Hi Britney,
last one (before I’m on leave):
Quoted text · Britney Fox · 3 lines
> Description : In a replace expression, a target is replaced more than once. > Examples : let $a := <x>x</x>/node() return (replace node $a with <a/>, > replace node $a with <b/>)
The W3 XQuery Update Facility does not allow you to replace the same some multiple times. In practice, this turns out to be a very helpful restriction, because it helps you to find bugs in your code (it never makes sense to replace the same node multiple times, because only one replacement would be visible in the result anyway).
Quoted text · Britney Fox · 2 lines
> Is there a BaseX option to allow multiple "replace" in one query on the same > document ?
As long as you don’t try to replace the same node, that’s absolutely possible. An example:
copy $xml := <xml><a/><b/></xml>
modify (
replace node $xml/a with <abc/>,
replace node $xml/b with <def/>
)
return $xmlI’m not 100% sure which result you would have expected in your original example. Maybe the following query matches your requirements?
let $a := <x>x</x>/node()
return (
replace node $a with (<b/>, <c/>)
)Fore more details on the semantics of XQuery Update, feel free to check out our documentation [1] or Xavier Franc’s nice introduction [2].
Cheers, C.
[1] http://docs.basex.org/wiki/XQuery_Update [2] http://www.xmlmind.com/tutorials/XQueryUpdate/
Written for BaseX 8.6. BaseX may have changed since: please check the current documentation.