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
12.9Mb 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

Fire Mage by John Forrester
Stolen Luck by Megan Atwood
Spider Shepherd: SAS: #2 by Stephen Leather
The Emerald Lie by Ken Bruen
Holy the Firm by Annie Dillard
Night in Shanghai by Mones, Nicole
Lambs to the Slaughter by Sally Spencer
The Bargain by Julia Templeton
Within the Walls of Hell by Taniform Martin Wanki
Un hombre que promete by Adele Ashworth