Revision as of 01:42, 1 November 2007 by Admin (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

UsingFoafKnows

Using foaf:knows to relate people together

The "friend of a friend" aspect of FOAF arises from the ability to say that one Person "knows" another Person. "knows" is used in a deliberately vague sense here that includes "is friends with", "corresponds with", etc. Additional elaborations on the basic FOAF data can further clarify these relationships.

<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:Person>
  <foaf:name>Leigh Dodds</foaf:name>
  <foaf:firstName>Leigh</foaf:firstName>
  <foaf:surname>Dodds</foaf:surname>
  <foaf:mbox_sha1sum>71b88e951cb5f07518d69e5bb49a45100fbc3ca5</foaf:mbox_sha1sum>
  <foaf:knows>
    <foaf:Person>
      <foaf:name>Dan Brickley</foaf:name>
      <foaf:mbox_sha1sum>241021fb0e6289f92815fc210f9e9137262c252e</foaf:mbox_sha1sum>
      <rdfs:seeAlso 
        rdf:resource="http://rdfweb.org/people/danbri/foaf.rdf"/>
    </foaf:Person>
  </foaf:knows>
</foaf:Person>
</rdf:RDF>
<-- 
-->

Which says "there is a person called Leigh Dodds with a mailbox whose hashed value is..., who knows a person called Dan Brickley whose mailbox is..., and that Dan Brickley is further described in foaf.rdf"

Cross Referencing

The foaf:knows relationship can also be stated by cross-referencing within the file. The following is equivalent to the above example:

<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:Person>
  <foaf:name>Leigh Dodds</foaf:name>
  <foaf:firstName>Leigh</foaf:firstName>
  <foaf:surname>Dodds</foaf:surname>
  <foaf:mbox_sha1sum>71b88e951cb5f07518d69e5bb49a45100fbc3ca5</foaf:mbox_sha1sum>
  <foaf:knows rdf:resource="#dan">
</foaf:Person>

<foaf:Person rdf:ID="dan">
  <foaf:name>Dan Brickley</foaf:name>
  <foaf:mbox_sha1sum>241021fb0e6289f92815fc210f9e9137262c252e</foaf:mbox_sha1sum>
  <rdfs:seeAlso 
        rdf:resource="http://rdfweb.org/people/danbri/foaf.rdf"/>
</foaf:Person>
</rdf:RDF>

It should be clear from the above example that a single FOAF document can describe multiple people. There's no concept of a "primary" person in the document upon which all properties or relationships are based.


CategoryTutorial