views:

40

answers:

1

I'm trying to design a RESTful interface for a filesystem-like web service. To provide hyperlinkability among the various resources (files, directories, etc.), I thought I would use XLink. However, it seems there is a strange omission from XLink: content types.

Atom provides an attribute to specify the content type of links as well as the linked resource's relationship to the current, as in:

<link rel="alternate" type="text/html" href="http://example.org"/&gt;

Because I am creating a custom content type for each of my resources' representations, this seems like an important bit of information to include in my hyperlinks.

I can kind of make out an analog to rel in the XLink spec (label, from and to, I guess?), but why is content type missing from XLink? Do they intend that the role is somehow meant to convey what a client finds at the end of a link? Perhaps I missed the purpose of XLink?

+2  A: 

It appears xlink has purposely ignored this; the only mention of media types or representations has to do with how fragment identifiers are to be interpreted. XLink actually only defines links to be between resources, and not their representations.

This means that if you used XLink you have to define your own way of specifying the expected media type of the target of the link, whereas if you use Atom's link you get the target media type, but not the versatility of XLink.

Since you're probably defining your own media type, it's not extremely important unless you want generic clients that don't know of your media type to be able to parse the embeded links. Any client that knows about your media type can read your documentation, and will know to use XLink, Atom, HTML (the link element) or your own proprietary link semantics.

Just as an example of the latter: The Sun Cloud API uses a JSON list of objects with rel, and href attributes for outgoing links.

mogsie
Ultimately I decided that suffering this shortcoming in XLink was not worth the added flexibility of extended links and whatnot. I've settled on Atom instead for links, as it provides everything we *need*, if not everything we want. Thank you very much for your thoughts!
ladenedge
I didn't want to bias you with my personal preference, but I would have chosen that too. Atom links are well understood, and have a registry and extension mechanism, and a wide variety of interesting links (e.g. for revision histories, paging, archives).
mogsie