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

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

Examples of Kind Tests

These examples show some different
KindTests
, used in the context of a containing path expression.

Expression
Description
parent::node()
Selects the parent of the context node, whether this is an element node or the root node. This differs from
parent::*
, which selects the parent node only if it is an element. The expression
parent::node()
is usually abbreviated to
..
.
//comment()
Selects all comment nodes in the document.
child::text()
Selects all text node children of the context node. This is usually abbreviated to
text()
.
@comment()
A strange but legal way of getting an empty node-set: it looks for all comment nodes on the attribute axis, and of course finds none.
self::attribute(title)
Selects the context node if it is an attribute named
title
.

Predicates

We saw earlier that a step has three parts: an axis, a
NodeTest
(which is either a
NameTest
or a
KindTest
), and optionally a list of predicates. We've examined the first two parts in the preceding sections; now it's time to look at predicates.

A predicate is a qualifying expression used to select a subset of the nodes in a sequence. The predicate may be any XPath expression, and it is written in square brackets.

Expression
Syntax
PredicateList
Predicate *
Predicate
[
Expr
]
BOOK: XSLT 2.0 and XPath 2.0 Programmer's Reference, 4th Edition
2.14Mb size Format: txt, pdf, ePub
ads

Other books

A Wedding at the Orange Blossom Inn by Shelley Shepard Gray
To Wed in Texas by Jodi Thomas
The Great Baby Caper by Eugenia Riley
Red Lightning by John Varley
The Big Lie by Julie Mayhew
The Socotra Incident by Richard Fox
Maid of Murder by Amanda Flower