On 18/10/2011 22:16, Suman Ganta wrote:

Hello Saxonica,

      We do expression analysis to figure out usage of specific functions in it. For that, we are parsing (staticContext.compileQuery(exp)) the expression and getting net.sf.saxon.XQueryExpression object back and getting net.sf.saxon.expr.Expression out of it. This expression object is analyzed to figure out usage of specific functions. Since we are not really executing (iterating the results) we do not want to do regular parsing to get net.sf.saxon.expr.Expression. Is there a way to get net.sf.saxon.expr.Expression without getting XQueryExpression so that the compile time for each expression can be reduced? We are using Saxon-PE 9.3.0.5.

 

Regards,

-Suman.


I'm not sure what you mean by "regular parsing". I would have thought parsing is exactly what you need to be done, while the other stages of compilation (binding of variable and function references, type analysis, optimization) are superfluous.

The parsing stage and the building of the raw expression tree are done by calling QueryParser.parseQuery(). I'm sure if you follow the logic of the source code you can see which parts of the process you need and which you don't. The methods are all public, so I don't see any problem in diving down into lower-level interfaces than XQueryExpression if you want to do so. But you need to be aware that when you call low-level interfaces (a) there's less stability from one release to the next, and (b) you have to be self-sufficient and prepared to work from the source code - there's less user-level documentation.

Michael Kay
Saxonica