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


--
Gerrit Imsieke
Geschäftsführer / Managing Director
le-tex publishing services GmbH
Weissenfelser Str. 84, 04229 Leipzig, Germany
Phone +49 341 355356 110, Fax +49 341 355356 510
gerrit.imsi...@le-tex.de, http://www.le-tex.de

Registergericht / Commercial Register: Amtsgericht Leipzig
Registernummer / Registration Number: HRB 24930

Geschäftsführer: Gerrit Imsieke, Svea Jelonek,
Thomas Schmidt, Dr. Reinhard Vöckler
_______________________________________________
BaseX-Talk mailing list
BaseX-Talk@mailman.uni-konstanz.de
https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk

Reply via email to