Discussion:
[basex-talk] xquery:eval and bindings argument
Buddy Kresge
2017-06-17 17:01:03 UTC
Permalink
I apologize in advance, because I know the answer will be simple (but I couldn't find an example and have tried all sorts of options).
I am trying to run xquery:eval passing in a string to evaluate and a map of bindings.  Everything I try I get an 'Undefined variable' error.
Here is a simple example I tried in the BaseX Gui. 
let $a := 3let $string := "$a + 1"returnxquery:eval($string, map{"a" : $a}
This is just one attempt, but there were many others.
Again, I know this is going to be a simple mistake I'm making, so apologies to the community in advance.

Thanks,
Buddy
Christian Grün
2017-06-17 21:34:08 UTC
Permalink
Hi Buddy,

You’ll need to add a variable declaration in the query string; see [1]
for examples.

Hope this helps,
Christian

[1] http://docs.basex.org/wiki/XQuery_Module#xquery:eval



On Sat, Jun 17, 2017 at 7:01 PM, Buddy Kresge
Post by Buddy Kresge
I apologize in advance, because I know the answer will be simple (but I
couldn't find an example and have tried all sorts of options).
I am trying to run xquery:eval passing in a string to evaluate and a map of
bindings. Everything I try I get an 'Undefined variable' error.
Here is a simple example I tried in the BaseX Gui.
let $a := 3
let $string := "$a + 1"
return
xquery:eval($string, map{"a" : $a}
This is just one attempt, but there were many others.
Again, I know this is going to be a simple mistake I'm making, so apologies
to the community in advance.
Thanks,
Buddy
Loading...