XLink and XPointer
The final piece of XML we cover is XLink and XPointer. These two creations fall under the Extensible Linking Language (XLL), a separate portion of the XML standard dedicated to working with XML links. Before we delve into this, however, we should warn you that the standard described here is subject to change at any time.
It’s important to remember that an XML link is only an assertion of a relationship between pieces of documents; how the link is actually presented to a user depends on a number of factors, including the application processing the XML document.
Unique Identifiers
In order to create a link, we must first have a labeling scheme for XML elements. We do this by assigning an identifier to specific elements we want to reference using an ID attribute:
<paragraph id="attack">Suddenly the skies were filled with aircraft.</paragraph>
You can think of IDs in XML documents as street addresses: they provide a unique identifier for an element within a document. However, just as there might be an identical address in a different city, an element in a different document might have the same ID. Consequently, you can tie together an ID with the document’s URI, as shown below:
http://www.oreilly.com/documents/story.xml#attack
The combination of a document’s URI and an element’s ID should uniquely identify that element throughout the universe. Remember that an ID attribute does not need to be named ”id,“ as we showed in the first example. You can name it anything ...
Get XML Pocket Reference 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.