George Brocklehurst makes things for the internet.

XFN and the rev attribute

Posted on

Background: XFN and rel

XFN is a microformat that expresses relationships. If a page represents you (for example your blog or your profile on a social network site) you can annotate the links on that page to indicate whether you are linking to another of your own profiles or to a friend, colleague or contact's page.

The annotations are made using the (X)HTML rel attribute. The HTML 4 specification provides several standard values for the rel attribute include next, prev and contents. In an age of social networks, where URLs often represent people, XFN is a logical extension of this attribute.

Of course, this is open to abuse. I could add a link to this page that points to someone else's site and uses XFN to claim that it is also my site. This is why the claims made by XFN are generally not trusted unless they are reciprocal. For example, this blog links to georgebrock.com and georgebrock.com links back to this blog. Both pages claim that the other site is about the same person, and because the claim is reciprocal it can be considered trustworthy.

XFN and rev

I've recently been building a social networking site, and marking up the user profiles and contact lists using a combination of hCard and XFN. While I was marking this up I found myself reaching not only for the rel attribute, but also the less common rev attribute. The rev attribute specifies the reverse relationship described by the link, for example rel="prev" is equivalent to rev="next".

This is the markup that I came up with:

 <h2>1 user wants to be your friend</h2>
 <ul>
   <li class="vcard">
     <a rev="friend" class="fn url" href="…">
       Tom Smith
     </a>
   </li>
 </ul>

 <h2>Waiting for confirmation from 1 user</h2>
 <ul>
   <li class="vcard">
     <a rel="friend" class="fn url" href="…">
       Dick Jones
     </a>
   </li>
 </ul>

 <h2>Friends with 1 user</h2>
 <ul>
   <li class="vcard">
     <a rel="friend" rev="friend" class="fn url" href="…">
       Harry Taylor
     </a>
   </li>
 </ul>

I've also considered using some of my own link types (with an accompanying XMDP document, of course). For example, if you have asked to be friends with someone and they haven't yet confirmed the relationship that could be made more explicit using rel="friend" rev="unconfirmed" on your profile and inverse on their profile: rel="unconfirmed" rev="friend".

Pros and cons

There are a few things about this that I really like:

  1. The markup is more semantically rich that it would be if only using rel. It expresses not only all the claims that a user has made, but also all the claims that have been made about that user, even if they are not (or not yet) reciprocal.
  2. Having all the relationship information about a given user in one place makes it incredibly easy to extract very specific information with a tool like YQL or GRDDL without having to rely on specific knowledge of the page structure.

There are also a few things that I don't like:

  1. The rev attribute isn't often used and is commonly misunderstood (although I'm not sure why, the specification is very clear on what it means). Because of the lack of understanding the microformats wiki strongly discourages the use of rev.
  2. It has been suggested that using rev instead of rel for XFN link types is tantamount to creating a whole new microformat.
  3. The reason reciprocal claims are trustworthy is that they are made by both of the pages involved. This markup claims reciprocation without involving the other page. While this makes sense in this specific case (the links are between profiles in the same site and are being automatically generated based on the same set of data) it would not be good in the general case to assume that just because a link has both rel and rev it is reciprocal and therefore trustworthy.

What do you think?

I've not previously seen the link types defined in XFN used with the rev attribute, so I'm curious what other developers, and particularly those in the microformats community think of this?