|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object net.sf.saxon.sxpath.XPathEvaluator
public class XPathEvaluator
This class provides a native Saxon API for free-standing evaluation of XPath expressions. Unlike the
JAXP API offered by XPathEvaluator
it exposes Saxon classes and interfaces
and thus provides a more strongly-typed interface with greater control over the detailed behaviour.
However, the preferred API for user applications calling XPath is the s9api XPathCompiler
interface.
Constructor Summary | |
---|---|
XPathEvaluator()
Default constructor. |
|
XPathEvaluator(Configuration config)
Construct an XPathEvaluator with a specified configuration. |
Method Summary | |
---|---|
XPathExpression |
createExpression(String expression)
Prepare (compile) an XPath expression for subsequent evaluation. |
XPathExpression |
createPattern(String pattern)
Prepare (compile) an XSLT pattern for subsequent evaluation. |
XPathVariable |
declareVariable(String uri,
String localName)
Declare a variable, making it available for use within a subsequently-compiled XPath expression. |
Configuration |
getConfiguration()
Get the Configuration in use. |
NamespaceResolver |
getNamespaceResolver()
Get the external namespace resolver, if one has been set using setNamespaceResolver(net.sf.saxon.om.NamespaceResolver) |
XPathStaticContext |
getStaticContext()
Get the current static context. |
void |
setDefaultElementNamespace(String uri)
Set the default namespace for elements and types |
void |
setNamespaceResolver(NamespaceResolver namespaceResolver)
Set the external namespace resolver to be used. |
void |
setStaticContext(XPathStaticContext context)
Set the static context for compiling XPath expressions. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public XPathEvaluator()
Configuration
that is implicitly created by this constructor,
which is accessible using the getConfiguration()
method.
public XPathEvaluator(Configuration config)
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 |
---|
public Configuration getConfiguration()
public XPathVariable declareVariable(String uri, String localName)
XPathDynamicContext.setVariable(XPathVariable, net.sf.saxon.om.ValueRepresentation)
.
Any external variable used in an XPath expression must be declared before the XPath expression
is compiled.
uri
- The namespace URI of the variable name. Use "" for the null namespace.localName
- The local part of the variable name.
public void setStaticContext(XPathStaticContext context)
IndependentContext
class.
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.
context
- the XPath static context
Setting a new static context clears any variables and namespaces that have previously been declared.
public XPathStaticContext getStaticContext()
IndependentContext
public XPathExpression createExpression(String expression) throws XPathException
expression
- The XPath expression to be compiled, supplied as a string.
XPathException
- if the syntax of the expression is wrong, or if it references namespaces,
variables, or functions that have not been declared.public XPathExpression createPattern(String pattern) throws XPathException
pattern
- the XSLT pattern to be compiled, supplied as a string
XPathException
- if the syntax of the expression is wrong, or if it references namespaces,
variables, or functions that have not been declared.public void setNamespaceResolver(NamespaceResolver namespaceResolver)
namespaceResolver
- The namespace resolver, which maintains a mapping of prefixes to URIs.
Any namespace prefix used in the XPath expression is resolved using this namespaceResolver.public NamespaceResolver getNamespaceResolver()
setNamespaceResolver(net.sf.saxon.om.NamespaceResolver)
IndependentContext
object used as the XPathStaticContext
also acts as the NamespaceResolver
.public void setDefaultElementNamespace(String uri)
uri
- The namespace to be used to qualify unprefixed element names and type names appearing
in the XPath expression.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |