Javax.Xml.Xpath.XPathFactory.NewInstance Method
  1. If the system property XPathFactory.DefaultPropertyName + ":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.
  2. ${java.home}/lib/jaxp.properties is read and the value associated with the key being the system property above is looked for. If present, the value is processed just like above.
  3. The class loader is asked for service provider provider-configuration files matching javax.xml.xpath.XPathFactory in the resource directory META-INF/services. See the JAR File Specification for file format and parsing rules. Each potential service provider is required to implement the method:

    java Example

    isObjectModelSupported(String)
    The first service provider found in class loader order that supports the specified object model is returned.
  4. Platform default XPathFactory is located in a platform specific way. There must be a platform default XPathFactory for the W3C DOM, i.e. XPathFactory.DefaultObjectModelUri.

java Example

   http\://java.sun.com/jaxp/xpath/dom=org.acme.DomXPathFactory
 

Syntax

[Android.Runtime.Register("newInstance", "(Ljava/lang/String;)Ljavax/xml/xpath/XPathFactory;", "")]
public static XPathFactory NewInstance (string uri)

Parameters

uri
Identifies the underlying object model. The specification only defines the URI XPathFactory.DefaultObjectModelUri, http://java.sun.com/jaxp/xpath/dom for the W3C DOM, the org.w3c.dom package, and implementations are free to introduce other URIs for other object models.

Returns

Documentation for this section has not yet been entered.

Exceptions

TypeReason
Javax.Xml.Xpath.XPathFactoryConfigurationExceptionIf the specified object model is unavailable.
Java.Lang.NullPointerExceptionIf uri is null.
Java.Lang.IllegalArgumentExceptionIf uri.length() == 0.

Remarks

  1. If the system property XPathFactory.DefaultPropertyName + ":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.
  2. ${java.home}/lib/jaxp.properties is read and the value associated with the key being the system property above is looked for. If present, the value is processed just like above.
  3. The class loader is asked for service provider provider-configuration files matching javax.xml.xpath.XPathFactory in the resource directory META-INF/services. See the JAR File Specification for file format and parsing rules. Each potential service provider is required to implement the method:

    java Example

    isObjectModelSupported(String)
    The first service provider found in class loader order that supports the specified object model is returned.
  4. Platform default XPathFactory is located in a platform specific way. There must be a platform default XPathFactory for the W3C DOM, i.e. XPathFactory.DefaultObjectModelUri.

java Example

   http\://java.sun.com/jaxp/xpath/dom=org.acme.DomXPathFactory
 

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 everything fails, an XPathFactoryConfigurationException will be thrown.

Tip for Trouble-shooting:

See Java.Util.Properties.Load(System.IO.Stream) 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:

[Android Documentation]

Requirements

Namespace: Javax.Xml.Xpath
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 8