The Minimal FOAF Document
This page describes the simplest possible, but arguably still useful FOAF document.
Here's the basic document skeleton for a FOAF document. Showing the root element of the RDF document and the relevant namespace declarations:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:foaf="http://xmlns.com/foaf/0.1/"> <!-- FOAF data goes here --> </rdf:RDF>
Things to note:
- FOAF documents are RDF documents, and are therefore wrapped in the rdf:RDF element
- The FOAF namespace is http://xmlns.com/foaf/0.1/
The remaining examples in this page will assume that the elements are wrapped in this skeleton document.
The Minimal Document
The most minimal FOAF document is the following:
Which says "there is a person". Obviously thats not very useful as it doesn't say anything about the person or even assign them a unique identifier.
A useful extension would be to include the persons name:
<foaf:Person> <foaf:name>Dan Brickley</foaf:name> </foaf:Person>
Which says "there is a person named Dan Brickley". (See NamingPeopleInFoaf for more information) This is marginally more useful, especially for human consumers of the data. However RDF is all about machine-processable descriptions of resources. RDF processors are much happier when there are unique identifiers for resources as it makes it easier to combine different peoples descriptions of that resource.
The Minimal Useful Document
Therefore our minimally useful FOAF document adds a unique identifier to our Person Resource. There are several ways to do this. The first involves adding the users email address like this:
<foaf:Person> <foaf:name>Dan Brickley</foaf:name> <foaf:mbox rdf:resource="mailto:email@example.com"/> </foaf:Person>
FOAF declares that an email address ("mbox") is a unique, unambiguous identifier for a Person. For more discussion on this see MboxAsUniqueIdentifier. A FOAF application can then determine that if two people make statements about a Resource with the identifier "mailto:firstname.lastname@example.org" then they're actually talking about the same thing.
It's perfectly legal to include multiple foaf:mbox elements within a foaf:Person. This basically says that there are multiple unique identifiers for this person (one for each foaf:mbox), giving FOAF processors more chance of amalgamating data about that resource (see also Smushing).
Many people aren't comfortable with advertising their email address on the web; spam being a major concern. FOAF therefore defines another unique identifier for a person: foaf:mbox_sha1sum. This is the SHA1 sum of the persons email. SHA1 sum is, for all practical applications, a way to generate a unique code from a text string. You can generate a SHA1 hash of your email address using either Bill Kearney's online Hash Generator (Link Broken) or Morten Frederikson's sha1ify.
Here's how to introduce it into your FOAF document:
<foaf:Person> <foaf:name>Dan Brickley</foaf:name> <foaf:mbox_sha1sum>748934f32135cfcf6f8c06e253c53442721e15e7</foaf:mbox_sha1sum> </foaf:Person>
Which says "there is a Person called Dan Brickley who has an email address whose sha1 hash is...".
FOAF processors can then go about Smushing people together using their foaf:mbox_sha1sum instead of their foaf:mbox.