Project

Profile

Help

XQuery functions

Added by Anonymous about 17 years ago

Legacy ID: #4372764 Legacy Poster: popol (mrjeje)

Hello, I would like to share the same function declaration between several queries. For that, it is possible to use the same StaticQueryContext instance to execute more than one query ? An exception is thrown when I declare just one time the function. This exception appears during the execution of the second query. The exception is "executable.getFunctionLibrary() is an instance of net/sf.saxon.functions.FunctionLibraryList". Here is an example of what I try to do : The first query contains the function declaration : declare function local:test(...) { .... } ... return local:test(...) The second query uses this function without declare it : ... return local:test(...) Moreover, even if I declare the function in the second query, an exception is thrown : "Duplicate definition of function test". Thanks for your help. Jérôme.


Replies (1)

RE: XQuery functions - Added by Anonymous about 17 years ago

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

This is a known bug, see http://sourceforge.net/tracker/index.php?func=detail&aid=1730717&group_id=29872&atid=397617 There's a patch in Subversion if you feel like rebuilding the product, but otherwise the circumvention is to create a new StaticQueryContext for each query. However, you do need to declare (or import) the function in every query that uses it. The theory is that the StaticQueryContext object is used by the Java application to set context information for use when the query is compiled, and it should not be updated as a result of compiling the query, so the context for the second query is (should be!) exactly the same as the first. Sorry about the inconvenience. Michael Kay Saxonica

    (1-1/1)

    Please register to reply