Skip to content

XPath Java Interop

jeremyheiler edited this page Mar 13, 2013 · 8 revisions

The purpose of this guide is to walk through how the XPath Java API is (and is not) used.

All classes in this guide refer to the JDK's javax.xml.xpath package unless otherwise noted. Also, all functions refer to the xenopath.xpath namespace unless otherwise noted.

XPath

Compiling Expressions

The function compile-expr will return its argument if it is an instance of XPathExpression. If it isn't, it will call this method with the argument in an attempt to compile it. When compiling an expression, it is an error if the argument is null or not a String.

  • XPathExpression compile(String expression)

Evaluating Expressions

These two methods are never called, preferring their three argument siblings with XPathConstants/STRING.

  • String evaluate(String expression, InputSource source)
  • String evaluate(String expression, Object item)

The first method below is called whenever the source argument to any of the lookup functions is an instance of org.xml.sax.InputSource. Otherwise the second method is called. The returnType argument is never provided directly by the user. The javax.xml.namespace.QName instance is ultimately provided by each lookup-* function and obtained from XPathConstants.

  • Object evaluate(String expression, InputSource source, QName returnType)
  • Object evaluate(String expression, Object item, QName returnType)

Namespace Context

These methods are not being used. Open an issue to request their use.

  • NamespaceContext getNamespaceContext()
  • void setNamespaceContext(NamespaceContext nsContext)

Function and Variable Resolvers

These methods are not being used. Open an issue to request their use.

  • XPathFunctionResolver getXPathFunctionResolver()
  • void setXPathFunctionResolver(XPathFunctionResolver resolver)
  • XPathVariableResolver getXPathVariableResolver()
  • void setXPathVariableResolver(XPathVariableResolver resolver)

Resetting State

This method is not being used. Open an issue to request its use.

  • void reset()

XPathExpression

These methods are never called, preferring their two argument siblings with XPathConstants/STRING.

  • String evaluate(InputSource source)
  • String evaluate(Object item)

The first method below is called whenever the source argument to any of the lookup functions is an instance of org.xml.sax.InputSource. Otherwise the second method is called. The returnType argument is never provided directly by the user. The javax.xml.namespace.QName instance is ultimately provided by each lookup-* function and obtained from XPathConstants.

  • Object evaluate(InputSource source, QName returnType)
  • Object evaluate(Object item, QName returnType)

XPathFunction

This interface is not being used. Open an issue to request its use.

  • Object evaluate(List args)

XPathFunctionResolver

This interface is not being used. Open an issue to request its use.

  • XPathFunction resolveFunction(QName functionName, int arity)

XPathVariableResolver

This interface is not being used. Open an issue to request its use.

  • XPathFunction resolveVariable(QName variableName)

XPathConstants

XPath Data Types

The following javax.xml.namespace.QName instances are used to determine the return type when evaluating an expression.

  • static QName BOOLEAN
  • static QName NODE
  • static QName NODESET
  • static QName NUMBER
  • static QName STRING

DOM Object Model URI

This object is not being used. Open an issue to request its use.

  • String DOM_OBJECT_MODEL

XPathFactory

Properties

The following two objects are not being used directly. Open an issue to request their use.

  • static String DEFAULT_OBJECT_MODEL_URI
  • static String DEFAULT_PROPERTY_NAME

Construction

This is the only method used to instantiate an XPathFactory instance.

  • static XPathFactory newInstance()

These two methods are not being used directly. Open an issue to request their use.

  • static XPathFactory newInstance(String uri)
  • static XPathFactory newInstance(String uri, String factoryClassName, ClassLoader classLoader)

XPath

This method is used to initialize an XPath object for evaluating expressions.

  • XPath newXPath()

Features

These two methods are not being used. Open an issue to request their use.

  • boolean getFeature(String name)
  • void setFeature(String name, boolean value)

Object Model

This method is not being used. Open an issue to request its use.

  • boolean isObjectModelSupported(String objectModel)

Function and Variable Resolvers

These methods are not being used. Open an issue to request their use.

  • void setXPathFunctionResolver(XPathFunctionResolver resolver)
  • void setXPathVariableResolver(XPathVariableResolver resolver)

XPathException

This exception is not dealt with by the library.

XPathExpressionException

This exception is not dealt with by the library.

XPathFactoryConfigurationException

This exception is not dealt with by the library.

XPathFunctionException

This exception is not dealt with by the library.