Hi Jean-Marc (answering on behalf of Dirk… Let’s see who is faster ;),your query will work if you change the xquery:eval call as follows:xquery:eval($query || $exp,$vars)Best,ChristianOn Sat, Feb 1, 2014 at 11:44 AM, jean-marc Mercier <jeanmarc.mercier@gmail.com> wrote:Dirkk, thx for your answer.I am really sorry, but definitively, I don't know how to use xquery:eval with the last release.Following your advise, I tried the following one, but it does not work:declare function local:eval_helper($exp, $args){let $query := 'declare variable $xml external; $xml'let $vars := map { '$xml':= $args }returnxquery:eval('$xml'||$exp,$vars)};declare variable $test := <toto><tata>1</tata></toto>;local:eval_helper('//tata', $test)Could you try yourself ? I mean, can you make the above user case working ? This use case worked fineley with BaseX7.8 beta 6aeaebf, before the external variable correction.
2014-02-01 Dirk Kirsten <dk@basex.org>:Hi Jean-Marc,
external variables now have to be explicitly declared. You can do so by:
declare variable $xml external;
Cheers,
Dirk
> _______________________________________________
On 01/02/14 09:16, jean-marc Mercier wrote:
> Hi,
>
> I am extensively using a function wrapping xquery:eval. My use case is
> roughly the following :
>
> declare function local:eval_helper($exp,
> $args){xquery:eval('$xml'||$exp,map{'$xml' := $args})};
> declare variable $test := <toto><tata>1</tata></toto>;
> local:eval_helper3('//tata', $test)
>
>
> Since the following correction : [1]
> https://github.com/BaseXdb/basex/issues/833, the previous code raises now a
> [XPST0008] Undefined variable $xml.
>
> I have tried several combinations to find a workaround, none are working :
>
> - declare function local:eval_helper($exp,
> $args){xquery:eval(''||$exp,map{'' := $args})};
> ([XPDY0050] Root of the context item must be a document node.).
> - declare function local:eval_helper($exp, $args){xquery:evaluate($arg||$exp)};
>
> [XPTY0019] Steps within a path expression must yield nodes; xs:integer
> found.
> -- declare variable $xml external := "xml", : [XPST0008] Undefined variable
> $xml.
>
> What is the correct workaround ?
>
>
> Cheers
>
> Jean-Marc
>
>
>
> BaseX-Talk mailing list
> BaseX-Talk@mailman.uni-konstanz.de
> https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
>
--
Dirk Kirsten, BaseX GmbH, http://basex.org
|-- Firmensitz: Blarerstrasse 56, 78462 Konstanz
|-- Registergericht Freiburg, HRB: 708285, Geschäftsführer:
| Dr. Christian Grün, Dr. Alexander Holupirek, Michael Seiferle
`-- Phone: 0049 7531 28 28 676, Fax: 0049 7531 20 05 22
_______________________________________________
BaseX-Talk mailing list
BaseX-Talk@mailman.uni-konstanz.de
https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk
_______________________________________________
BaseX-Talk mailing list
BaseX-Talk@mailman.uni-konstanz.de
https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk