XML technologies / XML / XML in a Nutshell / XLinks / Link behavior
(Excerpt from “XML in a Nutshell” by Elliotte Rusty Harold & W. Scott Means)
So far we have stayed abstract: an XLink connects two resources, but we have not said how users see it or software responds. There is no universal answer. For example, when a browser encounters a roman element using an http URL, clicking might load the novel into the current window, replacing the linking document, or open a new window. A browser encountering a roman element with an isbn URN has even less obvious behavior: reserve the book at a local library for collection, perhaps, or order it online. Other links can trigger other actions. Some content is embedded directly, as with this image element:
<image width="152" height="345" xlink:type="simple" xlink:href="http://www.turing.org.uk/turing/pi1/sark.jpg" />The author probably intends the browser to fetch and display the image as soon as the link is found, embedding it in the current document rather than opening a window or replacing the document.
As XML describes documents more flexibly than HTML, XLink describes links more flexibly. It signals a connection but leaves its meaning to the application. It need not be blue underlined words clicked to jump from source to target, though it certainly can be.
Authors can suggest link handling through the attributes xlink:show and xlink:actuate. The attribute xlink:show tells the application what to do on activation, such as display the target in the current or a new window. The attribute xlink:actuate tells it when: immediately or only on an explicit user request, for example.
xlink:show
The optional attribute xlink:show has five values suggesting the display context for a linked resource:
newOpens a new window showing the target resource at the link URI.
replaceDisplays the target in the current window, replacing the current document.
embedEmbeds an image of the target at the link element’s position in the current document.
otherSpecifies behavior other than a new window, replacement or visible embedding. Other nonstandard markup understood by the application can specify the details.
noneSpecifies no behavior.
All five are only suggestions applications may ignore. A web spider, for example, opens no windows, probably ignores embedded links and treats the other four types identically. For xlink:show="new", Mozilla might open a new table in an existing window rather than a new window. All is allowed if meaningful for the application.
xlink:actuate
The optional attribute xlink:actuate has four values suggesting when an application should follow a link:
onLoadFollow immediately on encountering the link.
onRequestFollow when the user requests it.
otherOther document markup determines timing, not XLink.
noneNo further information says when or whether to follow. Following may make no sense, as for a book’s ISBN rather than a URL where it can be found.
Again these four values are suggestions applications may ignore. A spider uses its own algorithms to decide when to follow links. Different behavior for identical attributes is allowed if meaningful in the reading application’s context.
A traditional link supplied by the HTML element A, as in the first novel example on Simple links, would be encoded like this:
<roman xlink:type="simple" xlink:href="ftp://archive.org/pub/etext/etext93/wizoz10.txt" xlink:actuate="onRequest" xlink:show="replace">
<titel>The Wonderful Wizard of Oz</titel>
<autor>L. Frank Baum</autor>
<jahr>1900</jahr>
</roman>This waits for an explicit user request, such as clicking the link, before replacing the current document with the one at ftp://archive.org/pub/etext/etext93/wizoz10.txt. For embedded images, you probably want immediate retrieval and embedding in the source. Use this syntax:
<image xlink:type="simple" xlink:actuate="onLoad" xlink:show="embed" xlink:href="http://www.turing.org.uk/turing/pi1/bus.jpg" width="152" height="345" />Both xlink:show and xlink:actuate are optional. Applications should react appropriately if absent.
Copyright © 2005 O'Reilly Verlag GmbH & Co. KG
You may print the online version for your private use.
Otherwise, this chapter from “XML in a Nutshell” is subject to the same conditions as the bound edition: the work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
O’Reilly Verlag GmbH & Co. KG, Balthasarstraße 81, 50670 Köln, kommentar(at)oreilly.de