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