XMLWordPrintable

      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`.

            joehw Joe Wang
            joehw Joe Wang
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: