Chapter 16: XML, XLink
XML + XLink + XPointer, written as if I’m sitting next to you — explaining patiently, step by step, with many examples, analogies, real-world context, and common confusion points.
We’ll go slowly so you really understand what these technologies are, why they were created, how they work, and why they are rarely used today (very important to know the honest reality in 2025–2026).
1. The Big Picture: What are XLink and XPointer?
XLink and XPointer were created in the late 1990s / early 2000s as part of the XML family to solve one main problem:
How do we create rich, two-way, typed, bidirectional links inside XML documents — much more powerful than simple HTML <a href=”…”> links?
| Technology | Purpose | Main idea | Status in 2025–2026 |
|---|---|---|---|
| XLink | Define links (simple or extended) | Describes how to link between resources | Almost never used today |
| XPointer | Point to specific parts inside a resource | Describes where exactly to go inside an XML/HTML document | Almost never used today |
Very important reality check (you should know this):
- Both were very ambitious and theoretically elegant
- Both were very complex to implement correctly
- Browsers never fully supported them (only very partial support in early Firefox / Opera)
- Today almost no one uses XLink or XPointer in real projects
- Most people who need linking in XML use simple attributes (href, id, idref) or switch to JSON + URLs
Still — you should understand them because:
- You will meet them in old documentation, government standards, publishing formats, older XML specifications
- Some niche domains (technical documentation, legal XML, DocBook, DITA) still mention them
2. First Concept: XLink – The Link Itself
XLink allows you to create links inside XML documents that are:
- Typed (simple vs extended)
- Bidirectional (in theory)
- Multi-destination (link to many resources at once)
- Descriptive (you can say what kind of link it is)
There are two main kinds:
| Type | HTML equivalent | When to use it | Most common syntax |
|---|---|---|---|
| Simple link | <a href=”…”> | Normal one-way link (most common) | xlink:type=”simple” + xlink:href |
| Extended link | No real HTML equivalent | Complex links (multiple targets, roles, arcs) | xlink:type=”extended” + <arc> + <resource> |
Very First Simple XLink Example
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
<?xml version="1.0" encoding="UTF-8"?> <bookstore xmlns:xlink="http://www.w3.org/1999/xlink"> <book id="b101"> <title>Atomic Habits</title> <author>James Clear</author> <!-- Simple XLink --> <cover-image xlink:type="simple" xlink:href="https://images.example.com/atomic-habits-cover.jpg" xlink:show="new" <!-- open in new window --> xlink:actuate="onRequest" <!-- user clicks to activate --> >View Cover</cover-image> <!-- Link to Wikipedia page --> <more-info xlink:type="simple" xlink:href="https://en.wikipedia.org/wiki/Atomic_Habits" xlink:title="Read more on Wikipedia" >Wikipedia</more-info> </book> </bookstore> |
Key attributes (you must remember these):
| Attribute | Possible values | Meaning / most common usage |
|---|---|---|
| xlink:type | simple / extended | Simple = like HTML <a>, Extended = complex |
| xlink:href | Any URI | Where the link points (must always be present) |
| xlink:title | Text | Human-readable description (tooltip in theory) |
| xlink:show | new / replace / embed / other | How to show the target (new = new tab) |
| xlink:actuate | onLoad / onRequest | When to activate (onRequest = user clicks) |
Reality check: Browsers ignore almost all of these except xlink:href and xlink:type=”simple”. Most real systems treat XLink simple links exactly like HTML links.
3. Extended XLink (the ambitious part – rarely used)
Extended links allow:
- Multiple resources
- Bidirectional links
- Role-based connections (arcs)
Example (very rare in practice)
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<extended-link xlink:type="extended"> <!-- Resources (the things being linked) --> <resource xlink:type="resource" xlink:label="source" xlink:title="Main Document">Chapter 5</resource> <resource xlink:type="resource" xlink:label="target1" xlink:href="appendix.xml#sectionA"/> <resource xlink:type="resource" xlink:label="target2" xlink:href="glossary.xml#term-transaction"/> <!-- Arcs (the actual connections) --> <arc xlink:type="arc" xlink:from="source" xlink:to="target1" xlink:arcrole="http://example.com/role/reference" xlink:title="See Appendix A"/> <arc xlink:type="arc" xlink:from="source" xlink:to="target2" xlink:arcrole="http://example.com/role/definition"/> </extended-link> |
Honest truth: You will almost never see extended XLink in real projects. It was too complicated → no browser support → no tools supported it well.
4. XPointer – Pointing to Specific Parts Inside a Document
XPointer tells where exactly inside a document the link should go.
There are three main ways (you should know them):
| XPointer scheme | Syntax example | What it does | Still used? |
|---|---|---|---|
| element() | element(chapter5) | Go to element with id=”chapter5″ | Rarely |
| xpath() | xpath(//section[@id=’intro’]) | Use full XPath expression | Very rarely |
| bare name (id) | #chapter5 | Shorthand for element(chapter5) | Most common (still!) |
Most realistic example (what you actually see sometimes)
|
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
<!-- Linking from one document to a specific part of another --> <reference xlink:type="simple" xlink:href="manual.xml#introduction" >See the Introduction section</reference> <!-- or more precise --> <reference xlink:href="report.xml#element(sec3.2.1)" >Detailed calculation in section 3.2.1</reference> <!-- or even XPath (very rare) --> <reference xlink:href="catalog.xml#xpath(//product[@code='P-784512'])" >Product P-784512</reference> |
Reality check:
- #id style (bare name) → still sometimes used (because HTML does it)
- element() → almost never
- xpath() → almost never (too complex, no browser support)
5. Real-World Status in 2025–2026 (very important)
| Situation | What people actually do today |
|---|---|
| Need to link to another XML document | Use normal href=”file.xml#id” or href=”url#id” |
| Need to link inside HTML | Use HTML <a href=”#section”> |
| Need rich linking metadata | Use custom attributes + JSON-LD / microdata |
| Publishing / DocBook / DITA | Use link / xref elements with href + idref |
| Government / legal XML | Usually simple href + fragment identifiers |
Bottom line:
- XLink simple + bare #id → still appears sometimes
- Full XLink extended / XPointer XPath → museum technology
Quick Summary – What You Should Remember
| Feature | Most realistic usage in 2025–2026 | Typical syntax |
|---|---|---|
| Simple XLink | Like HTML link | xlink:type=”simple” xlink:href=”…” |
| Bidirectional / multi-target | Almost never used | — |
| XPointer bare name | Jump to element with that id | file.xml#chapter3 |
| XPointer element() | Very rare | file.xml#element(sec2) |
| XPointer xpath() | Extremely rare | file.xml#xpath(//p[3]) |
Practical advice:
If you see XLink in modern code → usually it is only the simple form and treated like a normal hyperlink.
Would you like to continue with one of these next?
- Real examples from DocBook, DITA, or TEI (where XLink still appears sometimes)
- How HTML5 and modern web replaced most of XLink/XPointer
- Comparison: XLink vs HTML <link> / <a> vs JSON-LD
- Why XML hyperlinking failed compared to HTML
- How fragments (#id) still work today in XML + HTML
Tell me which direction feels most useful or interesting for you right now! 😊
