To RDF or not?

Volume 14, Issue 7; 22 Feb 2011

Over the weekend, I set about to rip out the last of the RDF from this site. Then I changed my mind.

First, a little history. When I started this weblog, I did so in part to experiment with a number of technologies, including RDF. The system I built did use RDF and I was able to leverage benefits from it: combining data from several sources and using inference to generate some metadata that was used elsewhere.

But those benefits came at a substantial performance cost. Generating the pages involved an RDF shake-and-stir process that took several minutes to complete. That's not an indictment of RDF, or at least I don't mean it as one. I don't believe that it's impossible to make RDF run fast, I simply wasn't using a tool that was fast.

When I rewrote the weblog infrastructure to run on MarkLogic Server, I took all of that out. Combining data is straightforward in the server and the sorts of things for which I used inferred metadata, I could (more) easily do with XQuery.

The one place where RDF remained was in the where/what/who pages. The problem was that those pages had drifted out of sync with the actual sources for that data. This bites me often enough to need fixing.

For example, if I add an itinerary to my calendar, I make sure the airports involved are in my address book. I use that data to generate the itinerary markup for my travel pages. The server also needs the airport data so that the Google map can be drawn on the itinerary pages. That means adding the airport data separately to the server.

This weekend, I set out to replace all the RDF data with more recent plain-old-XML directly from, for example, my address book. There were a couple of problems with this approach. The first is that I use a sort of quasi-RDF model for my address book anyway. Here, for example, is a crude representation of the address book entry for Denver International Airport:

  Denver International Airport
   
work  +1-800-247-2336
   
work  info@flydenver.com
   
homepage  http://www.flydenver.com/
homepage  http://www.ourairports.com/airports/KDEN/
ID  DEN
   
work  8500 Peña Blvd
  Denver CO 80249-6340
   
Note:
rdf:
p:class airports
geo:lat 39.861698
geo:long -104.672997
rdf:type wn:Airport
p:weather http://weather.noaa.gov/weather/current/KDEN.html
tax:wikipedia Denver_International_Airport

So what this really boiled down to was a plan to replace RDF that looks like this:

<rdf:Description xmlns:pim="http://nwalsh.com/xmlns/pim"
                 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
                 xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
                 xmlns:tax="http://norman.walsh.name/knows/taxonomy#"
                 xmlns:up="http://nwalsh.com/rdf/upcoming.org#"
                 xmlns:c="http://nwalsh.com/rdf/contacts#"
                 xmlns:vcf="http://nwalsh.com/xmlns/apple.vcf"
                 xmlns:foaf="http://xmlns.com/foaf/0.1/"
                 xmlns:v="http://nwalsh.com/rdf/vCard#"
                 xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
                 xmlns:owl="http://www.w3.org/2002/07/owl#"
                 xmlns:p="http://nwalsh.com/rdf/pim#"
                 rdf:about="http://norman.walsh.name/knows/where/DEN">
   <rdf:type rdf:resource="http://nwalsh.com/rdf/contacts#Contact"/>
   <rdf:type rdf:resource="http://nwalsh.com/rdf/contacts#Place"/>
   <rdf:type rdf:resource="http://xmlns.com/wordnet/1.6/Airport"/>
   <c:associatedName>Denver International Airport</c:associatedName>
   <c:category>Airports</c:category>
   <p:class>airports</p:class>
   <c:workPhone rdf:resource="tel:+1-800-247-2336"/>
   <v:workAdr rdf:parseType="Resource">
      <rdf:type rdf:resource="http://nwalsh.com/rdf/vCard#Address"/>
      <v:street-address>8500 Peña Blvd</v:street-address>
      <v:locality>Denver</v:locality>
      <v:region>CO</v:region>
      <v:postal-code>80249-6340</v:postal-code>
      <v:country-name>US</v:country-name>
   </v:workAdr>
   <foaf:mbox_sha1sum>7e05c9a58c70b36472bb02396ef0b838da080762</foaf:mbox_sha1sum>
   <tax:wikipedia>Denver_International_Airport</tax:wikipedia>
   <foaf:homepage rdf:resource="http://www.flydenver.com/"/>
   <foaf:homepage rdf:resource="http://www.ourairports.com/airports/KDEN/"/>
   <p:weather rdf:resource="http://weather.noaa.gov/weather/current/KDEN.html"/>
   <geo:lat rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">39.861698</geo:lat>
   <geo:long rdf:datatype="http://www.w3.org/2001/XMLSchema#decimal">-104.672997</geo:long>
   <owl:sameAs rdf:resource="http://norman.walsh.name/knows/where#DEN"/>
</rdf:Description>

With plain-old-XML that looks like this:

<contact xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:tax="http://norman.walsh.name/knows/taxonomy#"
         xmlns:foaf="http://xmlns.com/foaf/0.1/"
         xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
         xmlns:vcf="http://nwalsh.com/xmlns/apple.vcf"
         xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
         xmlns:p="http://nwalsh.com/rdf/pim#"
         xmlns="http://nwalsh.com/xmlns/pim"
         xmlns:up="http://nwalsh.com/rdf/upcoming.org#"
         xml:id="DEN" company="1">
   <foaf:name>Denver International Airport</foaf:name>
   <company>Denver International Airport</company>
   <foaf:mbox_sha1sum>7e05c9a58c70b36472bb02396ef0b838da080762</foaf:mbox_sha1sum>
   <phone type="work">+1-800-247-2336</phone>
   <address type="work">
      <street>8500 Peña Blvd</street>
      <city>Denver</city>
      <state>CO</state>
      <postcode>80249-6340</postcode>
   </address>
   <note/>
   <p:class>airports</p:class>
   <geo:lat>39.861698</geo:lat>
   <geo:long>-104.672997</geo:long>
   <rdf:type rdf:resource="http://xmlns.com/wordnet/1.6/Airport"/>
   <p:weather rdf:resource="http://weather.noaa.gov/weather/current/KDEN.html"/>
   <tax:wikipedia>Denver_International_Airport</tax:wikipedia>
   <uri type="homepage">http://www.flydenver.com/</uri>
   <uri type="homepage">http://www.ourairports.com/airports/KDEN/</uri>
   <uid>9431C154-E779-4126-9102-DDE8E625B969</uid>
   <category>Airports</category>
   <category>Published</category>
</contact>

On the whole, not really that much of a change. But it would be slightly simpler if I could just poke my address book into the database.

Trouble is, a little grepping (or rather, acking) revealed that I use the RDF data in a few places. There's nothing that couldn't be changed to use the new markup instead, but that would mean changing and testing each place.

About twenty minutes into my hacking, I decided that the simplest thing to do would be to write some XSLT to generate the RDF from the XML and leave the RDF alone in the database. It took several hours to get the two sets of data aligned again [never, ever, let there be two different sources for the same data, you know this! -ed] but I managed to get there.

I swear this essay seemed like it was worth writing before I started. Now I'm not so sure. Oh, well, hardly the first time I've wasted ten minutes of someone's time. Sorry, though.

Comments

>Apology accepted. Just dont do it again, yes?

—Posted by Not a spammer on 23 Feb 2011 @ 09:16 UTC #

No promises. Caveat lector.

—Posted by Norman Walsh on 23 Feb 2011 @ 08:52 UTC #

Didn't know about ack. Now I do. Maybe it makes you feel a teeny bit better about posting.

—Posted by Marc on 26 Feb 2011 @ 12:46 UTC #

Definitely worth the time to read just to learn about ack - that other stuff is good too! :)

—Posted by William on 08 Mar 2011 @ 04:36 UTC #