Simple, XSLT friendly RDF/XML
esw.w3.org/topic/SimpleRdfXml
SimpleRdfXml
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
MortenF's blog entry about XSLT and RDF many examples there (thx to beobal from #swig)
Kanzaki's XSLT RSS finest white magic!
Example
This is a fragment of FOAF, using the simpleRDF/XML
foaf-example: <rdf:RDF xmlns:foaf="http://xmlns.com/foaf/0.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:vs="http://www.w3.org/2003/06/sw-vocab-status/ns#" xmlns:wot="http://xmlns.com/wot/0.1/" xmlns:dc="http://purl.org/dc/elements/1.1/" > <rdf:Description rdf:about="http://xmlns.com/foaf/0.1/firstName"> <rdf:type rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#Property"/> <vs:term_status>testing</vs:term_status> <rdfs:label>firstName</rdfs:label> <rdfs:comment>The first name of a person.</rdfs:comment> <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/> <rdfs:domain rdf:resource="http://xmlns.com/foaf/0.1/Person"/> <rdfs:range rdf:resource="http://www.w3.org/2000/01/rdf-schema#Literal"/> <rdfs:isDefinedBy rdf:resource="http://xmlns.com/foaf/0.1/"/> </rdf:Description> </rdf:RDF>
Design Rules of SimpleRdfXml
be compatible with RDF/XML
but only a subset
restrict stuff to simplicity
Rules
no nested stuff
all literals as <foaf:name>Hello!</foaf:name> and not attributes like <blub foaf:name="Hello!">
no blank nodes (replace them wirth random uris while serializing)
serious: no blank nodes. They force you to check all the time for different ways to lookup resources.
only full uris, no relative ones
type always as triple, not in xml
Implementations
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.
Full URIS
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="http://xmlns.com/foaf/0.1/Person"/>
When things have two types, this comes in handy. Again, a step for making it simpler.
Contra-Example
This RDF is BAD RDF and is not simple, it breaks the rules: nono:
<foaf:Person rdfs:label="blub"> <rdfs:commment>asdafsd</rrr> <rdf:hasblub > <rdf:descrip....
SimpleRdfXml (zuletzt geändert am 2006-04-24 18:16:00 durch LeoS)
leobard - 25. Apr, 12:40
|
Trackback URL:
https://leobard.twoday.net/stories/1872447/modTrackback