Database Reference
In-Depth Information
Child
By looking at the identifiers of any two nodes, we can determine if one is the
child of the other. Given the identifiers for the element “Name,” which is 1.2.1 ,
and for the text node “Potato,” which is 1.2.1.1 , because the identifier for
“Potato” has as a prefix the identifier for “Name” and has one extra level in its
identifier, we can tell that it is a child of “Name.” We can also tell that it is the
first child of “Name” from the last level of its identifier.
Siblings
By looking at the identifiers of any two nodes, we can determine if they are sib‐
lings. Given the identifier for the element “Name,” which is 1.2.1 , and for the
element “Quantity,” which is 1.2.2 , because their identifiers have the same num‐
ber of levels and have the same prefix we can tell that the node with identifier 1.2
(“Vegetable”) is their parent. We can also tell that “Name” is the preceding sib‐
ling of “Quantity” because its last level has the lower identifier number of 1 ;
“Quantity” is numbered 2 , and therefore must be the following sibling of
“Name.”
Common ancestor
By looking at the common prefix of any two node identifiers, we can find their
common ancestor node. For example, if you take the node identifier for the text
node “Potato,” which is 1.2.1.1 , and the node identifier for the text node “8,”
which is 1.2.2.1 , and examine them from left to right, you will find that the
common prefix is 1.2 , and the node with the identifier 1.2 is the element
“Vegetable.”
Figure 4-10. A simple XML document and the corresponding DLN model
 
Search WWH ::




Custom Search