Category Archives: FOAF Explorer

http://xml.mfd-consult.dk/foaf/explorer/

WordPress Plugin: Semantic Visits

When I came back from Madrid, after the Image Decription workshop, a few days in the city, and a hefty party in Getafe, I realised I could add another country to my list of visits.

The nice folks at World66 have created a nice interface for generating an image with visited countries highlighted, but while it would be easy to check a few boxes and copy the code to somewhere on my blog pages, that wouldn’t make it possible for the semantic web to figure out where I’ve been. For that reason, I decided to mint a set of vocabulary terms for visits according to Norm Walsh’s country counting rules, collected in the visit vocabulary, and have WordPress output the information in my FOAF profile – thanks to the extensibility of my FOAF Output Plugin. Of course, the FOAF Explorer now also understands these terms, displaying maps of the world, Canada and USA when appropriate — see for yourself!

Thus, here is a new plugin, the Semantic Visits Plugin (view source).

The current version is 1.1.

Changes since 1.0:
  • Added visits to Canadian regions.
  • Fixed “wrong” code/name/etc. properties.
  • The URIs for US states are now correct, pointing at the http://www.daml.ri.cmu.edu/ont/USRegionState.daml ontology containing state definitions instead of http://www.daml.ri.cmu.edu/ont/State.daml which only contains classes and properties.

Continue reading WordPress Plugin: Semantic Visits

FOAF Explorer update

It has bothered me for a while, that the FOAF Explorer wasn’t able to handle duplicate statements. It would either repeat the entire property/value pair, or in some situations “just” show the values next to each other without whitespace or other separators in between.

That last issue really isn’t fixed yet, but at least it now only happens with different values – I managed to remove duplicate statements with some crude PHP hacking.

I was already doing a parse and custom (re-)serialise with Redland/Raptor (the PHP source is available) before passing it on to the XSLT, so it was “just” a matter of making sure the same statement wasn’t serialised twice.

Since part of the point of reserialising was to group statements by subject, I had an index in the form of an array of statements per subject. Even though it can be optimized, I simply added a loop to check for the presence of the current predicate/object pair:

$found=0; 
  $os=librdf_node_to_string($object); 
  reset($Nodes[$node]); 
  while(!$found && list(,$pso)=each($Nodes[$node])) { 
    $p=key($pso); 
    list($s,$o)=current($pso); 
    $found=($p==$predicate && librdf_node_to_string($o)==$os); 
  }

It works (try it!), and while the entire FE processing should now take longer, it actually helps somewhat that the XSLT doesn’t have to cope with too much…

While I was at it, I added support for the use of XFN as an RDF vocabulary, with the namespace http://gmpg.org/xfn/1#. It is now treated the same way as the Relationship vocabulary and the Trust vocabulary, which means that it’s handled as if all the properties are rdfs:subPropertyOf foaf:knows. It’s not perfect, the display could use some collapsing, but it works (try it!).

Oh, almost forgot: Also added support for the Quaffing vocabulary by Leigh Dodds.

If only FE really knew about rdfs:subPropertyOf