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.

   

back to top