miscoranda: by Sean B. Palmer

One Notation3 Tutorial, Extra Terse

The following is a Notation3 tutorial derived from IRC. It's most suited to people who know the basics of RDF and the RDF/XML serialization, but nothing or little of N3.

N3 is rather easy to get the hang of.
URIs: <http://example.org/>
bNodes: _:label
literals: "this is a literal"
qnames: ns:term
variables: ?x
To bind namespaces to prefixes:
@prefix pfx: <http://example.org/namespace#> .
Then it follows these patterns:
s p o .
s p o; p o .
s p o, o .
and by extension:
s p o; p o; p o, o, o, o, o .
The empty URI refers to the current document, hence:
<> rdf:type :Document .
As you can see, you may also use an empty prefix.
That must be explicitly bound, and must be done as follows:
@prefix : <#> .
(or to whatever URI)
bNodes can also be spelled [], in which case they have no label. For example:
[] rdf:type foaf:Person, rdfs:Resource .
The properies and objects can be put inside one of those bNodes—really that's a special case:
[ rdf:type foaf:Person, rdfs:Resource ] .
The main keyword is "a" which means rdf:type, but there's also => which is used in logic.
# Comments use hashes
RDF lists can easily be done using parens, for example:
:subj :prop ("p" "q" "r") .
which is equivalent to:
:subj :prop [ rdf:first "p"; rdf:rest [ rdf:first "q"; rdf:rest [ rdf:first "r"; rdf:rest rdf:nil ] ] ] .
analogous to rdf:parseType="Collection" in RDF/XML.
That's all you need for the rudiments.

I hope that's helpful for anyone approaching the daunting world of N3, SWAP, and CWM.

by Sean B. Palmer, at 2004-08-01 22:02:40. Comment?

Random Utilities · King Leare

Sean B. Palmer