-
XPointer allows the links to point to specific parts of an XML document
-
XPointer is a W3C Recommendation
-
XPointer uses XPath expressions to navigate in the XML document
<?xml version="1.0" encoding="UTF-8"?>
<employees>
<employee id="e001">
<image url="http://payroll.com/john.gif" />
<name>John</name>
<age>20</age>
</employee>
<employee id="e002">
<image url="http://payroll.com/james.gif" />
<name>James</name>
<age>30</age>
</employee>
</employees>
So, instead of linking to the entire document (as with XLink), XPointer allows us to link to specific parts of the document. To link to a specific part of a page, add a number sign (#) and an XPointer expression after the URL in the xlink:href attribute, like this: xlink:href=”http://payroll.com/employees.xml#xpointer(id(‘e001’))”. The expression refers to the element in the target document, with the id value of “e001″.
XPointer also allows a shorthand method for linking to an element with an id. we can use the value of the id directly, like this: xlink:href=”http://payroll.com/employees.xml#e001”.
Recent Comments