XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition (416 page)

BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition
4.78Mb size Format: txt, pdf, ePub
ads

is followed by something that could be a legitimate step in a path expression, then that's the interpretation that's chosen. Adding whitespace after the
/
doesn't make any difference. What you need to do if you want the other interpretation is to put the
/
in parentheses, thus:
(/) union /*
.

This ambiguity was actually present, and unremarked upon, in XPath 1.0, though, it arose less frequently because there weren't many operators in XPath 1.0 that could sensibly be applied to
/
as an operand. The
|
operator does not cause any ambiguities because it cannot be confused with an element name.

I've classified the root expression as an abbreviated axis step because for most purposes it can be regarded as equivalent to the expression
ancestor-or-self::document-node()
. However, there's a significant difference: if the context item doesn't have an ancestor that is a document node, you get a runtime error rather than an empty sequence as the result.

Technically, therefore, the expression
/
is defined in the language specification as being equivalent to:

BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition
4.78Mb size Format: txt, pdf, ePub
ads

Other books

Fire Monks by Colleen Morton Busch
Come Back To Me by Foster, Melissa
(9/20) Tyler's Row by Read, Miss
Wish by Barbara O'Connor
Sparks in Scotland by A. Destiny and Rhonda Helms
The Flood-Tide by Cynthia Harrod-Eagles
The Vaudeville Star by Nicola Italia
The Empty House by Rosamunde Pilcher
The Big Necessity by Rose George