Using Updates in XQJ
Wednesday, 22 September 2010 · 3 messages · last reply 23 Sep 2010
EK
Erdal Karaca22 Sep 2010 21:58 #
I do not seem to be able to update/modify a DOM and return it using the same query.
BaseX complains about update not being possible at that context...
let $x := <root/>
return (insert node <x/> into $x, $x)Is there a way to update and return the DOM using one query or is that not handled by xquery in general?
--
1 + 1 = 10
AW
Andreas Weiler23 Sep 2010 09:54 #
Hi Erdal,
in xquery it's not possible to combine read queries (returning a result) and update queries in one query.
Kind regards,
Andreas
Quoted text · Erdal Karaca · 20 lines
Erdal Karaca schrieb: > I do not seem to be able to update/modify a DOM and return it using > the same query. > BaseX complains about update not being possible at that context... > > let $x := <root/> > return (insert node <x/> into $x, $x) > > Is there a way to update and return the DOM using one query or is that > not handled by xquery in general? > > -- > 1 + 1 = 10 > ------------------------------------------------------------------------ > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >
LK
Lukas Kircher23 Sep 2010 11:54 #
Sorry, I forgot to add basex-talk as a receiver, so
here we go again ...
Sorry for the inconvenience, but BaseX does not support
updating DOM nodes out of the box. But using the transform
enables you to bypass the problem:
let $x := (
copy $c := <root/>
modify (insert node <x/> into $c)
return $c
)
return $xThere's also a section dedicated to this detail on our
website [1].
As Andreas stated earlier XQuery also doesn't
allow to mix up updating and non-updating expressions.
If you want to use the $x variable at a later point the
solution above helps. Otherwise you can omit the
variable declaration and directly return results of the
transform expression.
Hope this helps, regards,
Lukas
[1] http://www.inf.uni-konstanz.de/dbis/basex/xquery#update
Quoted text · Andreas Weiler · 35 lines
On Sep 23, 2010, at 9:54 AM, Andreas Weiler wrote: > Hi Erdal, > > in xquery it's not possible to combine read queries (returning a > result) > and update queries in one query. > > Kind regards, > Andreas > > Erdal Karaca schrieb: >> I do not seem to be able to update/modify a DOM and return it using >> the same query. >> BaseX complains about update not being possible at that context... >> >> let $x := <root/> >> return (insert node <x/> into $x, $x) >> >> Is there a way to update and return the DOM using one query or is >> that not handled by xquery in general? >> >> -- >> 1 + 1 = 10 >> ------------------------------------------------------------------------ >> >> _______________________________________________ >> BaseX-Talk mailing list >> BaseX-Talk at mailman.uni-konstanz.de >> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk >> > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Written for BaseX 6. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery