Understanding XPath Processor Terms

To use the context operators, it is important to understand the following terms:

Axis

An axis specifies a list of nodes in relation to the context node. For example, the ancestor axis contains the ancestor nodes of the context node. The child axis contains the immediate children of the context node. See Syntax for Specifying an Axis in a Query.

Context Node

A context node is the node the XPath processor is currently looking at. The context node changes as the XPath processor evaluates a query. If you pass a document to the XPath processor, the root node is the initial context node. If you pass a node to the XPath processor, the node that you pass is the initial context node. During evaluation of a query, the initial context node is also the current node.

Context Node Set

A context node set is a set of nodes that the XPath processor evaluates.

Current Node

Current node is the node that the XPath processor is looking at when it begins evaluation of a query. In other words, the current node is the first context node that the XPath processor uses when it starts to execute the query. During evaluation of a query, the current node does not change. If you pass a document to the XPath processor, the root node is the current node. If you pass a node to the XPath processor, that node is the current node.

Document Element

The document element is the element in a document that contains all other elements. The document element is an immediate child of the root node. When you obtain the document element of a document, you obtain all marked-up text in that document.

Filter

A filter in a query specifies a restriction on the set of nodes to be returned. For example, the filter in the following query restricts the result set to book elements that contain at least one excerpt element:

book[excerpt]  

Location Path Expression

A location path expression is an XPath expression. It has the following format:

Location Step

An XPath expression consists of one or more location steps. A location step has the following format:

[axis::]node_test[[filter] [filter]...] 

Node Test

You apply a node test to a list of nodes. A node test returns nodes of a particular type or nodes with a particular name. For example, a node test might return all comment nodes, or all book elements.

Root Node

Theroot node is the root of the tree. It does not occur anywhere else in the tree. The document element node for a document is a child of the root node. The root node also has as children processing instructions and comment nodes representing processing instructions and comments that occur in the prolog and after the end of the document element.

 
Free Stylus Studio XML Training: