FOAF Explorer

Created 17 years ago by Matt,
Last updated August 5th 2024, 3:50:07 pm

I've been mucking around with some FOAF stuff recently, and spent some time making a FOAF exploring application.

This is very basic and does not work completely, but it is quite interesting.

It uses the Joseki project to perform SPARQL queries on remote RDF files (i.e. It does pretty much the same as Construct does, but supports a FROM clause, in which you can specify a remote resource).

The project is currently on my server. But requires that I have the Joseki server running, so may not work.

Using the following SPARQL query, it is possible to get some data out about a person. However, there is a flaw which I have not solved: How to get only that information about the top level person! As at the moment, I am using the rdf:ID="#me" part of a FOAF profile to get the data, but this is not a defined standard, so somehow it needs a more general way of finding it.

PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns> SELECT ?name ?nick ?title ?homepage ?mbox ?mbox_sha1sum ?img ?depiction ?surname ?family_name ?givenname ?firstName ?gender ?img ?workplaceHomepage ?workInfoHomepage ?schoolHomepage FROM <http://mattstabeler.co.uk/foaf.rdf> WHERE { OPTIONAL { <http://mattstabeler.co.uk/foaf.rdf#me> foaf:name ?name. ?y foaf:name ?name. } OPTIONAL { ?x foaf:nick ?nick . } OPTIONAL { ?x foaf:title ?title . } OPTIONAL { ?x foaf:homepage ?homepage . } OPTIONAL { ?x foaf:mbox ?mbox . } OPTIONAL { ?x foaf:mbox_sha1sum ?mbox_sha1sum . } OPTIONAL { ?x foaf:img ?img . } OPTIONAL { ?x foaf:depiction ?depiction . } OPTIONAL { ?x foaf:surname ?surname . } OPTIONAL { ?x foaf:family_name ?family_name . } OPTIONAL { ?x foaf:givenname ?givenname . } OPTIONAL { ?x foaf:firstName ?firstName . } OPTIONAL { ?x foaf:gender ?gender . } OPTIONAL { ?x foaf:workplaceHomepage ?workplaceHomepage . } OPTIONAL { ?x foaf:workInfoHomepage ?workInfoHomepage . } OPTIONAL { ?x foaf:schoolHomepage ?schoolHomepage . } }

If anyone is interested in the code, its a bit ropey, but I will be happy to send it on.

Other useful SPARQL queries:

Find who the Person knows PREFIX foaf: <http://xmlns.com/foaf/0.1/&gt; PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#&gt; SELECT ?name ?seeAlso ?mbox_sha1sum FROM <http://mattstabeler.co.uk/foaf.rdf&gt; WHERE { ?x foaf:name ?name . OPTIONAL { ?x rdfs:seeAlso ?seeAlso . } }

Find out a Person's OnlineAccounts PREFIX foaf: <http://xmlns.com/foaf/0.1/&gt; SELECT ?accountName ?accountProfilePage ?accountServiceHomepage FROM <http://mattstabeler.co.uk/foaf.rdf#me&gt; WHERE { OPTIONAL{?x foaf:accountName ?accountName .} OPTIONAL{?x foaf:accountServiceHomepage ?accountServiceHomepage .} OPTIONAL{?x foaf:accountProfilePage ?accountProfilePage . } }