Some people enjoy working with RDF, but others of us don't, especially at the markup level. I started using Friend-of-a-friend (FOAF), and while I like the functionality - great work! - I really detest the markup, and it just gets more annoying the more I work with it. Rather than spend my time working with tools I didn't quite like either or cursing the markup, I turned to another technology about which I have mixed feelings, XSLT.

The two spreadsheets below transform a subset of FOAF - features commonly associated with Persons - from RDF to XML and back again. This lets me work with a FOAF file in XML if I prefer, using common HTML-derived idioms. Then I can transform my FOAF back to RDF for distribution. I don't believe these stylesheets capture FOAF's full range of capabilities, especially as far as extensions, but they do seem quite capable of dealing with ordinary FOAF.

For a sample, compare this RDF to this XML rendition of the same information.

I originally had problems with creatively structured FOAF files, notably this one. Its use of <foaf:knows rdf:resource="#name" /> is a much tougher problem than containment. XSLT doesn't understand URI fragment identifiers, but in this case I just strip off the # and look for a matching rdf:ID attribute. These creative structures do not survive a round trip, however. Compare this original with this XML result and a re-constituted RDF file. (The occasional bursts of namespace declarations are the result of using xsl:copy-of for elements it doesn't have a rule for - I hope to improve on that soon.)

These stylesheets are not a formal project - they represent my own noodling, fixing something that bothered me. They should be considered in the public domain, modifiable and usable at whim. I do plan to update them as FOAF matures, and I'm happy to listen to feedback, but I see these as convenience rather than infrastructure.

The stylesheet templates are pretty much in the order given at I don't like that order much, but it was easier to be consistent than to hunt around. Also, I coerced firstname and lastname to givenName and familyName, but I'm having second thoughts about it. I think that's the only deliberate information loss here. Finally, XSLT processors all interpret "indent nicely" differently, so your XML may vary a bit in indentation. You can turn off indent="yes" on xsl:output if you prefer.

Simon St.Laurent, 27 June 2003.