My RDF Style

I've realised that I'm unconciously using a subset of the RDF/XML serialization syntax. My mind must have read the spec, absorbed shedloads of RDF over the years and filtered out all the bits that aren't immediately useful. Now that we're all fired up about the syntax issues it might be prudent to write them down. So here are my informal style rules for writing RDF/XML:

  • Do use typed nodes (rss:channel, foaf:Person) - makes the RDF so much more readable.
  • Do use anonymous nodes - assigning a URI is making a long term commitment.
  • Do use xml:lang - we're using XML for a reason
  • Do use rdf:about instead of rdf:ID - keeps the notation simpler.
  • Do use rdfs:seeAlso, but give some other properties too - let people know where to find out more, but give them something now.
  • Don't write properties as attributes unless you're hiding RDF in XHTML - it's inconsistent.
  • Don't use collections - their semantics have been removed away anyway
  • Don't use rdf:parseType - it's for squeezing random stuff into RDF
  • Don't use rdf:datatype - maybe can you use a resource instead of a literal?

Using these rule would lead me to write the example from the RDF spec as the following. Note I've introduced another vocabulary to remove those rdf:Descriptions.

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:dc="http://purl.org/dc/elements/1.1/"
         xmlns:ex="http://www.example.com/terms/"
         xmlns:foaf="http://xmlns.com/foaf/0.1/">

  <foaf:Document rdf:about="http://www.w3.org/TR/rdf-syntax-grammar">
    <dc:title>RDF/XML Syntax Specification (Revised)</dc:title>
    <ex:editor>
      <foaf:Person>
        <ex:fullName>Dave Beckett</ex:fullName>
        <ex:homePage rdf:resource="http://purl.org/net/dajobe/" />
      </foaf:Person>
    </ex:editor>
  </foaf:Document>
</rdf:RDF>

Permalink: http://blog.iandavis.com/2003/05/my-rdf-style/

Other posts tagged as rdf

Earlier Posts