R3: Reasonably Readable RDF (draft)

[Read my earlier post to understand why I object to RDF/XML, and the need for this replacement.]

R3 is an RDF dialect that is intended to be an isomorphic replacement for the RDF/XML dialect. In addition to the base syntax, R3 may be extended to allow inferences and relationships to be drawn on the basis of class (an alternative to the W3C Web Ontology Language (OWL)).

While a RELAX NG schema is planned, at present the language is primarily defined through a series of examples:

Example 1

<rdf xmlns="http://www.guruj.net/2007/01/19-r3-syntax#"
     xmlns:meta="http://www.guruj.net/r3/meta#"
     xmlns:x="http://www.guruj.net/r3/traits#"
     xmlns:entity="http://www.example.com/objects#">

<node ref="entity:Muffin">
  <has property="meta:label">Muffin, a cat</has>
  <has property="x:eats" value="mice" />
</node>

</rdf>

[R3 definition of a cat.]

To create an RDF "graph", use the "target" attribute to indicate that the predicate points to a node rather than a literal value:

Example 2

<rdf xmlns="http://www.guruj.net/2007/01/19-r3-syntax#"
     xmlns:meta="http://www.guruj.net/r3/meta#"
     xmlns:x="http://www.guruj.net/r3/traits#"
     xmlns:entity="http://www.example.com/objects#">

<node ref="entity:John+Smith">
  <has property="meta:label">John Smith</has>
  <has property="x:gender" value="male" />
  <has property="x:owns" target="entity:Muffin" />
</node>

<node ref="entity:Muffin">
  <has property="meta:label">Muffin, a cat</has>
  <has property="x:eats" value="mice" />
</node>

</rdf>

[R3 definition of John, a male who owns a cat.]

Example 3 demonstrates the use of the <bag /> and <is /> tags. Bag is like <has />, but allows the easy assignment of a predicate to multiple objects. instead of <bag/>, you can use <alternative /> to specify "one of these" rather than "all". <sequence /> works identically to <bag /> but specifies that the order of listed properties is semantically significant.

Example 3 

<rdf xmlns="http://www.guruj.net/2007/01/19-r3-syntax#"
     xmlns:meta="http://www.guruj.net/r3/meta#"
     xmlns:x="http://www.guruj.net/r3/traits#"
     xmlns:entity="http://www.example.com/objects#">

<node ref="entity:Frieda+Daly">
  <has property="meta:label">Frieda Daly</has>
  <has property="x:gender" value="female" />
  <bag property="x:owns">
    <is target="entity:Snuggles" />
    <is target="entity:Kensington" />
  </bag>
</node>

<node ref="entity:Snuggles">
  <has property="meta:label">Snuggles, a cat</has>
  <has property="x:eats" value="mice" />
</node>

<node ref="entity:Kensington">
  <has property="meta:label">Kensington, a cat</has>
  <has property="x:eats" value="fish" />
</node>

</rdf>

[R3 definition of Frieda, a female who owns two cats.]

So why consider R3 instead of standard RDF/XML? I would cite three main advantages:

  • The nature of the RDF graph is clear from the XML structure. Predicates are explicitly identified as such by the <has /> and <bag /> tags, while <is /> provides a semantic wrapper around subject objects and allows easy specification of literals.
  • Easy and intuitive conversion of XML into English. The words "has", "property" and "is" all help associate concepts: "Frieda Daly has gender female"; "Frieda Daly has the property that she owns Snuggles and Kensington" or simply "Frieda Daly owns Snuggles and Kensington".
  • Namespaces help delineate meaning. By using namespaces within property names and values, the type of data being supplied or referred to is clearer. For example, "entity:Snuggles" is clearly a thing, while "meta:label" is information about that thing. With predicates, the namespace "x" is recommended for predicates, since it mentally associates the concept of "this object". Users can see the statement "x:eats = fish" and then look in the parent XML to determine that "entity:Kensington" should replace "x".

[An introduction to classes in R3 is now also available.]