The Sixteen Faces of Eve
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.
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>
<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>