sandesh wrote:
Quote:
Hi,
I have one question regarding XQuery.
Is it possible to construct the Xquery expression dynamically?
Eg:
collection("collectionName")/root/node[@value > 1000]
Here the condition Greater Than or Less Than Depends on User input, So
what I want is,
I would like to have this query in a file which I read during run
time and dynamically set the condition.
Please let me know if it is possible to do and If yes please give a
small example |
Sandesh,
You can do this with a conditional expression in your query. For
example,
you can create a string variable, "op" in the BDB XML query context,
and pass it to
the query, and your query would look like this:
"let $res := (if ($op = 'gt') then
collection('collectionName')/root/node[@value > 1000] else
collection('collectionName')/root/node[@value < 1000]) return $res"
There are other ways to construct such a conditional, including
probably doing it
exclusively with XPath2 constructs.
Regards,
George