30 The XML Files: Develo pment of XML/XSL A pplications Using WebS phere Studio
The XML Pointer Language (XPointer), the language defined to express
fragment identifiers for any URI reference that locates a resource whose Internet
media type is one of text/xml, application/xml, text/xml-external-parsed-entity, or
application/xml-external-parsed-entity.
Some examples of Xpointers follow. Each of these selects a particular element in
a document.
The example finds the element with the ID United:
http://www.airlines.com/airline.xml#xpointer(id("United"))
The example finds the second language element in the document:
http://www.airlines.com/airline.xml#xpointer(descendant::language[position()=2]
)
The third example is a shorthand form of finding the element with the ID United.
http://www.airlines.com/airline.xml#United
The next two examples are more involved. It shows how one navigates down a,
say a DOM tree. Here is shows the navigation from the root node, to the spec
child, and from it to all the second language elements from any of the child
elements:
http://www.airlines.com/airline.xml#xpointer(/child::spec/child::body/child::*/
child::language[2])
http://www.airlines.com/airline.xml#xpointer(/spec/body/*/language[2])
The last example finds the second child element of t he fourteenth child element
of the root element:
http://www.airlines.com/airline.xml#/1/14/2
The final URI also points to the element with the ID United. However, if no such
element is present, it then finds the element with the I D UNITED:
http://www.airlines.com/airline.xml#xpointer(id("United"))xpointer(id("UNITED")
)
XPointer paths and steps
A XPointer path is made up from a number of steps. From a context node, each
step will relatively locate a specific point in the document. A location step has
three points: axis, node test and an optional predicate. This is in the form:
axis::node-test[predicate]
For aircraft::ROW[position()=34]:
򐂰The axis is aircraft