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

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

In most cases
//A
gives the same answer as
/descendant::A
, but the significance of the formal expansion becomes apparent when positional predicates are involved. The expression
//para[1]
expands to
/descendant-or-self::node()/child::para[1]
, which selects every

element that is the first child of its parent. This isn't the same as
/descendant::para[1]
, which selects the first

element in the entire document.

The
//
abbreviation can also be used as an infix operator anywhere that
/
can appear. For example,
.//A
selects all

elements that are descendants of the context node. Again, the official meaning is
./descendant-or-self::node()/child::A
. The
./
in this expanded expression is redundant: people often write path expressions such as
./A/B
, but the
./
in most cases is pure noise. But with
//

Other books

The Lady Most Willing . . . by Julia Quinn, Eloisa James, Connie Brockway
The Female of the Species by Mindy McGinnis
Random Violence by Jassy Mackenzie
Mrs. Maddox by McGuire, Jamie
Keeplock by Stephen Solomita
All I Want by Natalie Ann
THUGLIT Issue Twelve by Marks, Leon, Hart, Rob, Porter, Justin, Miner, Mike, Hagelstein, Edward, Garvey, Kevin, Simmler, T. Maxim, Sinisi, J.J.
A Workplace Affair by Rae, Isabella
Unforgettable by Shanna Vollentine
Antsy Floats by Neal Shusterman