I think my problem was that I do my editing in both oXygen and BaseX GUI at the same time, oXygen providing many useful features like completion, key bindings, commenting out of fragments containing comments, etc.
And it must have been in oXygen that I used collection() in my function and got null in return, and then started investigating other ways to reach my aim.
I am writing now primarily in order to test the solution and possibly put it into the mailing list archives, but also with a little hope to get a hint for an out-of-scope issue connected with my use of oXygen/Saxon-EE, before I hit their forums.
So first, to sum up: my problem was that I couldn't replicate the main-module behaviour of "let $x := //whatever" inside a function (the context getting reset) and wanted to get some dynamic solution to that.
The solution appears to simply do "let $x := collection()//whatever".
(the "whatever" is of course appropriately constrained in my call)
Can you guys confirm this, please?
--- And now the private part: the above works in the GUI, but doesn't work in oXygen/Saxon-EE. Any idea of what kludge I may use to get Saxon to replicate the behaviour of the collection() call, so that I could continue to work with both tools at once?
Thanks in advance,
Piotr
On 24/01/12 23:51, Christian Grün wrote:
Hi Piotr,
yes, that's possible; please see the following example:
- choose "Command" in the main window's drop box
- enter the following command in the input field and press return: set bindings a=123
- enter and run the following query: $a
Some more information on the BINDINGS options is found at [1].
Best, Christian
[1] http://docs.basex.org/wiki/Options#BINDINGS
Christian ___________________________
2012/1/24 Piotr Bański bansp@o2.pl:
Dear Christian (and Dimitar),
Thanks for the hints!
Here's the next question then ;-)
(And I think the question may receive an easy answer in the context of the commandline, but I'm asking it in the context of the GUI, which I'm quite happy to use for my testing, before I move on to more serious scenarios)
Is there a way to pass a parameter to a query that I run in the GUI? I'm thinking of passing the path to the database to the query, so that it becomes a global parameter, and so that I can use that string as the argument to doc() inside my function, this way practically achieving what I wanted.
Thanks in advance and good night!
Piotr
On 24/01/12 22:52, Christian Grün wrote:
I would like to find a clean way of referencing the default context of my main module, where I can easily do "let $x := //whatever", but after I move this line to a function declaration.
I'm sorry, the context item will always be reset within functions both in XQuery 1.0 and 3.0, so the only way is to pass on the relevant node. A minor detail: If you put the doc() function inside the function instead of passing it on its result, you might benefit from some more optimizations, as a path expression can only be rewritten for index access if the accessed database is known at compile time.
Hope this helps, Christian