Copyright 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

O'Reilly logo

Chapter 7. XPath Fundamentals

This chapter defines some fundamental features of the XPath language. The first half of the chapter describes the basic syntactic and lexical conventions of the language, and the second half describes the important notion of context: this establishes the way in which XPath expressions interact with the environment in which they are used, which for our purposes primarily means the containing XSLT stylesheet.

The complete grammar of the language is summarized in Appendix A, and for convenience I have split the constructs of the language across five chapters, as follows:

Chapter

Scope

7

Notation used for describing the grammar

Overall structure of the language

Lexical rules (including comments and whitespace handling)

Literals

Variable references

Parenthesized subexpressions

Context item expression «.»

Function calls

Conditional expressions: «if»

8

Arithmetic operators: «+», «−», ...

Value comparison operators: «eq», «lt», ...

General comparison operators: «=», «<», ...

Node identity and ordering operators: «is», «<<», «>>»

Boolean operators: «and», «or»

9

Path expressions: «/», «//»

Steps and axes

Union, intersect, and except operators

10

Sequence concatenation operator: «,»

Numeric range operator: «to»

Filter expressions «a[b]»

Mapping expressions: «for»

Quantified expressions: «some» and «every»

11

SequenceType production

«instance of»

«castable as»

«cast as»

«treat as»

As with other programming languages, the syntax is defined in a set of production rules. Each ...

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