XML technologies / XSLT / Introduction to XSLT 2.0 / XSLT and XPath – getting started / String values and attribute values / Path expressions for attribute nodes
(Excerpt from “XSLT 2.0 & XPath 2.0” by Frank Bongers, chapter 1.)
Attribute nodes are not on the tree’s normally traversed element axes, and are therefore not shown in the tree. An axis name is mandatory when selecting an attribute.
@nachname
Selects attributenachnameof the current node, if present. Each element can have at most one attribute with this name.attribute::nachname
The same step as above, written out in full.person/@nachname
Selects attributenachnameof an elementpersonthat is a child of the current node. Multiple attribute nodes may be selected if multiplepersonelements exist.child::person/attribute::nachname
Again the same expression, with both steps written out in full.@*
Selects every attribute of the current node regardless of its name. Wildcard*can also be used for attribute nodes. Note that their order in the sequence is essentially unpredictable.../@*
Selects the attributes of the context node’s parent. If the context node is itself an attribute, it is also included in the selection.//@id
Selects all attributes namedidin the current document, regardless of their parent’s name.
The full axis name attribute can always be used as shown above, but is essentially redundant and therefore uncommon.
Summary: string values and attribute values
An element node’s string value consists of all text nodes contained directly or indirectly in that element, concatenated in document order.
Attribute order has no meaning and is therefore irrelevant. Attributes are considered unordered, like the fields of a record in a database table.
For a location step targeting an attribute, abbreviation
@is used as the axis name before the attribute name. Like any path expression, it must be interpreted in context.An attribute node’s string value is the character string making up its attribute value.
Copyright © Galileo Press, Bonn 2008
You may print the online version for your private use.
Otherwise, this chapter from “XSLT 2.0 & XPath 2.0 ― Das umfassende Handbuch” is subject to the same conditions as the bound edition. The work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
Galileo Press, Rheinwerkallee 4, 53227 Bonn