XML technologies / XPath / XPath 2.0: language reference / Path expressions: location steps / Node name test: NameTest
(Excerpt from "XSLT 2.0 & XPath 2.0" by Frank Bongers, chapter 4.)
Every axis has a principal node kind (principal node kind). For most axes, this is the element node. Only the attribute axis has attribute nodes as its principal kind; the namespace axis similarly has namespace nodes.
Any node test consisting of a QName is called a NameTest. It always refers to the axis’s principal node kind, already determined by the chosen axis.
A NameTest succeeds when its expanded QName matches the node’s expanded name. The whole QName, or its namespace or local-name component, can be replaced by an asterisk wildcard *.
A NameTest can take the following forms:
QName
The complete QName is supplied for comparison. A node passes if it has the same expanded QName. The supplied QName may contain only a local name, with no namespace component.
präfix:*
A specified namespace prefix is combined with a wildcard for the local name. The test succeeds if the node has the same namespace identified by the supplied prefix.
*:NCName
A local NCName is combined with a namespace wildcard. The test succeeds if the node has the specified local name, regardless of its namespace, including no namespace.
*
A wildcard alone instead of a QName matches every named node on the axis, that is, every node of the principal node kind. It therefore selects all elements on an element axis and all attributes on the attribute axis, regardless of name.
Editorial note:
Binding namespace URIs to prefixes is explained in detail on this page. XPath expressions in XSLT always occur in an XML document, the stylesheet, whose namespace declarations provide prefix bindings. Other host languages may handle this differently because XPath leaves it unspecified. Source-document prefixes can therefore differ from those used in XPath expressions.
Copyright © Galileo Press, Bonn 2008
You may print the online version for private use.
Otherwise, this chapter from "XSLT 2.0 & XPath 2.0 ― Das umfassende Handbuch" is subject to the same terms as the bound edition: the work and all its parts are protected by copyright. All rights reserved, including reproduction, translation, microfilming, storage and processing in electronic systems.
Galileo Press, Rheinwerkallee 4, 53227 Bonn