René Nyffenegger's collection of things on the web
René Nyffenegger on Oracle - Most wanted - Feedback -
 

XLink

Generally speaking, a link relates two (or more) resources. Those resources can be in virtually any format: an XML document, a music file, a picture, a query result or what ever you care to link to.
XLinks works on locations, not on resources.
Links provide the following conviniences:
  • A document can be splitted in smaller chunks. Each chunk can be worked on independently.
  • Eases navigation: index, table of content, footnotes and the like
  • Can cite other documents.
  • Solves the problem of having (and updating!) the same data in multiple documents.

Problems with (traditional) HTML links

  • HTML defines a limited set of tags that can link: <a> and <img>. The other tags cannot link. However, it is desirable to be able to link from any element.
  • The behaviour of a link is defined by the tag. It is desirable to be able to define those behaviours. (See the attributes show and actuate.
  • A link's target needs to have an anchor (if it is within the document). This is a problem if we cannot modify the target document. Solution: XPointer
  • The link definition is where the link source is. No provision for inbound links and third-party links. (See also Example third party link)
  • A link is limited to one direction with only one source and only one target.

Terminology

A link is a (explicitely stated) relationship between two (or more) locations.
The link is said to be
  • outbound
    if the link's source is a local resource
  • inbound
    if the link's destination is a local resource
  • third party
    if none of the resources are local.

Linking element

An XML Element that describes a link.

Locator

A locator identifies a remote resource participating in a link.

A setup for a XLink element

For an element to be an XLink, it must use the XLink namespace. The following fragment turns some_element into a source of a link.
<some_element

   xmlns:xlink="http://www.w3.org/1999/xlink

   ....  ....
>

</some_element>
The following code is a complete, although small, example for an XML docment with a DTD that contains an XLink.
<?xml version="1.0" ?>
<!DOCTYPE Author 

[
  <!ELEMENT Author EMPTY >

  <!ATTLIST Author
     xmlns:xlink    CDATA #FIXED "http://www.w3.org/1999/xlink" 
     xlink:type    (simple|extended|locator|arc|resource|title|none) #REQUIRED
     xlink:href     CDATA #REQUIRED 
     xlink:role     CDATA #IMPLIED
     xlink:title    CDATA #IMPLIED
     xlink:show    (new|embedded|replace) "replace"
     xlink:actuate (onLoad|onRequest)     "onRequest"
     >
]
>

<Author
  xmlns:xlink   = "http://www.w3.org/1999/xlink"
  xlink:type    = "simple"
  xlink:href    = "somebody.xml"
  xlink:role    = "author"
  xlink:title   = "author"
  xlink:show    = "replace"
  xlink:actuate = "onRequest"
/>
An XML element is an XLink if
Although the type attribute indicates there are a few types of XLinks, this is not true, there are only simple links and extended links. Simple links are functionally equivalent to HTML hyperlinks.

Types

simple

A link is simple if its attribute type is set to "simple".
Optional attributes of such an element are: href, role, arcrole, title, show, actuate
A simple element is outbound.

extended

A link is simple if its attribute type is set to "extended".
Can have locator arc resource title as children.
Optional attributes are: role and title

locator

A locator is only possible within extended links. There is a lcoator for each resource that participates in an extended link.
Can have title as child.
Optional attributes are: role, title, label
href is a mandatory attribute.
role, title and href are equivalent to their use for simple links.
href is also called the locator attribute.
Note: a locator does not necesseraly point to a target. It points to a resource that is involved in linking. In order to establish a connection, arc is needed.

arc

Defines a traversal rule between any combination of two locators and resources.
Can have arc as child.
Optional attributes are: arcrole, title, show, actuate, from, to

resource

The resource type indicates a local resource (as opposed to the locator type).
Optional attributes are:

title

none

Attributes in an XLink Element

role

Content not specified by w3c (?), indicates the role (nature) of the link. It must be uri reference.

arcrole

Content not specified by w3c (?). It must be uri reference.

title

A link describing string for the user.
How the title is used in a XLink Application is not defined.

href

The target of the link.

show

How the target is rendered. Possible values:
  • new
  • replace
  • embedded

actuate

Defines when the link is executed. Possible values:
  • onRequest
  • onLoad

type

Can be either
  • simple
  • extended
  • locator
  • arc
  • resource
  • title
  • none

from

The value must be equal to a label value in a resource or locator type.

to

label

The value of a label attribute is referenced by the same value in a from or to attribute.

Weird combinations

A combination of xlink:show="replace" and xlink;actuate="onLoad" makes limited sense. It could be interpreted as a redirection. However, what happens if two such combinations are present in a document?
Extended Links allow to combine multiple resources.

Third party link

<lnk
  xmlns:xlink   = "http://www.w3.org/1999/xlink"
  xlink:type = "extended">

  <res xlink:type = "locator" xlink:href="foo.bar" xlink:label= "fromHere" />

  <res xlink:type = "locator" xlink:href="foo.bar" xlink:label= "toThere" />

  <arc xlink:type= "arc" xlink:from="fromHere" xlink:to="toThere" />

</lnk>

An XLink Application interprets well formed XML document with XLink elements and attributes.

Links

Misc

A type=resource identifies a local resource while a locator defines a remote resource. This can be a bit missleading.