Compartir a través de


Node Tests

A version of this page is also available for

Windows Embedded CE 6.0 R3

4/8/2010

A node test specifies the node type and expanded name of the nodes selected by the location step. Every axis has a principle node type. If an axis can contain elements, the principle node type is element; otherwise it is the type of the nodes that the axis can contain. Therefore,

  • For the attribute axis, the principle node type is attribute.
  • For the name space axis, the principle node type is name space.
  • For other axes, the principle node type is element.

A node test that is a Qualified Name is True if and only if the type of the node is the principle node type and has an expanded-name equal to the expanded-name specified by the QName. For example, child::para selects the para element children of the context node; if the context node has no para children, it will select an empty set of nodes.

A QName in the node test is expanded into an expanded-name using the name space declarations from the expression context. This is the same way expansion is done for element type names in start and end tags except that the default name space declared with xmlns is not used: if the QName does not have a prefix, the name space URI is Null (this is the same way attribute names are expanded). It is an error if the QName has a prefix for which there is no name space declaration in the expression context.

A node test * is True for any node of the principle node type. For example, child::* will select all element children of the context node, and attribute::* will select all attributes of the context node.

A node test can have the form NCName:*. In this case, the prefix is expanded in the same way as with a QName, using the context name space declarations. It is an error if there is no name space declaration for the prefix in the expression context. The node test will be True for any node of the principle type whose expanded-name has the name space Uniform Resource Identifier (URI) to which the prefix expands, regardless of the local part of the name.

Available node tests are listed in the following table.

Comment()

Returns True for a comment node.

Node()

Returns True for a node of any type.

Processing-instruction()

Returns True for a processing instruction node.

Text()

Returns True for a text node.

The node test text() is true for any text node. For example, child::text() selects the text node children of the context node. In a similar way, the node test comment() is True for any comment node, and the node test processing-instruction() is True for any processing instruction. The processing-instruction() test may have an argument that is literal; in this case, it is True for any processing instruction that has a name equal to the value of the literal.

A node test node() is True for any node of any type.

See Also

Concepts

Location Paths