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
6.98Mb size Format: txt, pdf, ePub

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
]

Other books

My Prizes: An Accounting by Thomas Bernhard
FLOWERS ON THE WALL by Williams, Mary J.
The Glass Slipper by Eberhart, Mignon G.
Arrows of Time by Falconer, Kim