Creating a Hyperlink in XML With XLink

XML Linking Language (XLink) is a way of creating a hyperlink in Extensible Markup Language (XML). XML is used in web development, documentation, and content management. 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 a tag and create a workable passage inside a document.

As with all things XML, there are rules to follow when creating an XLink.

Developing a hyperlink with XML requires the 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.

XLink can be used in two ways to hyperlink in XML documents—as a simple link and as an extended link. A simple link is a one-way hyperlink from one element to another. An extended link connects multiple resources. 

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 a URI provided by the World Wide Web Consortium (W3C) to establish the namespace.

This means you always reference this URI when creating an XML document that contains XLink.

Creating the Hyperlink

After you make the namespace declaration, the only thing left to do is to attach a link to one of your elements.

xlink:href="http://www.myhomepage.com">
This is my home page. 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 HTML does.

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

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

Adding XLink to your XML code creates dynamic pages and allows you to cross-reference within a document. 

Format
mla apa chicago
Your Citation
Ferrara, Darla. "Creating a Hyperlink in XML With XLink." ThoughtCo, Jan. 18, 2018, thoughtco.com/what-is-xlink-3471373. Ferrara, Darla. (2018, January 18). Creating a Hyperlink in XML With XLink. Retrieved from https://www.thoughtco.com/what-is-xlink-3471373 Ferrara, Darla. "Creating a Hyperlink in XML With XLink." ThoughtCo. https://www.thoughtco.com/what-is-xlink-3471373 (accessed January 24, 2018).