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

  • XPathExpression compile(String expression)

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.

Evaluating Expressions

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

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

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

The first method above 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. Also, The returnType is never provided directly by the user. It is either provided by calling the corresponding lookup-* function for each javax.xml.namespace.QName in XPathConstants, or by passing in the corresponding keyword to lookup.

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()
Clone this wiki locally