Google+

The Sixteen Faces of Eve

14

28 September 2005 by Ian Davis

My goal in this posting, prompted by some email discussions on constrained profiles of RDF/XML, is to take three simple triples and see how many ways there were of serialising them as RDF/XML. I chose not to consider order of the elements to be significant – I may be mean but I’m not without a heart.

The triples I chose were trivial. In prose they are: “there is something that is a person, with a name of Eve and a homepage of http://example.org/~eve“. In Turtle/NTriples/N3:

_:eve rdf:type foaf:Person .
_:eve foaf:name "Eve" .
_:eve foaf:homepage <http://example.org/~eve>.

When I started this posting I thought I could squeeze out seven RDF/XML serializations of the same three triples, so I had a clever name for the post all worked out. When I actually came to serialize the triples I came up with sixteen variations! It rather spoilt the joke but it sort of hammers home the point I’m trying to make.

Here’s a challenge for a talented XPather: write an XPath that selects the homepage of the person with name “Eve”. It must work with all sixteen of these serialisations.

Remember, all of these XML documents parse to the same three triples above. My maths is too rusty to work out how many serialisations there are of 4, 5, 6 or more triples let alone the few hundred that comprise my FOAF file.

Face 1:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
         xmlns:foaf="http://xmlns.com/foaf/0.1/">
  <foaf:Person>
    <foaf:name>Eve</foaf:name>
    <foaf:homepage rdf:resource="http://example.org/~eve"/>
  </foaf:Person>
</rdf:RDF>

Face 2:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
         xmlns:foaf="http://xmlns.com/foaf/0.1/">
  <rdf:Description>
    <rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Person" />
    <foaf:name>Eve</foaf:name>
    <foaf:homepage rdf:resource="http://example.org/~eve"/>
  </rdf:Description>
</rdf:RDF>

Face 3:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
         xmlns:foaf="http://xmlns.com/foaf/0.1/">
  <foaf:Person foaf:name="Eve">
    <foaf:homepage rdf:resource="http://example.org/~eve"/>
  </foaf:Person>
</rdf:RDF>

Face 4:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
         xmlns:foaf="http://xmlns.com/foaf/0.1/">
  <rdf:Description foaf:name="Eve">
    <rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Person" />
    <foaf:homepage rdf:resource="http://example.org/~eve"/>
  </rdf:Description>
</rdf:RDF>

Face 5:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
         xmlns:foaf="http://xmlns.com/foaf/0.1/">
  <foaf:Person rdf:nodeID="eve">
    <foaf:name>Eve</foaf:name>
  </foaf:Person>
  <rdf:Description rdf:nodeID="eve">
    <foaf:homepage rdf:resource="http://example.org/~eve"/>
  </rdf:Description>
</rdf:RDF>

Face 6:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
         xmlns:foaf="http://xmlns.com/foaf/0.1/">
  <foaf:Person rdf:nodeID="eve" foaf:name="Eve" />
  <rdf:Description rdf:nodeID="eve">
    <foaf:homepage rdf:resource="http://example.org/~eve"/>
  </rdf:Description>
</rdf:RDF>

Face 7:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
         xmlns:foaf="http://xmlns.com/foaf/0.1/">
  <rdf:Description rdf:nodeID="eve">
    <rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Person" />
    <foaf:name>Eve</foaf:name>
  </rdf:Description>
  <rdf:Description rdf:nodeID="eve">
    <foaf:homepage rdf:resource="http://example.org/~eve"/>
  </rdf:Description>
</rdf:RDF>

Face 8:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
         xmlns:foaf="http://xmlns.com/foaf/0.1/">
  <rdf:Description rdf:nodeID="eve" foaf:name="Eve">
    <rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Person" />
  </rdf:Description>
  <rdf:Description rdf:nodeID="eve">
    <foaf:homepage rdf:resource="http://example.org/~eve"/>
  </rdf:Description>
</rdf:RDF>

Face 9:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
         xmlns:foaf="http://xmlns.com/foaf/0.1/">
  <rdf:Description rdf:nodeID="eve">
    <foaf:name>Eve</foaf:name>
  </rdf:Description>
  <foaf:Person rdf:nodeID="eve">
    <foaf:homepage rdf:resource="http://example.org/~eve"/>
  </foaf:Person>
</rdf:RDF>

Face 10:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
         xmlns:foaf="http://xmlns.com/foaf/0.1/">
  <rdf:Description rdf:nodeID="eve">
    <foaf:name>Eve</foaf:name>
  </rdf:Description>
  <foaf:Person rdf:nodeID="eve">
    <foaf:homepage rdf:resource="http://example.org/~eve"/>
  </foaf:Person>
</rdf:RDF>

Face 11:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
         xmlns:foaf="http://xmlns.com/foaf/0.1/">
  <rdf:Description rdf:nodeID="eve">
    <foaf:name>Eve</foaf:name>
  </rdf:Description>
  <rdf:Description rdf:nodeID="eve">
    <rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Person" />
    <foaf:homepage rdf:resource="http://example.org/~eve"/>
  </rdf:Description>
</rdf:RDF>

Face 12:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
         xmlns:foaf="http://xmlns.com/foaf/0.1/">
  <rdf:Description rdf:nodeID="eve" foaf:name="Eve" />
  <rdf:Description rdf:nodeID="eve">
    <rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Person" />
    <foaf:homepage rdf:resource="http://example.org/~eve"/>
  </rdf:Description>
</rdf:RDF>

Face 13:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
         xmlns:foaf="http://xmlns.com/foaf/0.1/">
  <rdf:Description rdf:nodeID="eve">
    <rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Person" />
  </rdf:Description>
  <rdf:Description rdf:nodeID="eve">
    <foaf:name>Eve</foaf:name>
    <foaf:homepage rdf:resource="http://example.org/~eve"/>
  </rdf:Description>
</rdf:RDF>

Face 14:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
         xmlns:foaf="http://xmlns.com/foaf/0.1/">
  <rdf:Description rdf:nodeID="eve">
    <rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Person" />
  </rdf:Description>
  <rdf:Description rdf:nodeID="eve" foaf:name="Eve">
    <foaf:homepage rdf:resource="http://example.org/~eve"/>
  </rdf:Description>
</rdf:RDF>

Face 15:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
         xmlns:foaf="http://xmlns.com/foaf/0.1/">
  <rdf:Description rdf:nodeID="eve">
    <foaf:name>Eve</foaf:name>
  </rdf:Description>
  <rdf:Description rdf:nodeID="eve">
    <foaf:homepage rdf:resource="http://example.org/~eve"/>
  </rdf:Description>
  <rdf:Description rdf:nodeID="eve">
    <rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Person" />
  </rdf:Description>
</rdf:RDF>

Face 16:

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
         xmlns:foaf="http://xmlns.com/foaf/0.1/">
  <rdf:Description rdf:nodeID="eve" foaf:name="Eve" />
  <rdf:Description rdf:nodeID="eve">
    <foaf:homepage rdf:resource="http://example.org/~eve"/>
  </rdf:Description>
  <rdf:Description rdf:nodeID="eve">
    <rdf:type rdf:resource="http://xmlns.com/foaf/0.1/Person" />
  </rdf:Description>
</rdf:RDF>
«

14 thoughts on “The Sixteen Faces of Eve

  1. Benjamin Nowack says:

    Heh, and couldn’t you write face 1-4 with namespaces declared in the inner tag and then drop the outer rdf:RDF?

  2. iand says:

    That’s just cruel.

  3. Jimmy Cerra says:

    So what? There are several representations in Turtle for that graph as well (besides the one you indicated). Just because you can dig a trench with a spoon doesn’t mean it is a good idea (unless you are escaping from a prision).

  4. iand says:

    Sure, but serializing as XML sort of suggests that you can use XML tools to process it. I’ve said before that it was a mistake ever to endorse an XML serialization of RDF, we should have had Turtle years ago.

  5. Damian says:

    You missed another variation: rdf:type can be an attribute. I think that doubles Eve’s faces.

  6. iand says:

    I don’t think so, attributes can only take literal values.

  7. Jimmy Cerra says:

    I don’t see much wrong with the general ideas behind RDF/XML except that it is the only official format (although there are lots of flaws with the details). The idea behind RDF/XML is not that you use XML tools to read RDF, but that you use RDF tools to read XML. I.E. You mark up an existing XML document with RDF/XML attributes indicating its semantic structure (as opposed to the logical structure).

  8. Jimmy Cerra says:

    P.S. Re: 6. rdf:type is an exception for that rule, in that it is allowed as an attribute but still points to a URIRef and not a plain literal.

  9. iand says:

    Hey I never knew that you could use rdf:type as an attribute in that way, but it’s legal. That’s another 10 variations on top of the 4 suggested by Ben. So, we’re up to 32 different ways to write 3 triples in RDF/XML :)

  10. Ontogon says:

    RDF/XML Sucks x 16 32Caution. Rant ahead… I’ve always thought that the XML serialization of RDF is pretty much garbage. Sorry, had to say…

  11. Howard Katz says:

    I’ll take you up on your XPath challenge. I think (he says hopefully) that the following should work://*[ ( .//foaf:name | .//@foaf:name ) = "Eve" ]//foaf:homepage/@rdf:resourceThis assumes that the top-level context is a single document containing all 16 variations.

  12. iand says:

    Good try Howard. I read that XPath as:Select the rdf:resource attribute of the foaf:homepage element that is a descendant of an element which has either a foaf:name child element or a foaf:name attribute with the value of “Eve”I don’t think that covers the faces where there foaf:name and foaf:homepage are children of different elements e.g. face 5

  13. Howard Katz says:

    What I’ve got *should* work for the case where foaf:name or @foaf:name and foaf:homepage are descendants (not necessarily direct children) of different elements. The key is lots of “//” descendant specifiers to indicate that *somewhere* back up the hierarchy there’s a common element for both end points (name and homepage). When I have some time later on I’ll try this on face 5 just to make sure …

  14. Bill de hOra says:

    Respectfully; asking what’s the XPath is the wrong question. It’s dealing with symptoms.Jimmy: the “So what” is that RDF/XML is like a box of chocolates; you never know what you’re gonna get.I know of no systems that are end to end model driven; you always have to deal with serializations, mappings, validation, form filling, presentation. The XML syntax sufficiently screws up the economic proposition of RDF that it makes sense to look at alternatives – a case of snatching defeat from the jaws of victory. It’s a nutso situation.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 1,721 other followers

%d bloggers like this: