XPointer with Example
Xpointers address the individual parts of an XML document.
Moreover, XPointer syntax builds on the XPath syntax used by XSLT.
Xpointers in Links
- Xpointers in URL
So, This URL points to the first name element in the document at http://www.ibiblio.org/xml/people.xml
Xpointers in Xlinks
- Xpointers are more frequently used in Xlinks.
- Moreover, The following example points to the first book child of the bookcoll child of the testament root element in the document at the relative URL ot.xml:
<link xlink:type=“simple” xlink:href=“ot.xml#xpointer(/testament/bookcoll/book[posi tion()=1])”>
- A bare name Xpointer is similar to an HTML named anchor; it identifies the element it points at by its name.
- However, an ID attribute of the element being pointed at, rather than a special an element with a name attribute, supplies this name.
- So, Many xpointers descend exclusively along the child axis, selecting elements by their position relative to their siblings
- xpointer(/child::*[position()=1]/child::*[position()=2]/child::*[ position()=3]) o selects the third child element of the second child element of the document’s root element.
Points and Ranges
- Xpaths, bare names and child sequences let you point only to entire nodes or sets of nodes.
- Also, Sometimes you may want to point to something that isn’t a node, such as the third word of the second paragraph.
- Moreover, XPointer adds points and ranges to the XPath syntax to make this possible.
- If the node contains child nodes, then points exist before and after each of its children.
- Also, If the node does not contain child nodes, then a point is present before and after each character in the node’s string value.
Moreover, Eight points located directly inside the novel element.
<novel copyright=“ public domain”>* Point 0
Point1 *<title>The Wonderful Wizard of Oz</title>* Point2
Point3 *<author>L. Frank Baum</author>*
- A range is the span of parsed character data between two points.
- So, Ranges are created with four functions that XPointer adds to XPath:
- range ( )
- range-inside ( )
- range-to ( )
- string-range ( )