XPointer defines what follows the # in a link to XML. A shorthand pointer such as catalog.xml#b3 selects the element whose ID is b3. The element() scheme walks child positions, so element(/1/3/2) means the root, its third child element, then that one's second child; xmlns() binds prefixes. The richer xpointer() scheme, XPath plus character ranges, never got past a 2002 Working Draft, but libxml2 3,427 implements its XPath part:
cat > picks.xml <<'EOF'
<picks xmlns:xi="http://www.w3.org/2001/XInclude">
<xi:include href="booknest-catalog.xml" xpointer="element(/1/3/2)"/>
<xi:include href="booknest-catalog.xml" xpointer="xpointer(//book[@id='b6']/title)"/>
<xi:include href="booknest-catalog.xml"
xpointer="xpointer(string-range(//title, 'Harbor'))"/>
</picks>
EOF
xmllint --xinclude picks.xmlXPath error : Unregistered function: string-range ... <picks xmlns:xi="http://www.w3.org/2001/XInclude"> <title>Patterns of the Deep Web</title> <title>Gardens in Glass</title> </picks>
/1/3/2 counts elements only: the header is the root's first child, so the third is book b2. The range pointer, which older XInclude tutorials use to quote part of a sentence, fails, because no maintained processor supports string-range(). Rely on shorthand IDs and element(), prefer IDs because positions break when a partner inserts an element, and do anything finer in XSLT or XQuery.
XPointer
XPointer allows links to point to specific parts of an XML document instead of the whole XML document. For instance:| xlink:href="http://example.com/cars.xml#xpointer(id('BMW'))" |
An XPointer expression referencing the element whose id attribute is 'BMW'.
Because the above example references the 'id' attribute, it can be rewritten as:| xlink:href="http://example.com/cars.xml#BMW" |
Shorthand form of the same XPointer reference.
XPointer recognizes XPath.<foobar id="foo">
<bar/>
<baz>
<bom a="1"/>
</baz>
<bom a="2"/>
</foobar>
| xpointer(id("foo")) => foobar |
| xpointer(/foobar/1) => bar |
| xpointer(//bom) => bom (a=1), bom (a=2) |
| element(/1/2/1) => bom (a=1) — /1 descends into the first element (foobar), /2 descends into the second child element (baz), /1 selects the first child element (bom). |
(Courtesy of http://en.wikipedia.org/wiki/XPointer 30 )