XML technologies / XSLT / Introduction to XSLT 2.0 / Getting started with XSLT and XPath / The XML document as a tree / Attribute nodes
(Excerpt from "XSLT 2.0 & XPath 2.0" by Frank Bongers, Chapter 1.)
An element’s attributes are represented by attribute nodes with a name (QName) and a value. The element node is considered the parent of its attribute node, but the attribute node is not considered a child of the element. Instead, the attribute node is said to belong to the element node, much like a property.
Attribute nodes are therefore not a normal part of the document tree, whose nodes all have a complete parent-child relationship by definition. An attribute node is consequently less straightforward to access than other node types, except namespace nodes.
Warning:
If an attribute is assigned a default value through a DTD or a schema, the XML parser is responsible for inserting it when it is omitted from the source document. Since an XML parser is not required to process a DTD or schema, there may be no corresponding node for such a default attribute.
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 terms as the printed edition: the work and all its parts are protected by copyright. All rights are reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
Galileo Press, Rheinwerkallee 4, 53227 Bonn