views:

117

answers:

1

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"&gt;
  <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"&gt;
  <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!

+2  A: 

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"&gt;
  <firstChild id="ID1" customId="{1234-5678}" />
  ...
  <ref xlink:href="#xpointer(/root/firstChild[@customId = '{1234-5678}'])" />
</root>
Tomalak
Even href="#ID1" is shorthand for href="xpointer(id('ID1'))". Can't be done without XPointers.
Onots
Okay, it's starting to make more sense. That's kinda nice that everything comes back to XPath actually, since I'm fairly familiar with it. Just need to learn the XPointer specifics now! Thanks.
Gavin Schultz-Ohkubo
Note that the XPointer document referred to in the XLink spec has been superseded by the XPointer framework: http://www.w3.org/TR/xptr-framework/. The xpointer() scheme is defined in http://www.w3.org/TR/xptr-xpointer/.
Tomalak