14.4 FOAF: Friend-of-a-Friend

For use of RDF to become widespread, its growth must occur in two directions: through use in sophisticated commercial applications such as those detailed in the next chapter, and through small, friendly, easy-to-use, and open source applications such as FOAF ? Friend-of-a-Friend.

You can find out more about FOAF at the its main web site at http://rdfweb.org/foaf/. In addition, an FOAF Wiki is at http://rdfweb.org/rweb/wiki/wiki.pl?FoafVocab. The RDF Schema for FOAF is at http://xmlns.com/foaf/0.1/. A mailing list for interested persons can be found at http://rdfweb.org/pipermail/rdfweb-dev/.

FOAF is a way of providing affiliation and other social information about yourself; it's also a way of describing a network of friends and others we know for one reason or another, in such a way that automated processes such as web bots can find this information and incorporate it with other FOAF files. The data is combined in a social network literally based on one predicate: knows.

Consider the scenario: I know Dorothea and she knows Mark and he knows Ben and Ben knows Sam and Sam knows... and so on. If the old adage about there being only six degrees of separation between any two people in the world is true, it should take only six levels of knows to connect Dorothea to Mark to Ben and so on. Then, once the network is established, it's very easy to verify who a person knows and in what context, and you have what could become a web of knowledge, if not exactly a web of trust.

The FOAF namespace is http://xmlns.com/foaf/0.1/, and the classes are Organization, Project, Person, and Document. There is no special meaning attached to each of these classes, they're meant to be taken at face value. In other words, a document is a document, not a special type of document. Though the other classes are available, most FOAF files are based on Person, and that's what's most used.

There are several FOAF properties, many of which are rarely used, a few of which are even a joke (dnaChecksum comes instantly to mind). However, almost every FOAF files uses the following properties:


An Internet email address in a valid URI format


Person's surname


Person's nickname


First name of person


Given name of person


Person's home page URL


URL of a project home page


Person's title or honorific


Person's phone


Link to person's publications


A person the person knows

There are other properties, but if you examine several FOAF files for people you'll find that the ones just listed are the most commonly used. In fact, the best way to understand how to create an FOAF file for yourself is to look at the FOAF files for people you know. Another way is to create the beginnings of a FOAF file using the FOAF-A-Matic.

14.4.1 The FOAF-A-Matic

I derived the name for my Query-O-Matic tools described in Chapter 10 in some part from the FOAF-A-Matic name. However, unlike my tools, which query existing RDF/XML, the FOAF-A-Matic is used to generate the RDF/XML for a specific FOAF file.

Access the original FOAF-A-Matic at http://www.ldodds.com/foaf/foaf-a-matic.html. Work is underway for a new version of the FOAF-A-Matic at the following web site: http://www.ldodds.com/wordtin/Wiki.jsp?page=FOAFaMaticMark2.

The FOAF-A-Matic is a web form with several fields used to record information such as name, home page, email, workplace information, and so on. In addition, the form also allows you to specify people that you know, including their name and a page to see more about them. In the example, I added two people: Simon St.Laurent, the editor of this book, and Dorothea Salo, one of the tech editors. When the fields are filled in, clicking the FOAF Me! button generates the RDF/XML, as shown in Example 14-3. You can then copy this, save it to a file, and modify the values?changing or adding new properties and more friends, whatever.

Example 14-3. FOAF RDF/XML file generated by FOAF-A-Matic
<foaf:name>Shelley Powers</foaf:name>
<foaf:homepage rdf:resource="http://weblog.burningbird.net"/>
<foaf:workplaceHomepage rdf:resource="http://burningbird.net"/>
<foaf:workInfoHomepage rdf:resource="http://burningbird.net/about.htm"/>
<foaf:schoolHomepage rdf:resource="http://www.cwu.edu/"/>
    <foaf:name>Simon St.Laurent</foaf:name>
    <rdfs:seeAlso rdf:resource="http://www.simonstl.com/"/>
    <foaf:name>Dorothea Salo</foaf:name>
    <rdfs:seeAlso rdf:resource="http://www.yarinareth.net/caveatlector/"/>

Notice in the example that the property mbox_shalsum is used instead of mbox. That's because one of the options used to generate the file was the ability to encode the email address so that it can't easily be scraped on the Web by email spambots?annoying little critters.

Notice also in the example that rdfs:seeAlso is used to map to a person's URL of interest. FOAF is first and foremost RDF/XML, which means the data it describes can be combined with other related, valid RDF/XML.

Once the FOAF file is to your liking, you can link to it from your home page using the link tag, as so:

<link rel="meta" type="application/rdf+xml" href="my-foaf-file.xrdf" /> 

This enables FOAF autodiscovery, or automatic discovery of your FOAF file by web bots and other friendly critters. Speaking of friendly critters, what else can you do with your FOAF file?

14.4.2 FOAF Technologies

Any technology that can work with RDF/XML can work with FOAF data. You can query FOAF files to find out who knows whom, to build a page containing links to your friends' pages, and so on. However, in addition to using traditional RDF/XML technologies with the FOAF data, there are also some FOAF-specialized technologies.

Edd Dumbill, the editor of XML.com, created what is known as the FOAFBot. This automated process sits quietly in the background monitoring an IRC (Internet Relay Chat) channel until such time as a member of the channel poses a question to it. For instance, at the FOAFBot web site a recorded question and answer exchange between an IRC member and the FOAFBot is:

<edd> foafbot, edd's name
<foafbot> edd's name is 'Edd Dumbill', according to Dan Brickley,
    Anon35, Niel Bornstein, Jo Walsh, Dave Beckett, Edd Dumbill, 
    Matt Biddulph, Paul Ford

FOAFBot has access to a knowledge base consisting of data that's been gleaned from FOAF files on the Internet. You can read more about FOAFBot and download the Python source code at http://usefulinc.com/foaf/foafbot. (Note the source code is built on Dave Beckett's Redland framework, described in Chapter 11.)

In the FOAFBot page that opens, there's also a link to an article about how to digitally sign your FOAF file.

Another use of FOAF data is the codepiction project, which uses the foaf:depiction property to search for images in which two or more people are depicted together in the same photo. You can read more about the codepiction project at http://rdfweb.org/2002/01/photo/index.html and see a working prototype at http://swordfish.rdfweb.org/discovery/2001/08/codepict/.

Finally, there's been effort to extend the concept of FOAF to a corporate environment, including defining a new vocabulary more in line with corporate connectivity than personal connectivity. You can check out the work on this project, called FOAFCorp, at http://rdfweb.org/foaf/corp/intro.html.