Skip to Main Content
XSLT
book

XSLT

by Doug Tidwell
August 2001
Intermediate to advanced content levelIntermediate to advanced
480 pages
11h 16m
English
O'Reilly Media, Inc.
Content preview from XSLT

XPath Axes

The XPath specification defines thirteen different axes; each axis contains various nodes. The nodes that are in a given axis depend on the context node. All 13 axes, excerpted from our more involved discussion in Section 3.1 in Chapter 3, are listed here.

child axis

Contains the children of the context node. As we’ve already mentioned, the XPath expressions child::lines/child::line and lines/line are equivalent. If an XPath expression (such as /sonnet) doesn’t have an axis specifier, the child axis is used by default.

parent axis

Contains the parent of the context node, if there is one. (If the context node is the root node, the parent axis returns an empty node-set.) This axis can be abbreviated with a double period (..). The expressions parent::sonnet and ../sonnet are equivalent. If the context node does not have a <sonnet> element as its parent, these XPath expressions return an empty node-set.

self axis

Contains the context node itself. The self axis can be abbreviated with a single period (.).

attribute axis

Contains the attributes of the context node. If the context node is not an element node, this axis is empty. The attribute axis can be abbreviated with the at sign (@). The expressions attribute::type and @type are equivalent.

ancestor axis

Contains the parent of the context node, the parent’s parent, and so on. The ancestor axis always contains the root node, unless the context node is the root node.

ancestor-or-self axis

Contains the context node, its parent, ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning XSLT

Learning XSLT

Michael Fitzgerald
Inside XSLT

Inside XSLT

Steven Holzner
XSLT Cookbook

XSLT Cookbook

Sal Mangano
XSLT and XPATH: A Guide to XML Transformations

XSLT and XPATH: A Guide to XML Transformations

John Robert Gardner, Zarella L. Rendon

Publisher Resources

ISBN: 0596000537Supplemental ContentCatalog PageErrata