Re: Tip?

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

  

Received on Thursday, 25 August 2016 11:27:11 UTC