- From: Adam Retter <adam@exist-db.org>
- Date: Thu, 25 Aug 2016 12:50:32 +0100
- To: Hans-Juergen Rennau <hrennau@yahoo.de>
- Cc: Christian Grün <christian.gruen@gmail.com>, EXPath ML <public-expath@w3.org>
So... the way I would explain it for eXist is, that the util:eval function example that I gave, executes code within the current XQuery Context, so everything in the host XQuery is available to the dynamically evaluated query. We also have a version of util:eval where you can request a new context if you wanted isolation. On 25 August 2016 at 12:26, Hans-Juergen Rennau <hrennau@yahoo.de> wrote: > Thank you, Adam - interesting. So your example seems to show that you can > leverage the binding of values to external variables (declared within the > expression text) in order to give access to "external" functions, that is, > functions defined in the context of the eval operation. > > Cheers, > Hans-Jürgen > > > Adam Retter <adam@exist-db.org> schrieb am 1:19 Donnerstag, 25.August 2016: > > > Hans, > > You might already know this, but I thought I would mention... there is > nothing that I know of in the spec that would prevent this, as it is > up to the implementation about what the `eval` function does. > > You might also be interested to know that both eXist and MarkLogic > support such a thing with their `eval` function implementations. For > example in eXist: > > xquery version "3.0"; > declare function local:f() { 'hello' }; > let $ exprText: = 'declare variable $func external; $func()' > return util:eval($exprText, false(), (xs:QName("func"), local:f#0)) > > > Cheers Adam. > > 2016-08-24 22:19 GMT+01:00 Hans-Juergen Rennau <hrennau@yahoo.de>: >> Hi Christian, >> >> vermutlich bist Du in Urlaub; falls nicht - kannst Du mir einem Tip >> weiterhelfen? >> >> Gibt es irgendeine Möglichkeit, in einem Ausdruck, der per xquery:eval >> ausgewertet wird, eine Funktion aufzurufen, die in der Umgebeung definiert >> wurde? >> >> Demo-Beispiel: das klappt nicht: >> ------------------------------------------------------ >> declare function local:f() {'hello'}; >> >> let $exprText := '$func()' >> return xquery:eval($exprText, map{'func':local:f#0}) >> ------------------------------------------------------ >> => >> [XPST0008] Undefined variable $func. >> >> Was ich wollte, war, im als Text vorliegenden Ausdruck die Funktion >> local:f() aufrufen, welche in der Umgebung von xquery:eval definiert ist. >> >> Das geht nicht, und vermutlich gibt es grundsätzlich keine Möglichkeit, >> auf >> Funktionen von "außen" zuzugreifen. >> >> Richtig? >> >> Viele Grüße, >> Hans-Jürgen > > > > > -- > Adam Retter > > eXist Developer > { United Kingdom } > adam@exist-db.org > irc://irc.freenode.net/existdb > -- Adam Retter eXist Developer { United Kingdom } adam@exist-db.org irc://irc.freenode.net/existdb
Received on Thursday, 25 August 2016 11:51:02 UTC