Introduction | |
Evaluating XPath Expressions using s9api | |
ยป | The JAXP XPath API |
The NodeInfo interface | |
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. 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.
Selecting the XPath implementation: Describes how to ensure that Saxon is selected as the XPath API implemenation
Setting the context item: Describes how to supply a context item
Return types: Describes the mapping of XPath return types to Java classes
Additional Saxon methods: Describes features of the Saxon implementation additional to the JAXP specification
Calling JAXP XPath extension functions: Describes how to call out from XPath expressions to Java code