# XML - Managing Data Exchange/XLink

* Chapters
* Appendices
* Exercises
* Computer Science Home
* Library and Information Science Home
* Markup Languages
* To do list
* Contributors list
* Contributing to Wikibooks
| Previous Chapter | Next Chapter |
| ← XPath | CSS → |
| Learning objectives Learn different techniques of implementing XLink's in XML create a custom XLink learn the functionality behind various XLink parameters | sponsored by: The University of Georgia Terry College of Business Department of Management Information Systems |

## Introduction

Through the use of Uniform Resource Identifiers (URI's), an XLink allows elements to be inserted into XML documents that create links between resources such as documents, images, files and other pages. An XLink is similar in concept to an HTML hyperlink, but is more powerful and flexible.
This chapter will be a general overview of the XLink syntax. It will also provide exposure to some of XLink's basic concepts. For the full XLink specification, see the latest version of the standard at:
http://www.w3.org/TR/xlink

## XLink

XLinks create a linking relationship between two or more resources. They allow for any XML element, image, text or markup files to be specified in the link.
By using a method similar to the centralized formatting of XSL stylesheets, XLinks allow a document's hyperlinks to be isolated and centralized in a separate document. As a linked document's addresses changes, the XLink remains functional.
The use of XLink requires the declaration of the XLink namespace. This namespace provides the global attributes for type, href, role, arcrole, title, show, actuate, label, from and to. The following example would make the prefix xlink available within the tourGuide element.

## XLink global attributes

The following table outlines the attributes that can be used with the xlink namespace. The global attributes are type, href, role, arcrole, title, show, actuate, label, from, and to. The table also includes descriptions of how the attributes can be used.
Exhibit 1: Table of global attributes
| Attributes | Description and Valid Values |
| type | Describes the meaning of an item simple - basic format similar to html linkage extended - more complex than simple types with multi functional format resource - provides local resources locator - provides remote resources arc - provides the ability to traverse from one resource to another title - readable name or explanation of link |
| href | Location of resource value is URI |
| role | Description of XLink's content value is URI describes the element whose role it is |
| arcrole | Description of XLink's content value is URI describe the relationship between the two sides of the arc |
| title | Name displayed, usually short description of link |
| show | Describes behavior of the browser once the XLink has been actuated and loaded new - load in a new window or frame replace - load in same window or frame embed - replace the current item other - look for information elsewhere none - not specified |
| actuate | Specifies when resource is retrieved or link processing occurs onRequest - when user requests the link onLoad - when page is loaded other - looks for information elsewhere none - not specified |
| label, from & to | Specifies link direction |

## XML schema

The following XML schema defines a tour guide that contains at least one city. Each city contains one or more attractions. The name of each attraction is an XLink.
Exhibit 2: XML schema for TourGuide

## XML document

The following XML document shows how the XLink, attractionName, defined in the XML schema, is used in an XML document. Note that it is necessary to include xlink:href="" within the attribute tags in order to define the linked website.
Exhibit 3: XML document for TourGuide.xsd (using XLink)

## XML stylesheet

The following XML stylesheet displays the contents of the XML document.
Exhibit 4: XML stylesheet TourGuide