What is XLink

Creating a Hyperlink in XML - Part 1

What is XLink? XML Linking Language (XLink) is a way of creating a hyperlink in XML. A hyperlink is a reference that a reader can follow to view another Internet page or object. XLink allows you to simulate what HTML does with the tag and create a workable passage inside the document. As with all things XML, there are rules to follow when creating an XLink. Developing a hyperlink with XML requires use of a Uniform Resource Identifier (URI) and namespace to establish the connection.

This lets you build a basic hyperlink within your code that can be seen in the output stream. To understand XLink, you must look closer at the syntax.

Creating an XLink Declaration

A namespace allows any component within XML code to be unique. XML relies on namespaces throughout the coding process as a form of identification. You must declare the namespace in order to create an active hyperlink. The best way to do this is to declare the XLink namespace as an attribute to the root element. This allows the entire document access to Xlink features.


XLink uses the URI provided by the World Wide Web Consortium (W3C) to establish the namespace. This means you will always reference this URI when creating an XML document that contains XLink.

Creating the Hyperlink

Once you have created the namespace declaration the only thing left to do is attach a link to one of your elements.


xlink:href="http://www.myhomepage.com">
This is my homepage. Check it out.

If you are familiar with HTML, you will see some similarities. XLink uses ‘href’ to identify the web address of the link. It also follows the link with text that describes the linked page the same way does.

XLink:type="simple" indentifies the link as ‘HTML-style.’

To open the page in a seperate window you would add the new attribute.


xlink:href="http://www.myhomepage.com" xlink:show="new">
This is my homepage. Check it out.

Adding XLink to your XML code creates dynamic pages and allows you to cross reference within your document. There are a few different ways to handle XLink in XML. In the next article, we will look closer at other functions of XLink, such as onload and embed.