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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access