From: Alex Miller <alexdmiller@ya...> - 2006-07-10 20:49:51
I need to call an external function on a Java object from XQuery but I
need the object to be a pre-existing instance with state. This rules
out using the support for calling either static Java methods or
constructing a new Java instance and calling methods on it (as I can't
get the state injected to the object from outside the XQuery).
Conceptually, I want to progamatically do this:
declare function foo($p1 as xs:string, $p2 as xs:string) as node()
where the object that is receiving the call is an object I created that
can have some prior state.
The two options I have been exploring are:
1) Declare an external function, register a function with the function
library, and give the function object itself the state during setup.
2) Declare a global variable and programatically declare that
variable's value at runtime to be some pre-defined object with state.
Then, use the Java function binding to call a method on that stateful
object and pass it parameters from the XQuery.
I think #1 is conceptually what I what to do. I can't figure out how
to use the API to register and define a function invocation. I got
lost in all the FunctionLibrary / XQueryFunctionLibrary / Executable /
UserFunction / XQueryFunction classes and seemed to be going in
circles. I'm not sure how to start instantiating or modifying any of
these objects in a useful way. Does anyone have an example of such a
I think if I could get past my issue from my previous email regarding
programatic declaration of an external parameter, that I could get #2
to work although it feels a bit kludgier for my needs.