Project

Profile

Help

Multiple queries

Added by Anonymous over 19 years ago

Legacy ID: #3100091 Legacy Poster: vguiraud (vguiraud)

Hello, Since Saxon 8.4, the same StaticQueryContext object may be used to define multiple queries. I tested this new functionality. I can't define a function on a query and use it in another query. Here is the java code : Configuration iConfiguration = new Configuration(); iConfiguration.setHostLanguage(Configuration.XQUERY); StaticQueryContext iStaticContext = new StaticQueryContext(iConfiguration); iStaticContext.buildDocument(new DOMSource(getPDOM("..."))); DynamicQueryContext iDynContext = new DynamicQueryContext(iConfiguration); XQueryExpression iExpr = iStaticContext.compileQuery("declare namespace test='TEST'; 'i'"); iExpr.evaluate(iDynContext); XQueryExpression iExpr2 = iExpr.getStaticContext().compileQuery("declare function test:FUNC() {'i'}; 'i'"); iExpr2.evaluate(iDynContext); XQueryExpression iExpr3 = iExpr2.getStaticContext().compileQuery("test:FUNC()"); iExpr3.evaluate(iDynContext); Here is the stack trace : java.lang.AssertionError: executable.getFunctionLibrary() is an instance of net.sf.saxon.functions.FunctionLibraryList at net.sf.saxon.query.XQueryFunction.compile(XQueryFunction.java:189) at net.sf.saxon.query.XQueryFunctionLibrary.fixupGlobalFunctions(XQueryFunctionLibrary.java:225) at net.sf.saxon.query.StaticQueryContext.fixupGlobalFunctions(StaticQueryContext.java:984) at net.sf.saxon.query.QueryParser.parseQuery(QueryParser.java:153) at net.sf.saxon.query.QueryParser.makeXQueryExpression(QueryParser.java:71) at net.sf.saxon.query.StaticQueryContext.compileQuery(StaticQueryContext.java:254) How can I do it ? Thanks a lot for your help.


Replies (1)

RE: Multiple queries - Added by Anonymous over 19 years ago

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

Since Saxon 8.4, the same StaticQueryContext object may be used to define multiple queries. Correct. I tested this new functionality. I can't define a function on a query and use it in another query. Also correct. I think you have misunderstood the new functionality. It makes a single StaticQueryContext object serially reusable, so you can do create StaticQueryContext compile Query A run Query A compile Query B run Query B compile Query C run Query C This doesn't mean that anything (e.g. functions) defined in query A is accessible to query B. To do this, you need to use "import module" as defined in the language specification. (In fact, when you use "import module", each module has its own StaticQueryContext object.) Michael Kay

    (1-1/1)

    Please register to reply