The XPath language is used to describe locations in a document tree. It is the expression language used by XSLT. See the XPath specification for complete details.
A well-formed XML document can be visualized as a tree
(in the computer science meaning of the term),
and this view is used throughout XPath and XSLT. For example,
if a certain document represents a book, it might have
a top-level tag
<book>, containing elements like
<chapter> and
<appendix>.
A few important definitions:
A node is the basic building block of the document tree, that is, the data structure used to represent an XML document during its processing by an XSLT script.
The node representing the outermost tag of the document is called the root node of the tree.
All nodes except the root node of the tree have a parent node, and many nodes can have child nodes under them.
To continue the example above, the
<book> node is the root,
and its children are the
<chapter> and
<appendix> elements.
All XPath expressions are evaluated in the context of a particular node (location) in the document. That node is called the context node.
The context size is the number of children of the context node's parent. For example, if the context node is one of seven children of its parent, the context size is seven.
The context position is the child number of the context node relative to its parent. For example, if the context node is the third of seven children of its parent, its context position is three.
XPath expressions use these data types:
node-setMany XPath operations select a set of zero or
more nodes. For example, the expression
"address" selects all of the
<address> elements
that are children of the context node. This node-set
may contain no nodes, one node, or many.
booleanA true or false value.
numberNumbers in XPath are represented using floating point.
stringA string of characters.