JDK-8176326 : Release Note: XPath enhancement
  • Type: Sub-task
  • Component: xml
  • Sub-Component: javax.xml.xpath
  • Affected Version: 9
  • Priority: P4
  • Status: Closed
  • Resolution: Delivered
  • Submitted: 2017-03-07
  • Updated: 2017-09-22
  • Resolved: 2017-03-09
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9Resolved
Description
Java SE 9 improves the `javax.xml.xpath` API with new APIs that make use of modern language features to facilitate ease of use and extend support of the XPath specification.

1. Support ANY type

>`javax.xml.xpath` supported explicit data types defined by the XPath specification. However, it was missing the important `ANY` type without which the XPath API assumes that an explicit type is always known, which is not true in some circumstances. The new API now supports the `ANY` type so that an XPath evalution can be performed when the return type is unknown. 


2. Improved ease of use

>For ease of use, four new `evaluateExpression` methods are added to the `javax.xml.xpath.XPath` and `javax.xml.xpath.XPathExpression` interfaces to allow specifying explicit types as follows:

>When specified explicitly, the new methods return the specific types, including `Boolean`, `Double`, `Integer`, `Long`, `String` and `org.w3c.dom.Node`.

>When the return type is expected to be `NODESET`, the new methods will return a new `XPathNodes` type. `XPathNodes` is a new interface that extends `Iterable<Node>` which makes it easier to use than the traditional `org.w3c.dom.NodeList`.

>When the return type is unknown or `ANY`, the new methods return a new `XPathEvaluationResult` type. `XPathEvaluationResult` provides an `XPathResultType` enum that defines the supported types that are `ANY`, `BOOLEAN`, `NUMBER`, `STRING`, `NODESET`, and `NODE`.