Question

The general gist of a simple XLink to another node in the same document seems to be:

<root xmlns:xlink="http://www.w3.org/1999/xlink">
  <firstChild id="ID1" />
  ...
  <ref xlink:href="#ID1" />
</root>

Without using XPointer or XPath, is this as much as you can do with XLink? Could you do an XLink which, say, referred to a customId instead, something that looked like:

<root xmlns:xlink="http://www.w3.org/1999/xlink">
  <firstChild id="ID1" customId="{1234-5678}" />
  ...
  <ref xlink:href="#customId/{1234-5678}" />
</root>

Please don't just refer me to the W3 spec - I don't know about you, but it takes a special kind of person to be able to interpret them, and I am not that person today!

Anyway, I understand that most XLink seem to be about referring to external resources, and most examples I've seen use http links to web resources... I'm just curious as to what you can do with XLink in terms of referring to a specific part within an XML document.

Thanks!

Was it helpful?

Solution

I don't think there is a way that works without using XPointer or XPath. I know you don't want to be referred to the spec, but:

From the XLink spec:

the format of the fragment identifier [...] used within the URI reference is specified by the XPointer specification.

From the XPointer spec:

XPointer [...] is based on the XML Path Language (XPath)

So I'd say it is something like:

<root xmlns:xlink="http://www.w3.org/1999/xlink">
  <firstChild id="ID1" customId="{1234-5678}" />
  ...
  <ref xlink:href="#xpointer(/root/firstChild[@customId = '{1234-5678}'])" />
</root>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top