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.09Mb 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

The Assailant by James Patrick Hunt
The Intimate Sex Lives of Famous People by Irving Wallace, Amy Wallace, David Wallechinsky, Sylvia Wallace
Guardian of the Gate by Michelle Zink
Girl Meets Boy by Kelly Milner Halls
Sweet Serendipity by Pizzi, Jenna
The Fatal Englishman by Sebastian Faulks
Cowboy Kisses by Diane Michele Crawford
The Mummy's Curse by Penny Warner
Psychosphere by Brian Lumley
She Can Scream by Melinda Leigh