Chapter 9. XPath: Path Expressions
This chapter defines the syntax and meaning of path expressions. Path expressions are the most distinctive feature of the XPath language, the construct that gives the language its name. The chapter also describes other constructs in the language that are closely associated with path expressions, in particular steps and axes and the «union», «intersect»
, and «except»
operators.
Path expressions are used to select nodes in a tree, by means of a series of steps. Each step takes as its starting point a node, and from this starting point, selects other nodes.
Each step is defined in terms of:
An axis, which defines the relationship to be followed in the tree (for example, it can select child nodes, ancestor nodes, or attributes)
A node test, which defines what kind of nodes are required, and can also specify the name or schema-defined type of the nodes
Zero or more predicates, which provide the ability to filter the nodes according to arbitrary selection criteria
Because they are closely associated with processing the results of path expressions, this chapter also describes the operators used to combine two sets of nodes by taking their union, intersection, or difference.
Although I've chosen Path Expressions as the title for this chapter, the term is actually a slippery one. Because of the way W3C defines the XPath grammar, all sorts of unlikely constructs such as «2»
or «count($x)»
are technically path expressions. The things I will actually cover in this ...
Get XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.