O'Reilly logo

XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition by Michael Kay

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required