The semantics of locator (XPath) expressions

According to the XML data model, XML documents are viewed as trees containing these kinds of nodes:

The links between those nodes, in other words the tree-forming relationship, reflect the immediate containment relationship in the XML document.

The root node can appear only at the root and nowhere else in the tree. It contains, as its children, the document element and optional comments and processing instructions.

Element nodes can contain any kinds of nodes except for the root node. The other kinds of nodes are only allowed at terminal nodes of the tree.

There are three kinds of containment links: 'child', 'attribute', and 'namespace'. The 'attribute' and 'namespace' containment links must lead to attribute and namespace nodes, respectively. In other words, to access the children of an element node (in terms of graph theory) you need to follow 'attribute' links to find all contained attributes, follow 'namespace' links to find all contained namespace declarations, and follow 'child' links to find contained elements, text nodes, processing instructions, and comments.

An XPath expression needs to be interpreted with respect to a context node, and denotes a set of nodes. When used as Net Search Extender selector patterns, the context node is free, that is, a relative path pattern p is interpreted as //p.

These are the Net Search Extender XPath selector patterns:

Note

A NodeTest of the form NameTest assumes the node to be of the principal type on the selected axis, which is attribute type on the attribute axis and child type on the child axis. Consequently, NameTest cannot be used to choose comments or processing instruction nodes, but only child and attribute nodes. Moreover, the patterns allow for the selection of any kind of node, except for namespace nodes, because the axis specifier 'namespace' is not allowed.

Examples of patterns:

This is the syntax of the locator element:

Locator     ::= LocationPathPattern
           | Locator '|'  LocationPathPattern
 LocationPathPattern  ::= '/' RelativePathPattern ?
           | '//'? RelativePathPattern
 RelativePathPattern  ::= StepPattern
           | RelativePathPattern '/' StepPattern
           | RelativePathPattern '//' StepPattern
 StepPattern    ::= ChildOrAttributeAxisSpecifier NodeTest
 ChildOrAttributeAxisSpecifier ::=
           ('child' | 'attribute') '::'
           | '@'?
 NodeTest    ::= NameTest
           | NodeType '(' ')'
           | 'processing-instruction' '(' Literal ')'
 NameTest    ::= '*' | NCName ':' '*' | QName
 NodeType    ::= 'comment' | 'processing-instruction'

NCName and QName are as defined in the XML Names Recommendation:

NCName
An XML name containing no colons
QName
A NCName that can be preceded by a NCName followed by a colon. For example: NCName:NCName