xfolk-to-rdf-old

From Microformats Wiki
Jump to navigation Jump to search

xFolk → RDF

by Toby Inkster

This article describes a method for converting an xFolk object into RDF triples and suggests ways of using RDFa or eRDF to extend xFolk, adding additional information about the xFolk object, and about the article that has been linked to.

Digg is an example of the type of site that could make use of xFolk, but in April 2008 they instead implemented support for RDFa. Their choice of RDF for representing tagged links is used as the basis for this article.

The Triples

The Subject

RDF represents all information in the form of "triples". The first part of a triple is the subject - a URI for the thing being described. Although at first the obvious choice for the subject might be the URI of the tagged link (and this is how I initially implemented xFolk→RDF), Digg instead uses its own page as the subject. So for our triple, the subject will be the URI of the xFolk object itself. The URI can be determined like this:

  1. If the tag with class="xfolkentry" is a <body> element, then the subject URI is the URI of the page being parsed.
  2. Otherwise, if the tag with class="xfolkentry" has an id attribute, then the subject URI is the page URI followed by a hash symbol (#) followed by the contents of the id attribute.
  3. Lastly, if none of the above applies, then there is no subject URI, so a BNode is created.

The Predicates

The following predicates are used:

(Editor's note: I've not 100% decided the best way of representing tags. Will get there soon though.)

The Objects

The object of dcterms:source is a resource with the URI found in the href attribute of the element with class="taggedlink".

The object of dcterms:title is a string literal consisting of the contents of the element with class="taggedlink".

The object of dcterms:abstract is a string literal consisting of the contents of the element with class="description".

An Example

The following example xFolk entry is included in the xFolk specification (ID attribute added for the purposes of illustration):

 <div class="xfolkentry" id="rtags">
   <div>
     <a class="taggedlink" href="http://www.sifry.com/alerts/archives/000306.html"> 
       Sifry's Alerts: Technorati launches Related Tags
     </a> 
   </div>
   <div class="description">
     Ever wanted to see what posts are related to other posts, what tags 
     are related to others? Now you can! Just check under the Tag 
     description on most tag pages, like this one, or this one, and you'll
     see the patterns. Can you smell the emergence?
   </div>
   <div class="meta">
     to
     <a rel="tag" href="/fpgibson/folksonomy">folksonomy</a>
     <a rel="tag" href="/fpgibson/technorati">technorati</a>
     ... <a class="delNav" href="/url/cbcabf7de070fdb46598ee679367be49">
     and 1 other person
     </a>
     ... on 2005-04-09
   </div>
 </div>

The above could generate the following RDF/XML:

 <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:dc="http://purl.org/dc/terms/">
   <rdf:Description rdf:about="http://example.org/#rtags">
     <dc:source rdf:resource="http://www.sifry.com/alerts/archives/000306.html" />
     <dc:title>Sifry's Alerts: Technorati launches Related Tags</dc:title>
     <dc:abstract>
       Ever wanted to see what posts are related to other posts, what tags 
       are related to others? Now you can! Just check under the Tag 
       description on most tag pages, like this one, or this one, and you'll
       see the patterns. Can you smell the emergence?
     </dc:abstract>
   </rdf:Description>
 </rdf:RDF>

Extending xFolk with RDFa

Because the xFolk entry and the link each have a URI, they can be used as subjects in RDFa:

 <dl>
   <dt>Page by</dt>
   <dd about="http://www.sifry.com/alerts/archives/000306.html"
       property="dc:creator">Sifry</dd>
   <dt>Page published on</dt>
   <dd about="http://www.sifry.com/alerts/archives/000306.html"
       property="dc:date">2005-04-09</dd>
   <dt>Link submitted by</dt>
   <dd about="#rtags" property="dc:creator">Alice Jones</dd>
   <dt>Link submitted on</dt>
   <dd about="#rtags" property="dc:date">2005-04-11</dd>
 </dl>

Added to the earlier HTML example, this ends up as:

 <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:dc="http://purl.org/dc/terms/">
   <rdf:Description rdf:about="http://example.org/#rtags">
     <dc:source>
       <rdf:Description rdf:about="http://www.sifry.com/alerts/archives/000306.html">
         <dc:creator>Sifry</dc:creator>
         <dc:date>2005-04-09</dc:date>
       </rdf:Description>
     </dc:source>
     <dc:title>Sifry's Alerts: Technorati launches Related Tags</dc:title>
     <dc:abstract>
       Ever wanted to see what posts are related to other posts, what tags 
       are related to others? Now you can! Just check under the Tag 
       description on most tag pages, like this one, or this one, and you'll
       see the patterns. Can you smell the emergence?
     </dc:abstract>
     <dc:creator>Alice Jones</dc:creator>
     <dc:date>2005-04-11</dc:date>
   </rdf:Description>
 </rdf:RDF>

Extending xFolk with eRDF

eRDF can be used instead of RDFa, however due to limitations of eRDF syntax, it can only be used to specify additional metadata about the xFolk entry, and not the tagged link.

Related Pages

xFolk

Microformats to RDF

See also: