Package net.sf.saxon.xpath
Class XPathFactoryImpl
- java.lang.Object
-
- javax.xml.xpath.XPathFactory
-
- net.sf.saxon.xpath.XPathFactoryImpl
-
- All Implemented Interfaces:
Configuration.ApiProvider
- Direct Known Subclasses:
EnterpriseXPathFactory,ProfessionalXPathFactory
public class XPathFactoryImpl extends javax.xml.xpath.XPathFactory implements Configuration.ApiProvider
Saxon implementation of the JAXP 1.3 XPathFactory
-
-
Constructor Summary
Constructors Constructor Description XPathFactoryImpl()Default constructor: this creates a Configuration as well as creating the XPathFactory.XPathFactoryImpl(Configuration config)Constructor using a user-supplied Configuration.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ConfigurationgetConfiguration()Get the Configuration object used by this XPathFactorybooleangetFeature(java.lang.String feature)Get a feature of this XPath implementation.booleanisObjectModelSupported(java.lang.String model)Test whether a given object model is supported.javax.xml.xpath.XPathnewXPath()Create an XPath evaluatorvoidsetConfiguration(Configuration config)Set the Configuration for the factoryvoidsetFeature(java.lang.String feature, boolean b)Set a feature of this XPath implementation.voidsetXPathFunctionResolver(javax.xml.xpath.XPathFunctionResolver xPathFunctionResolver)Set a resolver for XPath functions.voidsetXPathVariableResolver(javax.xml.xpath.XPathVariableResolver xPathVariableResolver)Set a resolver for XPath variables.
-
-
-
Constructor Detail
-
XPathFactoryImpl
public XPathFactoryImpl()
Default constructor: this creates a Configuration as well as creating the XPathFactory. Any documents accessed using this XPathFactory must be built using this same Configuration.
-
XPathFactoryImpl
public XPathFactoryImpl(Configuration config)
Constructor using a user-supplied Configuration. This constructor is useful if the document to be queried already exists, as it allows the configuration associated with the document to be used with this XPathFactory.- Parameters:
config- the Saxon configuration
-
-
Method Detail
-
setConfiguration
public void setConfiguration(Configuration config)
Set the Configuration for the factory- Parameters:
config- the Saxon Configuration to be used
-
getConfiguration
public Configuration getConfiguration()
Get the Configuration object used by this XPathFactory- Returns:
- the Saxon configuration
-
isObjectModelSupported
public boolean isObjectModelSupported(java.lang.String model)
Test whether a given object model is supported. Returns true if the object model is the Saxon object model, DOM, JDOM, DOM4J, or XOM- Specified by:
isObjectModelSupportedin classjavax.xml.xpath.XPathFactory- Parameters:
model- The URI identifying the object model.- Returns:
- true if the object model is one of the following (provided that the supporting
JAR file is available on the classpath)
NamespaceConstant.OBJECT_MODEL_SAXON,XPathConstants.DOM_OBJECT_MODEL,NamespaceConstant.OBJECT_MODEL_JDOM, orNamespaceConstant.OBJECT_MODEL_XOM, orNamespaceConstant.OBJECT_MODEL_DOM4J. Saxon also allows user-defined external object models to be registered with the Configuration, and this method will return true in respect of any such model.
-
setFeature
public void setFeature(java.lang.String feature, boolean b) throws javax.xml.xpath.XPathFactoryConfigurationExceptionSet a feature of this XPath implementation. The features currently recognized are:-
XMLConstants.FEATURE_SECURE_PROCESSING -
FeatureKeys.SCHEMA_VALIDATION: requests schema validation of source documents. The property is rejected if the configuration is not schema-aware.
In addition, any Saxon configuration feature (listed in
FeatureKeyscan be used provided the value is a boolean. (For non-boolean configuration properties, drop down to the underlying SaxonConfigurationobject and callsetConfigurationProperty())- Specified by:
setFeaturein classjavax.xml.xpath.XPathFactory- Parameters:
feature- a URI identifying the featureb- true to set the feature on, false to set it off- Throws:
javax.xml.xpath.XPathFactoryConfigurationException- if the feature name is not recognized
-
-
getFeature
public boolean getFeature(java.lang.String feature) throws javax.xml.xpath.XPathFactoryConfigurationExceptionGet a feature of this XPath implementation. The only features currently recognized are:-
FEATURE_SECURE_PROCESSING -
FeatureKeys.SCHEMA_VALIDATION: requests schema validation of source documents.
In addition, any Saxon configuration feature (listed in
FeatureKeyscan be used provided the value is a boolean. (For non-boolean configuration properties, drop down to the underlying SaxonConfigurationobject and callgetConfigurationProperty())- Specified by:
getFeaturein classjavax.xml.xpath.XPathFactory- Parameters:
feature- a URI identifying the feature- Returns:
- true if the feature is on, false if it is off
- Throws:
javax.xml.xpath.XPathFactoryConfigurationException- if the feature name is not recognized
-
-
setXPathVariableResolver
public void setXPathVariableResolver(javax.xml.xpath.XPathVariableResolver xPathVariableResolver)
Set a resolver for XPath variables. This will be used to obtain the value of any variable referenced in an XPath expression. The variable resolver must be allocated before the expression is compiled, but it will only be called when the expression is evaluated.- Specified by:
setXPathVariableResolverin classjavax.xml.xpath.XPathFactory- Parameters:
xPathVariableResolver- The object used to resolve references to variables.
-
setXPathFunctionResolver
public void setXPathFunctionResolver(javax.xml.xpath.XPathFunctionResolver xPathFunctionResolver)
Set a resolver for XPath functions. This will be used to obtain an implementation of any external function referenced in an XPath expression. This is not required for system functions, Saxon extension functions, constructor functions named after types, or extension functions bound using a namespace that maps to a Java class.- Specified by:
setXPathFunctionResolverin classjavax.xml.xpath.XPathFactory- Parameters:
xPathFunctionResolver- The object used to resolve references to external functions.
-
newXPath
public javax.xml.xpath.XPath newXPath()
Create an XPath evaluator- Specified by:
newXPathin classjavax.xml.xpath.XPathFactory- Returns:
- an XPath object, which can be used to compile and execute XPath expressions.
-
-