Project

Profile

Help

Passing a parameter from java into XQuery

Added by Anonymous over 19 years ago

Legacy ID: #2935536 Legacy Poster: amitabh ojha (amitabhojha)

Using Saxon Java XQuery API, one can of course within a java program process further, the output returned by a XQuery. In addition, while using Saxon Java XQuery API, is there a way to pass arguments (say integer numbers or strings) into an XQuery. Lets say there is an application Abc.java and inside it we are executing an XQuery “adder.xql” contents of which are as follows :- declare function local:adder ($x, $y) { $x + $y }; local:adder (2,6) Now instead of hard coding the arguments 2 and 6 into the statement local:adder (2, 6) as I have done above, is there a way that one could pass the arguments 2 and 6 into the XQuery dynamically at java command line as follows (without resorting to synthesizing the XQuery “adder.xql” itself through a string concatenation operation in java) :- java Abc 2 6


Replies (1)

RE: Passing a parameter from java into XQuery - Added by Anonymous over 19 years ago

Legacy ID: #2935733 Legacy Poster: Michael Kay (mhkay)

Declare an external variable in the query: declare variable $x external; and then supply its value using the setParameter() method on the DynamicQueryContext object. Michael Kay

    (1-1/1)

    Please register to reply