3.4. An Introduction to XLinks
The rules for linking in XML are defined in a standard called the XML Linking Language, or XLink. In XML, any element can be made a linking element. This is necessary because XML does not predefine any elements. Since you can define your own elements, you also need to be able to make one or more of them links. The syntax and capabilities of XLinks were inspired by the successes (and failures, in some cases) of HTML. XLinks are compatible with the older HTML links, but add more flexibility and functionality.
HTML generally uses two kinds of links. The <A> element creates a link, but doesn't automatically traverse it; if the user chooses to follow the link, the document at the other end replaces the current document. The <IMG> element works silently and automatically, linking to graphic data and importing it to the document.
For the sake of comparison, let's look at how XLinks improve upon HTML links:
Any XML element can be made into a link. In HTML, only a few elements have linking capability.
XLinks can use XPointers to reach any point inside the document. HTML links that target specific locations within a document rely on dedicated anchors to receive them, requiring the author of the target document to anticipate the need for every possible link and provide anchors.
XML can use XLinks to import text and markup. In HTML, there is no way to embed text from the target into the source document.
XPointers can define a range of XML markup to refer ...
Get Learning XML now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.