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.

Basically...

* 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: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

 :x :y :z .

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

:Sean :homepage <http://purl.org/net/sbp/>;
   :name "Sean B. Palmer";
]]]

would become...

[[[
<n3:Document xmlns:n3="http://example.org/n3" xmlns="#"
  xmlns:_="http://exmaple.org/n3/bNode"
  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">

<x y=":z"/>

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

<Sean homepage="[http://purl.org/net/sbp/]"
   name="'Sean B. Palmer'"/>

</n3:Document>
]]]

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.

N3: http://infomesh.net/2002/earl2.n3
N3-in-XML: http://infomesh.net/2002/earl2.xml
XML RDF: http://infomesh.net/2002/earl2.rdf

$ 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 : <http://purl.org/net/swn#> .
:Sean :homepage <http://purl.org/net/sbp/> .

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