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

Other books

Sense of Evil by Kay Hooper
El Campeón Eterno by Michael Moorcock
Six Years by Stephanie Witter
Josiah's Treasure by Nancy Herriman
Silent Surrender by Abigail Barnette
Interrupted Vol 1 by Moose, S.
The Chase by Lynsay Sands