4 XLink Markup Design

This section describes the design of XLink's markup vocabulary.

Link markup needs to be recognized reliably by XLink applications in order to be traversed and handled properly. XLink uses the mechanism described in the Namespaces in XML Recommendation [XML Names] to accomplish recognition of the constructs in the XLink vocabulary.

The XLink namespace defined by this specification has the following URI:

http://www.w3.org/1999/xlink

As dictated by [XML Names], the use of XLink elements and attributes requires declaration of the XLink namespace. For example, the following declaration would make the prefix xlink available within the myElement element to represent the XLink namespace:

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

Note:

Most code examples in this specification do not show an XLink namespace declaration. The xlink prefix is used throughout to stand for the declaration of the XLink namespace on elements in whose scope the so-marked attribute appears (on the same element that bears the attribute or on some ancestor element), whether or not an XLink namespace declaration is present in the example.

XLink's namespace provides global attributes for use on elements that are in any arbitrary namespace. The global attributes are type, href, role, arcrole, title, show, actuate, label, from, and to. All other attributes, and all elements, in the XLink namespace are reserved. Document creators use the XLink global attributes to make the elements in their own namespace, or even in a namespace they do not control, recognizable as XLink elements. The type attribute indicates the XLink element type (simple, extended, locator, arc, resource, or title); the element type dictates the XLink-imposed constraints that such an element must follow and the behavior of XLink applications on encountering the element.

Following is an example of a crossReference element from a non-XLink namespace that has XLink global attributes:

<my:crossReference
  xmlns:my="http://example.com/"
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xlink:type="simple"
  xlink:href="students.xml"
  xlink:role="http://www.example.com/linkprops/studentlist"
  xlink:title="Student List"
  xlink:show="new"
  xlink:actuate="onRequest">
Current List of Students
</my:crossReference>

Using global attributes always requires the use of namespace prefixes on the individual attributes.

In [XML Linking Language (XLink) Version 1.0], XLink elements are identified by the presence of an xlink:type attribute. In XLink 1.1, XLink elements are identified by the presence of either an xlink:type attribute or an xlink:href attribute:

4.1 XLink Attribute Usage Patterns

While the XLink attributes are considered global by virtue of their use of the namespace mechanism, their allowed combinations on any one XLink element type depend greatly on the value of the special type attribute (see 5.3 XLink Element Type Attribute (type) for more information) for the element on which they appear. The conformance constraint notes in this specification detail their allowed usage patterns. Following is a summary of the element types (columns) on which the global attributes (rows) are allowed, with an indication of whether a value is required (R) or optional (O):

  simple extended locator arc resource title
type O* 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    
* At least one of type or href must be specified.

(See also B Sample DTD, C Sample XML Schema, and D Sample RELAX NG Grammar for examples of non-normative schemas that illustrate the allowed patterns of attributes.)

This specification uses the convention "xxx-type element" to refer to elements that must adhere to a named set of constraints associated with an XLink element type, no matter what name the element actually has. For example, "locator-type element" would refer to all of the following elements:

<locator xlink:type="locator" ... />
<loc xlink:type="locator" ... />
<my:pointer xlink:type="locator" ... />

4.2 XLink Element Type Relationships

Various XLink element types have special meanings dictated by this specification when they appear as direct children of other XLink element types. Following is a summary of the child element types that play a significant role in particular parent element types. (Other combinations are not conformant.)

Parent type Significant child types
simple none
extended locator, arc, resource, title
locator title
arc title
resource none
title none

4.3 Attribute Value Defaulting

Using XLink potentially involves using a large number of attributes for supplying important link information. In cases where the values of the desired XLink attributes are unchanging across individual instances in all the documents of a certain type, attribute value defaults (fixed or not) may be added to a DTD or schema so that the attributes do not have to appear physically on element start-tags. For example, if attribute defaults were provided for the xmlns:xlink, xmlns:my, type, show, and actuate attributes in the example in the introduction to 4 XLink Markup Design, the example would look as follows:

<my:crossReference
  xlink:href="students.xml"
  xlink:role="http://www.example.com/linkprops/studentlist"
  xlink:title="Student List">
Current List of Students
</my:crossReference>

Information sets that have been created under the control of a DTD have all attribute values filled in. Note, however, that parsers are not required to process the external subset. Applications, such as web browsers, that do not process the external subset will not be aware of any default values identified therein.

Note also that using the attribute value default technique to specify the XLink namespace declaration has no equivalent in [RELAX NG], [XML Schema Part 1: Structures], or other modern schema languages. While it can be used when DTD-informed parsing is performed, it poses an interoperability risk and should be used with care.

4.4 Integrating XLink Usage with Other Markup

This specification defines only attributes and attribute values in the XLink namespace. There is no restriction on using non-XLink attributes alongside XLink attributes. In addition, most XLink attributes are optional and the choice of simple or extended link is up to the markup designer or document creator, so a DTD or other schema that uses XLink features need not use or declare the entire set of XLink's attributes. Finally, while this specification identifies the minimum constraints on XLink markup, schemas that use XLink are free to tighten these constraints. The use of XLink does not absolve a valid document from conforming to the constraints expressed in its governing schema.

Following is an example of a crossReference element with both XLink and non-XLink attributes:

<my:crossReference
  xmlns:my="http://example.com/"
  my:lastEdited="2000-06-10"
  xmlns:xlink="http://www.w3.org/1999/xlink"
  xlink:type="simple"
  xlink:href="students.xml">
Current List of Students
</my:crossReference>

4.5 Using XLink with Legacy Markup

Because XLink's global attributes require the use of namespace prefixes, non-XLink-based links in legacy documents generally do not serve as conforming XLink constructs as they stand, even if attribute value defaulting is used. For example, XHTML 1.0 has an a element with an href attribute, but because the attribute is a local one attached to the a element in the XHTML namespace, it is not the same as an xlink:href global attribute in the XLink namespace.

This specification defines XLink markup, that is, what combinations XLink attributes and what arrangements of elements with XLink attributes are conformant. It also defines the XLink semantics of such conformant markup. When XLink is used on elements that have other attributes or related elements with linking semantics, XLink can not and does not attempt to define the semantics of such combinations.

If an element allows such possibly conflicting markup to occur, it should specify the semantics of the result.