Package net.sf.saxon.sxpath
Class XPathEvaluator
- java.lang.Object
- 
- net.sf.saxon.sxpath.XPathEvaluator
 
- 
- Direct Known Subclasses:
- XSDAssert.CustomizedXPath
 
 public class XPathEvaluator extends java.lang.ObjectThis class provides a native Saxon API for free-standing evaluation of XPath expressions. This is the primitive XPath interface used internally within Saxon.The preferred API for user applications calling XPath is the s9api XPathCompilerinterface.- Since:
- 8.4
 
- 
- 
Constructor SummaryConstructors Constructor Description XPathEvaluator(Configuration config)Construct an XPathEvaluator with a specified configuration.
 - 
Method SummaryAll Methods Instance Methods Concrete Methods Modifier and Type Method Description XPathExpressioncreateExpression(java.lang.String expression)Prepare (compile) an XPath expression for subsequent evaluation.XPathExpressioncreatePattern(java.lang.String pattern)Prepare (compile) an XSLT pattern for subsequent evaluation.ConfigurationgetConfiguration()Get the Configuration in use.XPathStaticContextgetStaticContext()Get the current static context.protected ExpressionpostProcess(Expression exp, ExpressionVisitor visitor, ContextItemStaticInfo cit)Customize the expression post-optimization.voidsetStaticContext(XPathStaticContext context)Set the static context for compiling XPath expressions.
 
- 
- 
- 
Constructor Detail- 
XPathEvaluatorpublic XPathEvaluator(Configuration config) Construct an XPathEvaluator with a specified configuration.- Parameters:
- config- the configuration to be used. If the XPathEvaluator is to be used to run schema-aware XPath expressions this must be an instance of- EnterpriseConfiguration
 
 
- 
 - 
Method Detail- 
getConfigurationpublic Configuration getConfiguration() Get the Configuration in use.- Returns:
- the Saxon configuration
 
 - 
setStaticContextpublic void setStaticContext(XPathStaticContext context) Set the static context for compiling XPath expressions. This provides more detailed control over the environment in which the expression is compiled, for example it allows namespace prefixes to be declared, variables to be bound and functions to be defined. For most purposes, the static context can be defined by providing and tailoring an instance of theIndependentContextclass. Until this method is called, a default static context is used, in which no namespaces are defined other than the standard ones (xml, xslt, and saxon), and no variables or functions (other than the core XPath functions) are available.- Parameters:
- context- the XPath static context- Setting a new static context clears any variables and namespaces that have previously been declared. 
 
 - 
getStaticContextpublic XPathStaticContext getStaticContext() Get the current static context. This will always return a value; if no static context has been supplied by the user, the system will have created its own. A system-created static context will always be an instance ofIndependentContext- Returns:
- the static context object
 
 - 
createExpressionpublic XPathExpression createExpression(java.lang.String expression) throws XPathException Prepare (compile) an XPath expression for subsequent evaluation.- Parameters:
- expression- The XPath expression to be compiled, supplied as a string.
- Returns:
- an XPathExpression object representing the prepared expression
- Throws:
- XPathException- if the syntax of the expression is wrong, or if it references namespaces, variables, or functions that have not been declared.
 
 - 
postProcessprotected Expression postProcess(Expression exp, ExpressionVisitor visitor, ContextItemStaticInfo cit) throws XPathException Customize the expression post-optimization. This method does nothing, but can be overridden in a subclass- Parameters:
- exp- the expression after optimization
- visitor- an expression visitor that includes static context information
- cit- information about the context item type
- Throws:
- XPathException
 
 - 
createPatternpublic XPathExpression createPattern(java.lang.String pattern) throws XPathException Prepare (compile) an XSLT pattern for subsequent evaluation. The result is an XPathExpression object representing a (pseudo-) expression that when evaluated returns a boolean result: true if the context node matches the pattern, false if it does not.- Parameters:
- pattern- the XSLT pattern to be compiled, supplied as a string
- Returns:
- an XPathExpression object representing the pattern, wrapped as an expression
- Throws:
- XPathException- if the syntax of the expression is wrong, or if it references namespaces, variables, or functions that have not been declared.
- Since:
- 9.1
 
 
- 
 
-