Going Deep: The XPath Data Model

In the XPath view of things, elements, attributes, text, comments, processing instructions, and even namespaces are represented internally as nodes connected in a tree shape. Some nodes, such as elements, may have child nodes, while others, such as attributes, have no children, as restricted by XML rules. A special node, called the root node, serves as the ultimate ancestor node.

Example 3-2 shows a short XML document, and Figure 3-1 shows how that document would be represented by a tree of nodes.

In this example, note that neither the XML declaration nor the DOCTYPE declaration produce any nodes. Thus, these XML data structures are effectively invisible to XPath and, by extension, XForms. On the other hand, notice how each element node has two namespace nodes attached: one for the xmlns:html declaration on the root element, which applies throughout, and one for the built-in declaration of the xml prefix, as seen in the attribute xml:lang. Even a short document ...

Get XForms Essentials now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.