Christian, thanks for your XQuery support. Will pay back in XSLT support ;)
I made this change, and I also made the xquery:eval statements compatible with 7.8: https://github.com/gimsieke/sxedit/blob/master/lib/basex/restxq/sxedit.xqm
Gerrit
On 16.02.2014 15:40, Christian Grün wrote:
Hi Gerrit,
the return clause of the transform (copy) expression does not allow update operations. What you can do is to wrap your code in a FLWOR expression:
let $doc := copy $doc := parse-xml($wrapper) modify ( for $n in $doc/descendant-or-self::*[starts-with(local-name(), '_____')] let $repl := replace(local-name($n), '^_____', ''), $uri := namespace-uri($n) return rename node $n as QName($uri, $repl) ) return $doc return replace node db:open($doc/*:frag/@db, $doc/*:frag/@doc)//*[path() eq $doc/*:frag/@xpath] with $doc/*:frag/*
You can also use the (for now BaseX-specific) "update" keyword, e. g. as follows:
let $doc := parse-xml($wrapper) update ( for $n in descendant-or-self::*[starts-with(local-name(), '_____')] let $repl := replace(local-name($n), '^_____', ''), $uri := namespace-uri($n) return rename node $n as QName($uri, $repl) ) return replace node db:open($doc/*:frag/@db, $doc/*:frag/@doc)//*[path() eq $doc/*:frag/@xpath] with $doc/*:frag/*
Hope this helps, Christian