XML.com: XML From the Inside Out
oreilly.comSafari Bookshelf.Conferences.


A Technical Introduction to XML
by Norman Walsh | Pages: 1, 2, 3, 4, 5, 6

Pulling the Pieces Together

The XPointer and XLink specifications, currently under development, introduce a standard linking model for XML. In consideration of space, and the fact that the XLink draft is still developing, what follows is survey of the features of XLink, rather than a detailed description of the specification.

In the parlance of XLink, a link expresses a relationship between resources. A resource is any location (an element, or its content, or some part of its content, for example) that is addressed in a link. The exact nature of the relationship between resources depends on both the application that processes the link and semantic information supplied.

Some highlights of XLink are:

  • XLink gives you control over the semantics of the link.
  • XLink introduces Extended Links. Extended Links can involve more than two resources.
  • XPointer introduces Extended Pointers (XPointers). XPointers provide a sophisticated method of locating resources. In particular, XPointers allow you to locate arbitrary resources in a document, without requiring that the resource be identified with an ID attribute.

Since XML does not have a fixed set of elements, the name of the linking element cannot be used to locate links. Instead, XML processors identify links by recognizing the xml:link attribute. Other attributes can be used to provide additional information to the XML processor. An attribute renaming facility exists to work around name collisions in existing applications.

Two of the attributes, show and actuate allow you to exert some control over the linking behavior. The show attribute determines whether the document linked-to is embeded in the current document, replaces the current document, or is displayed in a new window when the link is traversed. actuate determines how the link is traversed, either automatically or when selected by the user.

Some applications will require much finer control over linking behaviors. For those applications, standard places are provided where the additional semantics may be expressed.

Simple Links

A Simple Link strongly resembles an HTML <A> link:

<link xml:link="simple" href="locator">Link Text</link>

A Simple Link identifies a link between two resources, one of which is the content of the linking element itself. This is an in-line link.

The locator identifies the other resource. The locator may be a URL, a query, or an Extended Pointer.

Extended Links allow you to express relationships between more than two resources:

<elink xml:link="extended" role="annotation">

<locator xml:link="locator" href="text.loc">The Text</locator>

<locator xml:link="locator" href="annot1.loc">Annotations

<locator xml:link="locator" href="annot2.loc">
	More Annotations</locator>

<locator xml:link="locator" href="litcrit.loc">
	Literary Criticism</locator>


This example shows how the relationships between a literary work, annotations, and literary criticism of that work might be expressed. Note that this link is separate from all of the resources involved.

Extended Links can be in-line, so that the content of the linking element (other than the locator elements), participates in the link as a resource, but that is not necessarily the case. The example above is an out-of-line link because it does not use its content as a resource.

Extended Pointers

Cross references with the XML ID/IDREF mechanism (which is similar to the #fragment mechanism in HTML) require that the document being linked-to has defined anchors where links are desired (and technically requires that both the ID and the IDREF occur in the same document). This may not always be the case and sometimes it is not possible to modify the document to which you wish to link.

XML XPointers borrow concepts from HyTime and the Text Encoding Initiative (TEI). XPointers offer a syntax that allows you to locate a resource by traversing the element tree of the document containing the resource.

For example,


locates the third child (whatever it may be) of the second oldjoke in the document.

XPointers can span regions of the tree. The XPointer


selects the second and third oldjoke s in the document.

In addition to selecting by elements, XPointers allow for selection by ID, attribute value, and string matching. In this article, the XPointer


selects the first occurance of the word "Here" in the What Do XML Documents Look Like? section of this article. The link can be established by an extended link without modifying the target document.

Note that an XPointer range can span a structurally invalid section of the document. The XLink specification does not specify how applications should deal with such ranges.

Extended Link Groups

Out-of-line links introduce the possibility that an XML processor may need to process several files in order to correctly display the hypertext document.

Following the annotated text example above, assuming that the actual text is read only, the XML processor must load at least the text and the document that contains the extended link.

XLink defines Extended Link Groups for this purpose. Loading an Extended Link Group communicates which documents must be loaded to the XML processor. Extended Link Groups can be used recursively, and a steps attribute is provided to limit the depth of recursion.

Understanding The Pieces

Some documents, particularly compound documents pulled together with XLinks, are likely to be composed of elements from multiple tag sets. For example, a technical article might be written using one DTD, but include mathematical equations written in MathML and vector graphics written in a third DTD.

In order for a processing application to associate the correct semantics with an element, it must know which tag set the element comes from. XML solves this problem with namespaces. Namespaces in XML describes this system in detail.

The principle is to allow a colon-delimited prefix to be associated with some external semantic via a URI. Then use of that prefix identifies the element as having the semantics described by the URI. For example:

<bk:para>The fraction 3/4 can be expressed in MathML as:

<ml:cn type="rational">3<ml:sep/>4</ml:cn>.</bk:para>

The para element in this example is explicitly identified as being in the namespace identified by the bk prefix, which must have been defined earlier in the document, and the cn and sep elements come from the ml namespace (presumably associated in some way with MathML).

Style and Substance

HTML browsers are largely hard-coded. Although some browsers can base their formatting on Cascading Style Sheets (CSS), they still contain hard-coded conventions for documents which do not provide a stylesheet. A first level heading appears the way that it does largely because the browser recognizes the <h1> tag.

Again, since XML documents have no fixed tag set, this approach will not work. The presentation of an XML document is dependent on a stylesheet.

The standard stylesheet language for XML documents is the Extensible Style Language (XSL). At the time of this writing, the XSL effort is well underway, but many questions remain unanswered. The XSL Working Group produced its first Working Draft on 18 Aug 1998.

Other stylesheet languages, like Cascading Style Sheets, are likely to be supported as well.


In this article, most of the major features of the XML Language have been discussed, and some of the concepts behind XLink, Namespaces, and XSL have been described. Although some things have been left out in the interest of the big picture (such as character encoding issues), hopefully you now have enough background to pick up and read the XML Specifications without difficulty.

Pages: 1, 2, 3, 4, 5, 6

Next Pagearrow