by Thomas Erl
When comparing XML to HTML, XML’s huge data-centric feature set makes it an attractive alternative to HTML, as a standard document format. However, even when pairing XML with XSL’s formatting functionality, a feature-by-feature comparison of XML+XSL versus HTML will point out one major omission from XML’s list: hyperlinking. With HTML documents, adding hyperlinks is as easy as surrounding a piece of text with anchor (<a>) tags, and adding the link destination as a URL to the tag’s hyperlink reference (href) attribute, as follows:
Click <a href=”www.xmltc.com”>here</a> now.
This HTML statement is rendered as below, once displayed by a browser:
Click here now.
The underlined part of the text represents a link to the SOA Systems’ Web site. This simple ability to provide hyperlinks within a Web page text is arguably the Internet’s most powerful feature, yet an XML document (even when linked to an XSL style sheet) cannot provide this functionality on its own. This is why XLink was developed. Not only does XLink supply the ability to create HTML hyperlinks, its specification is equipped with an elaborate language that addresses many shortcomings of the HTML anchor tag.
For instance, with XLink, a document’s hyperlinks can be isolated in a separate link document. This centralizes link information the same way XSL style sheets centralize formatting information, and the benefits are very similar. If the destination address of a hyperlink changes, it only needs to be updated in one location. Also, in an HTML authoring environment, a document editor would need to have write permissions in order to add hyperlinks to a previously authored HTML document. This is no longer necessary, as the editor can now generate the links independently.
Additionally, with XLink developers can now add meta information to hyperlinks, which can provide the user with comprehensive information about the destination resource of a hyperlink, without having to visit it.
Finally, through the creation of a complex linking structure, XLink can even create linking associations between more than two resources.
XLink structures (regardless of whether they are embedded in XML documents or exist externally), can represent either “simple” or “extended” links (which is defined through the XLink type attribute). A simple link structure provides basic information to associate the origin and destination resources, as follows (note that the numbers on the left are line numbers):
1. <sample:linkelement xmlns:sample="http://www.samplereports.com/"
5. xlink:title="Report on SOA Systems Inc."
7. SOA Systems Inc.
This XLink structure is really just an XML element definition with a series of attribute/value pairs. This first line:
…defines the namespace within which this link file is active.
The second line:
…specifies the XLink specification used by the processor.
On the third line:
…the type attribute defines this structure as being of type “simple.”
The fourth line:
…contains the familiar href attribute, which provides the address of the destination resource.
The title attribute on the fifth line:
xlink:title="Report on SOA Systems Inc."
…assigns the link a text value independent from the displayed text representing the link (this is similar to the HTML alt attribute).
On the sixth line:
…the show attribute is comparable to the HTML target attribute, in that it provides options for how the browser will behave when opening the destination resource.
Finally, the last line before the XLink end-tag:
SOA Systems Inc.
…simply contains the text that is displayed in the browser, to which the hyperlink information is assigned.
Extended links are beyond the scope of this paper, however it is sufficient to state that they introduce the ability to create complex link structures by providing the features to identify multiple link “participants” which can be associated in different ways. Additionally, the “link traversal” paths between participants can also be defined by extended link structures.
- Inside XML Schemas
- SOAP in a Nutshell
- Transforming Data with XSLT
- Understanding DTDs
- Why SAX is Good for DOM
- What You Should Know about XPath
- An XHTML Primer
- XLink - Inside and Out
- Data Access with XQuery
- XSL versus CSS
- Another Introduction to XML
- Unifying Corporate Data & Documents
- Replacing HTML Documents with XML
- Meta-Enable Your Enterprise
- The XML Data Custodian
- Integrating XML into the Enterprise
- The Wireless Enterprise
Foreword by Grady Booch
With contributions from David Chappell, Jason Hogg, Anish Karmarkar, Mark Little, David Orchard, Satadru Roy, Thomas Rischbeck, Arnaud Simon, Clemens Utschig, Dennis Wisnosky, and others.
Governing Shared Services On-Premise & in the Cloud by Stephen Bennett, Thomas Erl, Clive Gee, Anne Thomas Manes, Robert Schneider, Leo Shuster, Andre Tost, Chris Venable
For more information about these books, visit: www.servicetechbooks.com