Get a new XPathFactory instance using the specified object model.
To find a XPathFactory object, this method looks the following places in the following order where "the class loader" refers to the context class loader:
-
If the system property DEFAULT_PROPERTY_NAME + ":uri" is present, where uri is the parameter to this method, then its value is read as a class name. The method will try to create a new instance of this class by using the class loader, and returns it if it is successfully created.
-
Use the configuration file "jaxp.properties". The file is in standard Properties format and typically located in the conf directory of the Java installation. It contains the fully qualified name of the implementation class with the key being the system property defined above.
The jaxp.properties file is read only once by the JAXP implementation and its values are then cached for future use. If the file does not exist when the first attempt is made to read from it, no further attempts are made to check for its existence. It is not possible to change the value of any property in jaxp.properties after it has been read for the first time.
-
Use the service-provider loading facility, defined by the ServiceLoader class, to attempt to locate and load an implementation of the service using the default loading mechanism : the service-provider loading facility will use the current thread's context class loader to attempt to load the service. If the context class loader is null, the system class loader will be used.
Each potential service provider is required to implement the method isObjectModelSupported(String objectModel) . The first service provider found that supports the specified object model is returned.
In case of ServiceConfigurationError an XPathFactoryConfigurationException will be thrown.
-
Platform default XPathFactory is located in a platform specific way. There must be a platform default XPathFactory for the W3C DOM, i.e. DEFAULT_OBJECT_MODEL_URI.
If everything fails, an XPathFactoryConfigurationException will be thrown.
Tip for Trouble-shooting:
See Properties.load(java.io.InputStream) for exactly how a property file is parsed. In particular, colons ':' need to be escaped in a property file, so make sure the URIs are properly escaped in it. For example:
http\://java.sun.com/jaxp/xpath/dom=org.acme.DomXPathFactory