XLink and XPointer Syntax
XLink syntax
In HTML we know the element defines a hyperlink. XML does not work that way. In an XML document you can use any name you like, so browsers cannot predict which elements act as hyperlinks.
The way to define hyperlinks in an XML document is to put a marker on an element that can act as a hyperlink.
Here is a simple example of using XLink to create a link in an XML document:
xlink:href="http://www.runoob.com">Visit Runoob xlink:href="http://www.w3.org">Visit W3C
To access XLink attributes and features we must declare the XLink namespace at the top of the document.
The XLink namespace is: "http://www.w3.org/1999/xlink".
xlink:type="simple" creates a simple two-ended link (meaning "from here to there"). Later we will look at multi-ended (multi-directional) links.
XPointer syntax
In HTML we can create a hyperlink that points both to an HTML page and to a bookmark inside that page (using #).
Sometimes it is useful to point to something more specific. For example, we may need to point to the third item of a particular list, or the second line of the fifth paragraph. This is easy to do with XPointer.
If a hyperlink points to an XML document, we can append an XPointer part to the URL in the xlink:href attribute, so we can navigate (through an XPath expression) to a specific location in the document.
For example, in the following example we use XPointer with the unique id "rock" to point to the fifth item in a list.
href="http://www.example.com/cdlist.xml#id('rock').child(5,item)"