The JAXP XPath API
Saxon implements the JAXP 1.3 API for executing XPath expressions as defined in package
java.xml.xpath
, which is a standard part of the Java class library since JDK 1.5.
Three sample applications using this API are available: they are called
XPathExample.java
, XPathExampleSA.java
, and ApplyXPathJAXP.java
,
and can be found in the samples/java
directory after downloading the saxon-resources
archive.
To run the XPathExample.java
application, see the instructions
in Shakespeare XPath Sample Application.
The XPathExampleSA.java
application demonstrates use of schema-aware XPath. It is designed
to be used with the files books.xml
and books.xsd
in the directory samples/data
.
The ApplyXPathJAXP.java
application is an enhanced version of the class of the
same name issued as a sample application in the JAXP 1.3 distribution. It has been enhanced to show
the use of more advanced features, such as the ability to bind namespaces, variables, and functions, and
also to demonstrate use of the XPath API with different object models.
The XPath API in Saxon predates the introduction of the JAXP 1.3 XPath API, so it contains some facilities that are obsolescent (but most of the deprecated features were removed with effect from Saxon 9.6). However, there are also differences caused by the fact that Saxon supports XPath 2.0, with its richer data model, whereas JAXP 1.3 operates only on XPath 1.0.
The following sections describe use of the XPath API in more detail.