Mapping Notation3 to XML: An Alternate XML RDF Syntax

I thought of this approach whilst writing a new article... I was
going to send it to www-archive, but maybe some people on
www-rdf-interest will get a kick out of it.


* All subjects become element names, all predicates become
attributes, and all objects become attribute values as literals.
* Map <> into [] and "" into '' for object/attribute values (the
latter mapping isn't totally necessary).
* QNames in attribute values are allowed, and the empty XML
prefix maps onto ":" as in N3.
* Anonymous nodes are given a special namespace; you can still
use "_" legally as the prefix.
* To repeat objects, put them in the same attribute value, as
space separated tokens.
* Blank bNodes must be given labels, wherever they occur (we
could change this).
* N3 lists (:x :y :z) basically just become sets of elements
within an element (like the daml:Collection parseType), although
clearly they must be labelled bNodes.

For example, the following Notation3:-

@prefix : <#> .
@prefix rdf: <> .

 :x :y :z .

[ _:q (_:r :s); :t ] .

:Sean :homepage <>;
   :name "Sean B. Palmer";

would become...

<n3:Document xmlns:n3="" xmlns="#"

<x y=":z"/>

<_:p _:q="_:myList :t"/>

<Sean homepage="[]"
   name="'Sean B. Palmer'"/>


Typed nodes would just be rdf:type attributes, although we could
put "a" in the n3 standard "n3" namespace as a keyword since n3:a
is so much shorter :-)

The cool thing is, it's not actually much longer than Notation3
in its plain format. Hmm... let's try a bigger document.


$ wc earl2.*
     25      68    1043 earl2.n3
     41      60    1635 earl2.rdf
     34      41    1288 earl2.xml
    100     169    3966 total

Closer to N3 in size than XML RDF, and quite readable too.

There is a problem in that we can't use URIs or literals for
subjects... we could always add n3:node, n3:uri, and n3:literal
attributes. Likewise, we could add n3:blank:-

<n3:blank _:q="_:myList :t"/>

However, generally I don't like to add syntactic fluff: the bNode
namespace syntax is bad enough.

Kindest Regards,
Sean B. Palmer
@prefix : <> .
:Sean :homepage <> .

Received on Wednesday, 20 March 2002 22:30:59 UTC