XPath API for Java
This section describes how to use Saxon as a Java class library for XPath processing, without making any use of XSLT stylesheets. It includes information on the XPath API, and the API for the Saxon implementation of the XPath object model. On other pages you will find the API for XSLT transformation, the API for running XQuery, and the API for Schema validation.
For information about the different ways of loading source documents, see Handling Source Documents.
Saxon supports three Java APIs for XPath processing, as follows:
The JAXP API is a (supposedly) standard API defined in Java 5. Saxon implements this interface. Details of Saxon's implementation are described at The JAXP XPath API. Note that there are some extensions and other variations in the Saxon implementation. Some of the extensions to this interface are provided because Saxon supports XPath 2.0, whereas JAXP 1.3 is designed primarily for XPath 1.0; some are provided because Saxon supports multiple object models, not only DOM; some are for backwards compatibility; and some are provided to allow applications a finer level of control if required.
The preferred interface for XPath processing is the s9api interface, which also supports XSLT and XQuery processing, schema validation, and other Saxon functionality in an integrated set of interfaces. This is described at Evaluating XPath Expressions using s9api
For historical reasons Saxon continues to support a legacy XPath API in package
net.sf.saxon.sxpath. This is documented only in the Javadoc specifications. It is a lower-level API, so as well as being retained for backwards compatibility, it may also be appropriate for applications that require a very intimate level of integration with Saxon internals.