Hi there,
I am using basex 6.2.7 (gui version) from the maven repo.
Using eval (see below) gives me: Fehler: [XPST0017] Unknown function "local:name1(...)".
If I call local:name1() directly, it works. Running the same script with Saxon (using saxon:evaluate) works, too.
declare function local:name1() { let $msg := "hello from name1" return <msg>{$msg}</msg> };
declare function local:dispatch($e as element()) { let $func := local-name($e) let $res := basex:eval(concat("local:", $func, "()")) return $res };
let $elem := <name1>bla</name1> (: return local:name1() :) return local:dispatch($elem)
Regards,
Max
Dear Max,
in BaseX, the eval() function ignores the existing context. This decision was taken to simplify numerous optimizations. As an example, in the following query, local:n() will be inlined as removed by the dead code detector:
declare function local:n() { 1 }; local:n()
Some code optimizations could be suppressed if eval() functions are encountered in the query. This is subject to further work, though.
Sorry; hope this helps anyway, Christian
On Mon, Sep 27, 2010 at 8:57 AM, Maximilian Gärber mgaerber@arcor.de wrote:
Hi there,
I am using basex 6.2.7 (gui version) from the maven repo.
Using eval (see below) gives me: Fehler: [XPST0017] Unknown function "local:name1(...)".
If I call local:name1() directly, it works. Running the same script with Saxon (using saxon:evaluate) works, too.
declare function local:name1() { let $msg := "hello from name1" return <msg>{$msg}</msg> };
declare function local:dispatch($e as element()) { let $func := local-name($e) let $res := basex:eval(concat("local:", $func, "()")) return $res };
let $elem := <name1>bla</name1> (: return local:name1() :) return local:dispatch($elem)
Regards,
Max _______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
Hi Christian,
thanks for clarifying this. To be sure I got this right: The xquery passed to basex:eval() has to be self-contained, no way to refer to anything that's not literally passed to the function?
Regards,
Maxi
2010/9/28 Christian Grün christian.gruen@gmail.com:
Dear Max,
in BaseX, the eval() function ignores the existing context. This decision was taken to simplify numerous optimizations. As an example, in the following query, local:n() will be inlined as removed by the dead code detector:
declare function local:n() { 1 }; local:n()
Some code optimizations could be suppressed if eval() functions are encountered in the query. This is subject to further work, though.
Sorry; hope this helps anyway, Christian
On Mon, Sep 27, 2010 at 8:57 AM, Maximilian Gärber mgaerber@arcor.de wrote:
Hi there,
I am using basex 6.2.7 (gui version) from the maven repo.
Using eval (see below) gives me: Fehler: [XPST0017] Unknown function "local:name1(...)".
If I call local:name1() directly, it works. Running the same script with Saxon (using saxon:evaluate) works, too.
declare function local:name1() { let $msg := "hello from name1" return <msg>{$msg}</msg> };
declare function local:dispatch($e as element()) { let $func := local-name($e) let $res := basex:eval(concat("local:", $func, "()")) return $res };
let $elem := <name1>bla</name1> (: return local:name1() :) return local:dispatch($elem)
Regards,
Max _______________________________________________ BaseX-Talk mailing list BaseX-Talk@mailman.uni-konstanz.de https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
thanks for clarifying this. To be sure I got this right: The xquery passed to basex:eval() has to be self-contained, no way to refer to anything that's not literally passed to the function?
…exactly. Feedback on other users is welcome on this one: Who else actually using the eval() function out there? Would you like to have the actual context embedded?
Christian
basex-talk@mailman.uni-konstanz.de