Overview on XLink
Peter Egri
PhD student
1. Introduction
In pure XML one can only use data structures, but can not define relations (links) among data elements. XLink was created to allow such relations. Probably the most well-known type of link is the hyperlink in HTML, but it is very limited:
● it is unidirectional,
● it connects exactly two nodes,
● the source node must be an HTML document, and
● a hyperlink can not contain arbitrary metadata.
In XLink these limitations does not exist: we can also express complicated relationships among more than two resources. Although the links are written in XML, the connected nodes need not to be XML files or elements, but can be any resources (according to [2], a resource is any addressable unit of information or service). Hyperlink is just a special kind of link, which is used for presentation to a human user.
2. Basic definitions
A link – so-called XLink element - consists of several resources and defines arcs between pairs of these resources. The arcs are directed, so they contain a starting and an ending resource. Following or using an arc is called traversal.
A resource is called local, if it is inside the XLink element, otherwise it is remote and must be identified by an URI (Uniform Resource Identifier), which is defined in [3].
If the starting resource of an arc is local and the ending resource is remote, then the arc is called outbound. Conversely, if the starting resource is remote and the ending resource is local, then it is called inbound. If both the ending and starting resources are remote, then the arc is a third-party arc. If an XML document contains only inbound and third-party arcs, the it is called link database (linkbase).
A software is an XLink application, if it can interpret XML documents with XLink elements.
3. XLink elements
To use XLink, we must declare the xlink namespace:
xmlns:xlink=”http://www.w3.org/1999/xlink”
The xlink namespace provides 10 global attributes: type, href, role, arcrole, title, show, actuate, label, from and to.
An XML element is XLink element, if it has a type attribute from the xlink namespace with one the values “simple”, “extended”, “locator”, “arc”, “resource” or “title”, and it satisfies the constraints described by Table 1.
|
|
simple |
extended |
locator |
arc |
resource |
title |
|
type |
R |
R |
R |
R |
R |
R |
|
href |
O |
|
R |
|
|
|
|
role |
O |
O |
O |
|
O |
|
|
arcrole |
O |
|
|
O |
|
|
|
title |
O |
O |
O |
O |
O |
|
|
show |
O |
|
|
O |
|
|
|
actuate |
O |
|
|
O |
|
|
|
label |
|
|
O |
|
O |
|
|
from |
|
|
|
O |
|
|
|
to |
|
|
|
O |
|
|
Table 1. Global attributes of XLink elements
R indicates required and O indicates optional attributes for the appropriate types. These constraints can be tightened by additional DTDs (document type declaration, see [4] for details). Furthermore XLink elements can contain arbitrary non-XLink attributes.
4. Global attributes
4.1 Type attribute
The type of an XLink element must be set “simple”, “extended”, “locator”, “arc”, “resource”, “title” or “none”. If the type is “none”, then the element has no XLink-specified meaning.
4.2 Href attribute
The value of this attribute must be an URI which identifies a remote resource.
4.3 Role attribute
This is a semantic attribute, which can describe the meaning of a resource. Its value must be an URI referencing to a resource with the appropriate description. It is not necessary to use semantic attributes at all, it is just a possibility.
4.4 Arcrole attribute
Like role, this is also a semantic attribute, but intended to describe the meaning of an arc. Its value must be an URI.
4.5 Title attribute
This is also a semantic attribute, but rather than a detailed description, it can contain a brief characterization of the resource or arc in a human-readable form. Its value can be any string.
4.6 Show attribute
This is a behavior attribute which describes the desired presentation of the ending resource when traversing the arc. Its value can be “new”, “replace”, “embed”, “other” or “none”. The meanings of these values are the follows:
● “new”: the ending resource should be loaded in a new window, frame, pane or other relevant presentation context.
● “replace”: the ending resource should be loaded in the same window, frame, pane or other relevant presentation context in which the starting resource was.
● “embed”: the ending resource should be loaded in place of the presentation of the starting resource.
● “other” : the XLink application should look further to determine the appropriate traversing behavior.
● “none”: the behavior is unconstrained, the application can freely determine it.
4.7 Actuate attribute
This is also a behavior attribute, it describes the desired timing of a traversal. Its value can be either “onLoad”, onRequest”, “other” or “none”.
● “onLoad”: the application should traverse the link immediately on loading the starting resource.
● “onRequest”: the ending resource should be loaded when an appropriate event is triggered.
● “other”: the XLink application should look further to determine the appropriate traversing time.
● “none”: the behavior is unconstrained, the application can freely determine it.
4.8 Label attribute
This is a traversal attribute, it identifies non-uniquely the (local and remote) resources of the link. So a label can belong to a group of resources. Its value must be a NCName, which is definied in [5].
4.9 From attribute
This traversal attribute can take place in an arc and it identifies the starting resource or resources of the arc, so there must exist at least one resource in the same linking element with a label that has the same value.
4.10 To attribute
This is similar to the from attribute, but is identifies the ending resource(s).
5. Extended links
An XLink element is a linking element, if its type is “extended” or “simple”. A simple linking element is just a special form of extended element – with only two resources and an outbound link – so I will mainly focus on the usage of the extended elements.
Extended links are usually stored separately from the resources and associate resources, which are read-only or which do not support embedded links. The relation among extended link and non-linking XLink elements can be illustrated by the following figure:

Figure 1. Relationships among XLink elements
So extended elements can contain locator, arc, resource and title elements in any number and order, furthermore they can have any non-XLink-specified content. It is also valid if the extended linking element has only one resource or none at all.
5.1 Local resources
An XLink element indicates a local resource, if its type is “resource”. It can also have semantic attributes (role, title) and a label attribute which can be referenced by arcs. Resource elements can have any content, but the content has no XLink-specified meaning.
From now on when I write “resource” I mean both local and remote resources. If I want to write about element whose type is “resource”, I write “local resource”.
5.2 Remote resources
The XLink element whose type is “locator” indicates a remote resource. It must contain a href attribute with an URI which identifies a remote resource, and can also have additional attributes: role, title and label. Locator elements can have any content, but only title elements which are direct children of the locator have XLink-specified meaning (see 5.4).
5.3 Arcs
An XLink element defines an arc and provides traversal rules, if its type is “arc”. Arc elements can have any content, but only title elements which are direct children of the arc have XLink-specified meaning (see 5.4). The arcs can have semantic attributes (arcrole, title), behavior attributes (show, actuate) and traversal attributes (from, to).
The traversal attributes specifies the starting and ending resources of the arc, their values must appear in at least one resource in the same linking element as a value of a label. The arc element creates a traversal arc from every resource which has a label with the same value as the from attribute to every resource which has a label with the same value as the to attribute. For example if the from has value “label1”, to has value “label2” and there is two resources with the label “label1” and three resources with the label “label2” then the arc element creates six traversal arcs.
If the from or to attribute is not defined, it means all labels. If the is no arc element in an extended link, it means that there is an arc between every pair of resources. Important constraint is that all arcs must be unique, so there can not occur two arcs with the same from and to attributes.
If an arc element has an arcrole attribute with the value ”http://www.w3.org/1999/xlink/properties/linkbase”, then the ending resource must be an XML document and it is supposed to be a linkbase. Thus the XLink applications can access potentially relevant linkbases.
5.4 Titles
In addition to the title attributes, extended, arc and locator elements can also have title elements. They are mostly used for internationalization and localization purposes, or when several comments are needed.
5.5 Simple linking elements
As I mentioned earlier, a simple linking element is just a special link with two resources and an outbound arc. However it can occur that it has no href attribute, in this case the link is untraversable. The simple linking element - with all of its contents - is the local resource.
6. Example
In this small example I define a DTD for storing partnerships of a company . The document element is an extended link called “CompanyRelations”, inside we must first define our company which will be a local resource, then we can define arbitrary other companies divided into two types (supplier and buyer) and we can define the relationships among the companies.
Then I define a company (Me and Co Inc.), two suppliers, a buyer, the partnerships and some additional informations. The structure can be illustrated by the following figure:

Figure 2. Partnerhips among some fictious companies
<?xml version="1.0"
encoding="UTF-8"?>
<!DOCTYPE CompanyRelations [
<!ELEMENT
CompanyRelations (Company, (Supplier | Buyer | Partnership | Tooltip)*)>
<!ATTLIST
CompanyRelations
xmlns:xlink
CDATA #FIXED "http://www.w3.org/1999/xlink"
xlink:type
(extended) #FIXED "extended"
xlink:role
CDATA #IMPLIED
xlink:title
CDATA #IMPLIED
>
<!ELEMENT
Company ANY>
<!ATTLIST
Company
xlink:type
(resource) #FIXED "resource"
xlink:role
CDATA #IMPLIED
xlink:title
CDATA #IMPLIED
xlink:label
NMTOKEN #IMPLIED
>
<!ELEMENT
Supplier (Tooltip)*>
<!ATTLIST
Supplier
xlink:type
(locator) #FIXED "locator"
xlink:href
CDATA #REQUIRED
xlink:role
CDATA #IMPLIED
xlink:title
CDATA #IMPLIED
xlink:label
NMTOKEN "supplier"
>
<!ELEMENT
Buyer (Tooltip)*>
<!ATTLIST
Buyer
xlink:type
(locator) #FIXED "locator"
xlink:href
CDATA #REQUIRED
xlink:role
CDATA #IMPLIED
xlink:title
CDATA #IMPLIED
xlink:label
NMTOKEN "buyer"
>
<!ELEMENT
Partnership EMPTY>
<!ATTLIST
Partnership
xlink:type
(arc) #FIXED "arc"
xlink:arcrole
CDATA #IMPLIED
xlink:title
CDATA #IMPLIED
xlink:show
(new | replace | embed | other | none) #IMPLIED
xlink:actuate
(onLoad | onRequest | other | none) #IMPLIED
xlink:from
NMTOKEN #IMPLIED
xlink:to
NMTOKEN #IMPLIED
>
<!ELEMENT
Tooltip ANY>
<!ATTLIST
Tooltip
xlink:type
(title) #FIXED "title"
>
]>
<CompanyRelations
xlink:title="Partnerships of Me and Co. Inc.">
<Company
xlink:title="This is our company" xlink:label="MeAndCo">Me
and Co Inc.</Company>
<Supplier
xlink:href="companies/widgets.xml" xlink:title="Widgets
Ltd."/>
<Supplier
xlink:href="companies/acme.xml" xlink:title="ACME Inc.">
<Tooltip>This
is a reliable company</Tooltip>
</Supplier>
<Buyer
xlink:href="companies/tecso.xml" xlink:title="Tecso
Store"/>
<Tooltip>We
must find more buyers!!!</Tooltip>
<Partnership
xlink:title="Relation with our suppliers"
xlink:from="MeAndCo" xlink:to="supplier"
xlink:show="new" xlink:actuate="onRequest"/>
<Partnership
xlink:title="Relation with our buyers" xlink:from="MeAndCo"
xlink:to="buyer" xlink:show="new"
xlink:actuate="onRequest"/>
</CompanyRelations>
References:
[1] XML Techniques for E-Commerce
course by Michael Sonntag, 2004.
http://www.sonntag.cc/teaching/XML_E-Commerce
[2] XML Linking Language (XLink) Version 1.0
W3C Recommendation
[3] Uniform Resource Identifiers (URI): Generic Syntax
(RFC 2396) T. Berners-Lee, R. Fielding, L. Masinter
http://www.ietf.org/rfc/rfc2396.txt
[4] Extensible Markup Language (XML) 1.0 (Third Edition)
W3C Recommendation
http://www.w3.org/TR/2004/REC-xml-20040204/
[5] Namespaces in XML
World Wide Web Consortium
http://www.w3.org/TR/1999/REC-xml-names-19990114/