Name

XPathFactory

Synopsis

The XPathFactory class is a factory for creating XPath expression evaluators. Call the no-argument version of newInstance( ) to obtain an XPathFactory object that creates XPath object to work with DOM documents. The javax.xml.xpath package is nominally object-model independent, however, and you can specify the name of a different object model by calling the one-argument version of newInstance( ).

Once you have created an XPathFactory object, you can set default function and variable resolvers with setXPathFunctionResolver( ) and setXPathVariableResolver( ). You can configure implementation-dependent features of an XPathFactory with setFeature( ) . All implementations are required to support the XMLConstants.FEATURE_SECURE_PROCESSING feature. When this feature is set to true, external functions are not allowed in XPath expressions, and the XPathFunctionResolver is not used.

After creating and configuring an XPathFactory object, use the newXPath( ) method to create one or more XPath objects for actually evaluating XPath expressions.

public abstract class XPathFactory {
// Protected Constructors
     protected XPathFactory( );  
// Public Constants
     public static final String DEFAULT_OBJECT_MODEL_URI;   ="http://java.sun.com/jaxp/xpath/dom"
     public static final String DEFAULT_PROPERTY_NAME;      ="javax.xml.xpath.XPathFactory"
// Public Class Methods
     public static final XPathFactory newInstance( );  
     public static final XPathFactory newInstance(String uri) throws XPathFactoryConfigurationException; ...

Get Java in a Nutshell, 5th Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.