Overview of XLink


Many people want to use XML on the Web, where linking is an absolute requirement, so it makes sense to define a companion linking standard for XML. Also, once people can easily exchange and understand structured documents, specifying relationships among them becomes very valuable . These forces have motivated the XML Linking Language (XLink) initiative. However, the advanced features of XLink may have little appeal to mainstream Web users.

Most Web authors are familiar with HTML and its href syntax. Therefore, a goal of the XLink specification is to make it very simple to use this syntax to create a one-way link from a point in an XML source document to a target document. This compatibility lowers the learning barrier for existing Web developers. It also raises the question of whether XLink gives these developers enough incentive to adopt it.

With XLink, it is possible to go beyond simple HTML-like links. Theoretically, once people have access to a wide variety of content structured in XML, they will naturally want to connect different pieces of this content in many different ways. To accommodate this need, XLink offers powerful capabilities for specifying relationships among multiple target documents rather than just between two documents. Of course, this more sophisticated approach requires more sophisticated software infrastructure and more sophisticated user behavior.

Suppose that an attorney has researched a particular esoteric and complex point of the law. Parts of many different court opinions apply in differing degrees to this attorney's particular case. With XLink, the attorney could create an extended link that led to all the different opinions, categorized the opinions by relevance, and pointed to specific passages in the opinions . The attorney could then e-mail this extended link to other attorneys on the case. To accomplish this task, the attorney would need software features for creating the extended link, and his colleagues would need software features for navigating them. Whether there is a need for such features outside of specialized domains such as law and medicine remains an open question.

How It Works

Links with multiple targets are an exciting development, but let's start with the simple case. If you wanted to link just one Order Document to one Customer Document, you would use a simple link . A simple link is very similar to a standard HTML link. Figure 3-6 shows how the link is defined as part of the Order Document and targets the Customer Document.

Figure 3-6. A Simple XLink

graphics/03fig06.jpg

The syntax for a link is itself XML. Therefore, extracting the linking information from a document does not require any additional capabilities. However, knowing what to do with this information requires an XLink processor that understands linking information. Document viewers such as Web browsers, therefore, need to include such a component to support links using the XLink syntax. Example 3-13 shows the actual syntax for the simple link represented in Figure 3-6.

Example 3-13
 <Customer  xlink:form="simple"  xlink:inline="true"  xlink:href="http://www.foocompany.com/customers/   barcorp.xml"  xlink:show="new"  xlink:actuate="user"  xlink:title="Bar Corporation"  xlink:label="Customer">  Bar Corporation </Customer> 

This XLink comprises a set of attributes on an element. Because these attributes use the XLink namespace, you can attach them to any element without affecting the processing of that element. Only the XLink processor will receive the information contained in these attributes. The "inline" attribute indicates whether the element contents, in this case "Bar Corporation," are themselves part of the link. The "form" attribute specifies that this link is a simple link. The "href" attribute specifies the URI of the target document.

In addition to these basic attributes, there are special attributes to indicate the desired behavior for the link. The "show" attribute instructs the processor to open a new window for the target document. The "actuate" attribute instructs the processor to activate the link when the user clicks on it. The rest of the attributes provide the XLink processor with contextual information about the link. The interpretation of contextual attributes may be specific to a particular XLink processor.

As shown in Figure 3-7, extended links allow multiple target documents. In this example, a Tracking Document associates the corresponding Invoice Document and Shipping Document. This Tracking Document contains only this link. Even though the Tracking Document is a valid XML document, it is logically independent of the content it connects. This separation of relationships from content is a powerful tool for categorizing content on the Web. For a given set of logical documents, there may be dozens of different categorizations, all implemented with links and all independent of each other.

Figure 3-7. Extended XLink

graphics/03fig07.jpg

An extended link has more complex structure than a simple link. Because the link includes multiple targets, there will be subelements corresponding to each target. Therefore, extended links have two kinds of attributes: those that appear once in the top-level element of the link and those that appear in each of the subelements corresponding to a target. Example 3-14 shows this syntax for the link represented in Figure 3-7.

Example 3-14
 <OrderTracking xlink:form="extended">   <Invoice   xlink:form="locator"   xlink:href="http://www.foocompany.com/    BarCorpInvoice.xml"   xlink:title="Bar Corporation Invoice"   xlink:label="Invoice"/>   <Shipment   xlink:form="locator"   xlink:href="http://www.foocompany.com/    customers/BarCorpShipment.xml"   xlink:title="Bar Corporation Shipment"   xlink:label="Shipment"/> </OrderTracking> 

The "OrderTracking" element is at the top level for this link, so it has the "xlink:form" attribute set to "extended." The XLink processor then knows to look for additional attributes on the subelements. In this case, there are "Invoice" and "Order" subelements, each corresponding to a target document. The "locator" value of the "xlink:form" attribute indicates that the subelement corresponds to an external document, while the "xlink:href" attribute gives the location of the document. Extended links have the same attributes as simple links for indicating contextual information such as "xlink:label" and "xlink:title." In addition to the attributes shown here, there is also a set of advanced extended link attributes useful for creating sophisticated semantic webs among documents.

As discussed in the coverage of XPointer, you can combine XLink and XPointer to refer from one document to a specific location within another document. In this case, you add a "#" to the end of the URI in the "xlink:href" attribute and then append the XPointer expression.

Practical Usage

As with XSL, the finalized version of XLink is relatively new. The most important factor affecting the adoption of XLink is the availability of XLink-capable Web infrastructure. At the time of this writing, only open source browsers supported XLink, although work on compatibility with major commercial browsers was under way. Moreover, most browsers limit support to simple links. While XLink simple links are somewhat more powerful than HTML links, they still suffer from the problem of being embedded in the source document. Therefore, delivering on the goal of separating relationships from content necessitates support for extended links.

Support for extended links really requires server-side support because an extended link is essentially a virtual document that requires dynamic assembly. The actual implementation of such a server is more difficult than it might seem because there are issues with how to deal with links to documents that themselves contain links. If limited demand for such advanced capabilities does not justify the inclusion of the necessary infrastructure in general purpose Web servers, the use of extended links may be limited to dedicated hypertext systems in specialized applications such as bioinformatics.

Just as XSL will likely be limited to publishing applications, XLink will likely be limited to hypertext applications. People probably won't apply XLink to application-generated XML documents very much, so application developers will not need to be very familiar with it. However, potentially any XML document could become part of paginated output or part of a hypertext archive, so a general awareness of these standards is valuable.



XML. A Manager's Guide
XML: A Managers Guide (2nd Edition) (Addison-Wesley Information Technology Series)
ISBN: 0201770067
EAN: 2147483647
Year: 2002
Pages: 75
Authors: Kevin Dick

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net