qexo-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qexo-general] Using qexo from Java with unusual input & output form


From: Per Bothner
Subject: Re: [Qexo-general] Using qexo from Java with unusual input & output formats
Date: Fri, 11 Sep 2015 22:16:00 +0200
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0



On 09/11/2015 06:11 PM, John Ohno wrote:
It looks like when compiling xquery to JVM bytecode from the command line, the 
context item must still be specified at compile-time. Is there a way to produce 
a class file from an XQuery script without specifying the context item, knowing 
that the context item will be specified at run-time using applyWithFocus?

It depends what you mean by "script".  I'm a bit rusty when it comes to
XQuery, but as I recall there is no such thing as the "context node"
for a module.  The context node is only defined within sub-expressions.
The ApplyWithFocus/evalWithFocus methods evalulate expressions, but
not entire modules.  And compiling to bytecode works at the
level of compiling an entire module.

(The XQuery standard does allow a default context to be set "by the
external environment", but Qexo doesn't support that, as far as I
can tell/remember.)

However, you can use an external variable:

declare variable $contextnode external;

If you look at the getExternal method in XQuery.java you see that
the value of contextnode is looked up in the current dynamic
global environment.   (This is primrily used by Scheme/Lisp
but also used for XQuery external variables.)

You still have to compile the XQuery "script" to a class,
and somehow pass the FastInfoset data to it.  Since I don't know
how your data "flows" it's hard to say.  There hasn't been a lot
of testing of invoking compiled XQuery code from Java.  It might
be easier to call from XQuery a Java routine that returns your data.
--
        --Per Bothner
address@hidden   http://per.bothner.com/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]