Tuesday, 25. April 2006

Simple, XSLT friendly RDF/XML

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

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

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

  1. be compatible with RDF/XML

  2. but only a subset

  3. restrict stuff to simplicity

Rules

  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

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)

QR barcode by i-nigma.com/CreateBarcodes

Trackback URL:
https://leobard.twoday.net/stories/1872447/modTrackback

icon

semantic weltbild 2.0

Building the Semantic Web is easier together

and then...

foaf explorer
foaf

Geo Visitors Map
I am a hard bloggin' scientist. Read the Manifesto.
www.flickr.com
lebard's photos More of lebard's photos
Skype Me™!

Search

 

Users Status

You are not logged in.

I support

Wikipedia Affiliate Button

Archive

April 2006
Sun
Mon
Tue
Wed
Thu
Fri
Sat
 
 
 
 
 
 
 2 
 3 
 4 
 5 
 6 
 7 
 8 
 9 
10
11
12
13
15
16
17
18
19
20
21
23
24
26
29
30
 
 
 
 
 
 
 

Credits


austriaca
Chucknorrism
digitalcouch
gnowsis
Jesus
NeueHeimat
route planning
SemWeb
travel
zoot
Profil
Logout
Subscribe Weblog