XML technologies / XML / XML in a Nutshell / XPointer / Child sequences

(Excerpt from "XML in a Nutshell" by Elliotte Rusty Harold & W. Scott Means)

Another very common form of XPointer is one that descends exclusively along the child axis, selecting elements by their position relative to their siblings. For example, xpointer(/child::*[position()=1]/child::*[position( )=2]/child::*[position( )=3]) selects the third child element of the second child element of the document’s root element. The element() scheme lets you abbreviate this syntax by specifying only the child numbers, separated by slashes. This abbreviation is called a child sequence. The preceding XPointer could be rewritten using the element() scheme in the much more compact form element(/1/2/3).

For example, the previously mentioned “Motivation and Summary” section of the recommendation Namespaces in XML at "http://www.w3.org/TR/1999/REC-xml-names-19990114/xml-names.xml" (see page Shorthand pointers) is represented as a div element. This div element is the first child element of the second child element of the root element. Therefore, "http://www.w3.org/TR/1999/REC-xml-names-19990114/xml-names.xml#element(/1/2/1)" points to this section.

  

 

 

 

back to top