Simple, XSLT friendly RDF/XML

We need a simple RDF/XML serialization for XSLT transformations. I wrote my ideas about this here:


Using the general RDF/XML spec, the RDF serialization can look quite different depending on rdf-writer implementation. These diversity in writing RDF makes writing XSLT transformation a black art. What happens is that the data shows up in so many different ways, that many people write big hacks to get it work.

Solution: a simple RDF/XML syntax that is RDF/XML compatible but has some restrictions to it. It is kind-of deterministic and can be better parsed in XSLT. I [LeoS] call it SimpleRdfXml.

See Also


This is a fragment of FOAF, using the simpleRDF/XML


    xmlns:dc="" >
  <rdf:Description rdf:about="">
    <rdf:type rdf:resource=""/>

    <rdfs:comment>The first name of a person.</rdfs:comment>
    <rdf:type rdf:resource=""/>

    <rdfs:domain rdf:resource=""/>
    <rdfs:range rdf:resource=""/>
    <rdfs:isDefinedBy rdf:resource=""/>

Design Rules of SimpleRdfXml

  1. be compatible with RDF/XML

  2. but only a subset

  3. restrict stuff to simplicity


  1. no nested stuff

  2. all literals as <foaf:name>Hello!</foaf:name> and not attributes like <blub foaf:name="Hello!">

  3. no blank nodes (replace them wirth random uris while serializing)

  4. serious: no blank nodes. They force you to check all the time for different ways to lookup resources.

  5. only full uris, no relative ones

  6. type always as triple, not in xml


Using Jena, the easiest way to get it is:

simple rdf:
Model m = ...;
m.write(System.out, "RDF/XML");

bad rdf:
m.write(System.out, "RDF/XML-ABBREV");

more detail

No nested stuff

All literals as elements, not attributes

Querying from XSLT is easy with both, but having to check both all the time sucks. Most hackers go with the element solution, as it can contain datatypes and languages and can have better strings with CDATA elements.

No blank nodes

Thats hard to achieve. The idea behind is to easily query other nodes and follow links, when blank nodes are in game, this is harder.


In foaf-vocab, there is a uri called “../sig” which is the show-stopper. don’t do it

Type always as triple

Wrong: <foaf:Person rdf:about="urn:example"> Right:

<rdf:Description rdf:about="urn:example"> 

  <rdf:type rdf:resource=""/>

When things have two types, this comes in handy. Again, a step for making it simpler.


This RDF is BAD RDF and is not simple, it breaks the rules: nono:

<foaf:Person rdfs:label="blub">
  <rdf:hasblub >


SimpleRdfXml (zuletzt geändert am 2006-04-24 18:16:00 durch LeoS)