Project

Profile

Help

Saxon 8.1.1 declareVariable problem

Added by Anonymous over 19 years ago

Legacy ID: #2900610 Legacy Poster: Yana Kadiyska (ykadiyska)

Hello, newby here so sorry if this is an obvious mistake. I need to declare a variable that my query uses. I have the following code: final Configuration config; DynamicQueryContext dynamicContext ; StaticQueryContext staticContext; //some instantiation here dynamicContext.setContextNode(staticContext.buildDocument( new DOMSource(dom)) ); String query="for $a in $root//price return $a"; Variable thisVar = Variable.make("root"); thisVar.setValue(dynamicContext.getContextNode() ); staticContext.declareVariable(thisVar); XQueryExpression exp = staticContext.compileQuery(query); At which point I get a runtime exception that variable $root is not declared (I know the query is unnecessarily complex but for purposes of my app I prefer not to alter the query). The binding I'm trying to achieve is equivalent to let $root:=doc(...). Also, through some debugging, I know the binding makes into the variables map of the static context object...not sure why it's not found when compile is called. Thanks for any help


Replies (1)

RE: Saxon 8.1.1 declareVariable problem - Added by Anonymous over 19 years ago

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

Your query needs to declare the variable $root as an external variable: declare variable $root external; Michael Kay Saxonica Limited (Sorry for the delayed response, SourceForce hasn't been notifying me of these postings)

    (1-1/1)

    Please register to reply