Hitachi

uCosminexus Application Server XML Processor User Guide


6.11 Notes on the javax.xml.xpath Package

The following table gives cautionary notes on the javax.xml.xpath package.

Table 6‒21: Notes on the javax.xml.xpath package

No.

Notes

1

In multi-thread programming, the XPathFactory class is not thread-safe. Therefore, multiple threads must not access the same XPathFactory instance at the same time. To avoid conflicts between threads, use one of the following methods:

  • Each thread has one XPathFactory instance.

  • Each thread exclusively accesses the XPathFactory instance.

2

In multi-thread programming, XPath instances generated by the newInstance method of the XPathFactory class and XPathExpression instances generated by the compile method of the XPath interface are not thread-safe. Therefore, multiple threads must not access the same XPath instance and XPathExpression instance at the same time. To avoid conflicts between threads, use the following method:

  • Each thread has one XPath instance and one XPathExpression instance.

3

The URI http://java.sun.com/jaxp/xpath/dom is the only URI that you can specify as the argument of the newInstance(String uri) method of the XPathFactory class.

4

If you evaluate an XPath expression that refers to a context by using the following methods, specify a non-null context for the item argument:

  • evaluate(String expression, Object item, QName returnType) method of the XPath interface

  • evaluate(String expression, Object item) method of the XPath interface

  • evaluate(Object item, QName returnType) method of the XPathExpression interface

  • evaluate(Object item) method on the XPathExpression interface

5

Specify the Document, DocumentFragment, Element, Text, Attr, ProcessingInstruction, or Comment object for the item argument described in No.4 in this table.

6

For a return type of the evaluate method of the class that implements the XPathFunction interface and a return type of the resolveVariable method of the class that implements the XPathVariableResolver interface, specify either the java.lang.String, java.lang.Boolean, java.lang.Number, org.w3c.Node, or org.w3c.NodeList type.

7

If an exception occurs in a method for the javax.xml.xpath package, a detailed message may not be obtained because the return value from the getMessage method that was applied to the exception object can be null. In this case, if you obtain the wrapped exception object by applying the getCause method to the exception object and then apply the getMessage method, you may obtain the detailed message.

8

Specify spaces before and after and, or, mod, and div operators.

(Example) 1000 div 10

9

An XPath expression that meets all of the following conditions is not supported:

  1. Specifies the XPath function that returns a node set for each operand in the | operator, and creates a union of the node sets.

  2. Applies a predicate to the union of the node sets created in condition 1.

10

An XPath expression that meets all of the following conditions is not supported:

  1. Uses either the local-name, namespace-uri, or name function.

  2. Specifies the following expression for the argument of the function described in condition 1. above:

    self::node()/descendant::prefix1:* (#)

    In this case, you can work around this problem by changing the argument of the function described in condition 1 to the following expression:

    self::node()/self::node()/descendant::prefix1:* (#)

    The prefix1 indicates any namespace prefix.

11

An XPath expression that applies the following-sibling axis to the attribute and namespace nodes is not supported.

12

When an operand of the | operator is not a location set, the XPath expression is not supported.

13

If there are multiple namespace nodes where each set of a namespace prefix and namespace URI is the same, an XPath expression that applies an axis to their namespace nodes is not supported.

14

When the id functionality is applied to an XML document that includes an ID type attribute with a duplicated value, the result of the id functionality might be invalid.