Books / Understanding XML / Chapter 7

Indexing and Linking in XML

Links in HTML documents are tagged with <A HREF="">, where the value of the HREF attribute refers to a target document.

XPointer and Xpath

XML Pointer Language (XPointer) is based on the XML Path Language (XPath), which supports addressing into the internal structures of XML documents. XPointer allows references to elements, attributes, character strings, and other parts of XML documents. XPointer referencing works regardless of whether the referenced objects bear an explicit ID attribute (an attribute named id, such as id="section4"). It allows for traversals of a document tree and choice of its internal parts based on various properties, such as element types, attribute values, character content, and relative position.

XPointers operate on the tree defined by the elements and other markup constructs of an XML document. An XPointer consists of a series of location terms, each of which specifies a location, usually relative to the location specified by the prior location term. Here are some examples of location paths:

  • child::para selects the para element children of the context node
  • child::* selects all element children of the context node
  • child::text() selects all text node children of the context node
  • child::node() selects all the children of the context node, whatever their node type
  • attribute::name selects the name attribute of the context node
  • attribute::* selects all the attributes of the context node
  • para matches any para element
  • * matches any element
  • chapter|appendix matches any chapter element and any appendix element
  • olist/item matches any item element with an olist parent
  • appendix//para matches any para element with an appendix ancestor element
  • / matches the root node
  • text() matches any text node
  • items/item[position()>1] matches any item element that has a items parent and that is not the first item child of its parent
  • item[position() mod 2 = 1] would be true for any item element that is an odd-numbered item child of its parent
  • @class matches any class attribute (not any element that has a class attribute)
  • div[@class="appendix"]//p matches any p element with a div ancestor element that has a class attribute with value appendix.

The following example is a combination of a URL and an XPointer and refers to the seventh child of the fourth section under the root element:,SECTION).child(7)

A link is an explicit relationship between two or more data objects or parts of data objects. A linking element is used to assert link existence and describe link characteristics.

XML Linking Language (XLink) allows elements to be inserted into XML documents in order to create and describe links between resources. In HTML, a link is unidirectional from one resource to another and has no special meaning, except it brings up the referred document when clicked in a browser. XLink uses XML syntax to create structures that can describe the simple unidirectional hyperlinks of today’s HTML as well as more sophisticated multidirectional and typed links. With XLink, a document author can do the following, among others:

  • Associate semantics to a link by giving a “role” to the link.
  • Define a link that connects more than two resources.
  • Define a bidirectional link.

A link is an explicit relationship between two or more data objects or portions of data objects. A linking element is used to assert link existence and describe link characteristics. Linking elements are recognized based on the use of a designated attribute named xml:link. Possible values are “simple” and “extended” (as well as “locator”, “group”, and “document”, which identify other related types of elements). An element that includes such an attribute should be treated as a linking element of the indicated type. The following is an example similar to the HTML A link:

<A xml:link="simple" href="">
The XLink<A>

An example of an extended link is:

 title="Web Resources"
	<xlink:locator href=""
	<xlink:locator href=""
	<xlink:locator href=""
 title="Netscape Communications"/>
	<xlink:locator href=""
 title="ABC News"/>

XLink provides behavior policies that allow link authors to signal certain intentions as to the timing and effects of link traversal. These include:

  • Show: The show attribute is used to express a policy as to the context in which a resource that is traversed to should be displayed or processed. It may take one of three values: embed, replace, new.
  • Actuate: The actuate attribute is used to express a policy as to when traversal of a link should occur. It may take one of two values: auto, user.
  • Behavior: The behavior attribute is used to provide detailed behavioral instructions.

Licenses and Attributions

Speak Your Mind