The XLink Specification

The popularity of the World Wide Web is directly related to the mass appeal of hypertext links. In fact, a new phrase was coined to describe the process of moving between hyperlinked documents—Web surfing. Despite their popularity, current Web links are considered primitive in comparison to other linking specifications like those in the Hypermedia/Time-based Structuring language (HyTime) and the Text Encoding Initiative (TEI) guidelines. The XLink specification takes into account the advances of these predecessors to provide the capability to link XML documents.

Note

At the time of this writing, the XLink specification is still a candidate recommendation. The latest specification can be found at http://www.w3c.org/TR.


Comparison to HTML Hyperlinks

Hyperlinking has two basic components: linking and addressing. Linking is declaring a relationship between two objects. Addressing is a method for finding an object you want to associate with another object. In HTML, the A tag stands for anchor, the term in HTML for a resource. The A element describes a link and its HREF attribute points to the destination resource. The source of the link is the text in the content of the A element. For example:

<A HREF="http://java.sun.com">Java Technology Home </A>

An HTML link is analogous to a simple link in XLink. Here is an implementation of a simple link using XLink:

<MYLINK  xlink:type="simple" 
         xlink:href="http://java.sun.com">Java Home </MYLINK>

Note

All XLink attributes and elements can only be used after you have declared the xlink namespace. For example:

<MYDOC xmlns:xlink="http://www.w3.org/1999/xlink/namespace/">


Link Types

A link type can be one of seven values: "simple", "extended", "locator", "arc", "resource", "title", or "none". Before we explain each type, it is important to note that the value of the type attribute may be inferred by the application. In other words, the xlink:type attribute may be a #IMPLIED attribute whereby the processing application can infer its meaning from the other attributes available. This provides the flexibility for an application to treat an element as a link only under certain circumstances based on the value of other non–link-related attributes.

The definitions for each link type are

  • simple—A constrained link between two resources that is functionally identical to an HTML A element.

  • extended—A more powerful type of link that allows one-to-many connections and bidirectional traversal.

  • locator—Identifies an element that refers to a remote resource that is participating in a link.

  • arcFor use with an extended link in order to supply traversal, behavior, and semantic attributes for one traversal of the link (for one to-from combination).

  • resource—For use with an extended link to specify local resources that are participating in the link.

  • title—Both extended and locator type elements can have multiple human-readable titles by using any number of title type elements. One potential use of this is for internationalization.

  • none—Denotes the element as a non-XLink element. This allows an element to be conditionally treated as an XLink.

Link Attributes

There are four categories of XLink attributes: locators, arc ends, behavior, and semantics. Locator attributes define where a remote resource is located. Arc ends define the context of a link traversal (like direction). Behavior attributes define how the link is activated and what action should be taken with the resource it refers to. Semantic attributes give additional information about the link. Each category will have one or more attributes. All the attributes discussed later must be prepended with the xlink prefix.

There is only a single Locator attribute, which is href. The value of the href attribute must be a valid URI.

There are two arc end attributes: from and to. The values for both attributes must be an ID in an XML document. The intent of the from and to attributes are to provide contextual information to the processing application.

There are two attributes for specifying behavior: show and actuate. In contrast, HTML link (anchor) behavior is hardwired. The HTML link behavior is to activate the link based on a user click and replace the current document with the remote resource. The show attribute describes what action occurs when a link is traversed. The actuate attribute describes when a link traversal should occur. The show attribute may take one of four values: embed, replace, new, or undefined. Here are definitions for those four values:

  • embed—The designated resource should be integrated in the body of the resource at the start of the link.

  • replace—The designated resource should replace (for the purposes of display or processing) the resource at the start of the link.

  • new—The designated resource should be displayed in a new window.

  • undefined—The behavior of the application traversing the link is unconstrained by the XLink specification.

The actuate attribute may take one of three values: onLoad, onRequest, or undefined.

  • onLoad—The link should be traversed automatically as soon as the starting resource is loaded.

  • onRequest—The link should be traversed only on request (like a click) from the user.

  • undefined—When the link is traversed is unconstrained by the XLink specification. The application is free to use other cues.

Replace and user are the behaviors we are familiar with in HTML links. For example:

<A xlink:type="simple" xlink:show="replace" xlink:actuate="onRequest"

   xlink:href="http://www.mysite.com">This is my Site! </A>

Here is another example that would place the target resource into a separate window:

<NEWLINK xlink:type="simple" xlink:show="new" xlink:actuate="onRequest"
xlink:href="http://www.mysite.com">This is my Site! </NEWLINK>

There are attributes associated with semantics: role and title. The role is a link attribute that allows a free-form description of the purpose of the link. The title attribute provides human-readable text describing the link. The title is useful for presentation of the link.

The inline attribute can only have the value "true" or "false." If a link is inline, its contents count as the local resource of the link. An out-of-line link is one that is completely outside the resource it is linking.

There are constraints on where attributes can occur. Table 4.5 shows where attributes can occur by type. The columns are xlink:types and the rows represent attributes. An X indicates that the attribute is allowed within an element of that xlink:type.

Table 4.5. Attribute Placement Constraints
 simple extended locator arc resource title
type X X X X X X
href X  X    
role X X X X X  
title X X X X X  
show X X  X   
actuate X X  X   
from    X   
to    X   

Extended Links

An extended link is more powerful than a simple link and has these features:

  • Can connect any number of resources

  • Can create links to and from documents from outside the documents they are linking (create them out-of-line)

In order to create multi-ended links, an extended link separates the source from the targets of the link by using two subelement types: locator and arc. Here is an example of an extended link:

<TOPPICK  xlink:type="extended">
  <book xlink:type = "locator" xlink:href="book1.html" xlink:role="original" />
  <book xlink:type = "locator" xlink:href="book2.html" xlink:role="sequel" />
  <magazine xlink:type = "locator"  xlink:href="article.html"
            xlink:role="review" />
</TOPPICK>

Locator type elements can also have title, show, and actuate attributes. Locators are very similar to simple links. You can add attribute value defaults to the DTD to reduce the number of xlink attributes needed for a particular element.

When referring to resources, XML links can use XPointers, which are URIs that can refer inside an XML document. XPointers are discussed in the next section.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.133.79.70