context for util:eval
Monday, 31 October 2011 · 7 messages · last reply 1 Nov 2011
AB
Andy Bunce31 Oct 2011 13:20 #
I notice Basex has a util:eval function similar to the eXist db one<http://demo.exist-db.org/exist/functions/util/eval>however it is not clear for the BaseX version what the inherited context,
if any, is. The example on the eXist site:
let $a := "Hello"
return util:eval("$a")Fails with an undefined variable $a with BaseX 7.0.1
/Andy
CG
Christian Grün31 Oct 2011 18:02 #
Hi Andy,
as you already guessed, and to reduce side effects, the util:eval() function in BaseX uses its very own context.
Hope this helps,
Christian
Quoted text · Andy Bunce · 11 lines
On Mon, Oct 31, 2011 at 1:20 PM, Andy Bunce <bunce.andy at gmail.com> wrote: > I notice Basex has a util:eval function similar to the eXist db one however > it is not clear for the BaseX version what the inherited context, if any, > is. The example on the eXist site: > > let $a := "Hello" > return util:eval("$a") > > Fails with an undefined variable $a with BaseX 7.0.1 > > /Andy
AB
Andy Bunce31 Oct 2011 18:19 #
Ok, I understand, but a bit of a shame.
The functionality I want is just functx:dynamic-path
<http://www.xqueryfunctions.com/xq/functx_dynamic-path.html> Is just using the functx library via the repo likely to be the most efficient approach for BaseX?
/Andy
On Mon, Oct 31, 2011 at 5:02 PM, Christian Grün
<christian.gruen at gmail.com>wrote:
Quoted text · Christian Grün · 22 lines
> Hi Andy, > > as you already guessed, and to reduce side effects, the util:eval() > function in BaseX uses its very own context. > > Hope this helps, > Christian > _______________________________________ > > On Mon, Oct 31, 2011 at 1:20 PM, Andy Bunce <bunce.andy at gmail.com> wrote: > > I notice Basex has a util:eval function similar to the eXist db one > however > > it is not clear for the BaseX version what the inherited context, if any, > > is. The example on the eXist site: > > > > let $a := "Hello" > > return util:eval("$a") > > > > Fails with an undefined variable $a with BaseX 7.0.1 > > > > /Andy >
MS
Michael Seiferle31 Oct 2011 18:55 #
Hi Andy,
it sure is the most comfortable approach, I myself use the functx library via our repository extension.
Quoted text · Andy Bunce · 1 line
> REPO INSTALL http://files.basex.org/xar/functx-1.0.xar
Hope this helps :-)
Michael
Quoted text · Andy Bunce · 2 lines
Am 31.10.2011 um 18:19 schrieb Andy Bunce: > Is just using the functx library via the repo likely to be the most efficient approach for BaseX?
FG
Florent Georges31 Oct 2011 20:19 #
Quoted text · Michael Seiferle · 4 lines
Michael Seiferle wrote: > it sure is the most comfortable approach, I myself use the > functx library via our repository extension. > REPO INSTALL http://files.basex.org/xar/functx-1.0.xar
You can even find it directly from CXAN ;-)
http://cxan.org/pkg/functx
--
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/
AB
Andy Bunce1 Nov 2011 13:17 #
There seems to be a namespace issue when using nested modules... This works..
import module namespace functx="http://www.functx.com";
functx:capitalize-first("test")I define foo.xy..
module namespace foo = "http://example.org/module1";
import module namespace functx="http://www.functx.com";
declare function foo:first($s){
functx:capitalize-first($s)
};
Then execute
import module namespace foo = "http://example.org/module1" at "foo.xq";
foo:first("aa")I get the error
Query: import module namespace foo = "http://example.org/module1" at "foo.xq";
foo:first("aa")
Error: [FONS0004] Namespace prefix not declared:
"functx:Different_number_of_names".This works:
import module namespace foo = "http://example.org/module1" at "foo.xq";
declare namespace functx="http://www.functx.com";
foo:first("aa")But surely I should not be required to define the functx namespace here?
/Andy
Quoted text · Florent Georges · 16 lines
On Mon, Oct 31, 2011 at 7:19 PM, Florent Georges <lists at fgeorges.org> wrote: > Michael Seiferle wrote: > > > it sure is the most comfortable approach, I myself use the > > functx library via our repository extension. > > REPO INSTALL http://files.basex.org/xar/functx-1.0.xar > > You can even find it directly from CXAN ;-) > > http://cxan.org/pkg/functx > > -- > Florent Georges > http://fgeorges.org/ > http://h2oconsulting.be/ >
CG
Christian Grün1 Nov 2011 22:19 #
Thanks Andy,
this problem seems to be related with GitHib issue 133..
https://github.com/BaseXdb/basex/issues/133
..which is why I have added your observation to this bug entry.
Christian
Quoted text · Andy Bunce · 60 lines
On Tue, Nov 1, 2011 at 1:17 PM, Andy Bunce <bunce.andy at gmail.com> wrote: > There seems to be a namespace issue when using nested modules... > This works.. > > import module namespace functx="http://www.functx.com"; > functx:capitalize-first("test") > > I define foo.xy.. > > module namespace foo = "http://example.org/module1"; > import module namespace functx="http://www.functx.com"; > declare function foo:first($s){ > functx:capitalize-first($s) > }; > > Then execute > import module namespace foo = "http://example.org/module1" at "foo.xq"; > foo:first("aa") > > I get the error > Query: import module namespace foo = "http://example.org/module1" at > "foo.xq"; > > foo:first("aa") > Error: [FONS0004] Namespace prefix not declared: > "functx:Different_number_of_names". > > This works: > import module namespace foo = "http://example.org/module1" at "foo.xq"; > declare namespace functx="http://www.functx.com"; > foo:first("aa") > > But surely I should not be required to define the functx namespace here? > > /Andy > > On Mon, Oct 31, 2011 at 7:19 PM, Florent Georges <lists at fgeorges.org> wrote: >> >> Michael Seiferle wrote: >> >> > it sure is the most comfortable approach, I myself use the >> > functx library via our repository extension. >> > REPO INSTALL http://files.basex.org/xar/functx-1.0.xar >> >> You can even find it directly from CXAN ;-) >> >> http://cxan.org/pkg/functx >> >> -- >> Florent Georges >> http://fgeorges.org/ >> http://h2oconsulting.be/ > > > _______________________________________________ > BaseX-Talk mailing list > BaseX-Talk at mailman.uni-konstanz.de > https://mailman.uni-konstanz.de/mailman/listinfo/basex-talk > >
Written for BaseX 7.0. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery