N3 Notation
From Wiki
This article is a stub. You can help us by expanding it.
Contents |
RDF Triples and N3
<rdf:Description rdf:about="ex:adrian"> <foaf:knows rdf:resource="ex:gerd"/> <foaf:age rdf:datatype="xs:int">41</ex:age> </rdf:Description>
// N3 Syntax ex:adrian foaf:knows ex:gerd. ex:adrian foaf:age "41"^^xs:int.
Short Syntax for N3 (using semicolon)
ex:adrian foaf:knows ex:gerd; foaf:age "41"^^xs:int.
Namespace declarations
@prefix ex: <http://www.example.org/persons#>
or
@prefix : <http://www.mydefaultnamespace.org/#>
for the default namespace.
If nodes are from the default namespace we can write:
:adrian :child [ foaf:age "11"^^xs:int ] , [ foaf:age "3"^^xs:int ].
N3 representation of a RDF graph
// XML Syntax
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:m="http://www.example.org/meeting_organization#"
xmlns:g="http://www.another.example.org/geographical#">
<rdf:Description about="http://meetings.example.com/cal#m1">
<m:Location parseType="Resource">
<g:zip>02139</g:zip>
<g:lat>14.124425</g:lat>
<g:long>14.245</g:long>
</m:Location>
<m:chair rdf:resource="http://www.example.org/people#fred"/>
</rdf:Description>
</rdf:RDF>
translates in N3 as:
// N3 notation @prefix m: <http://www.example.org/meeting_organization#> . @prefix g: <http://www.another.example.org/geographical#> . <http://meetings.example.com/cal#m1> m:Location [ g:zip "02139"; g:lat "14.124425"; g:long "14.245" ]; m:chair <http://www.example.org/people#fred>.
Rules in N3
Variables are denoted like any other resource but identified by declarations:
// universally quantified variables
@forAll :x, :y.
{ :x :parent :y } => { :y ex:child :x }.
// existentially quantified variables
@forSome :a.
:Joe :home :a.
:a :owner :Joe.
:a :phone "555-1212".
You can use ? to denote universally quantifies variables and _ for the existentially quantified ones.
{ :?x :parent :?y } => { :?y ex:child :?x }.
:Joe :home :_a.
:_a :owner :Joe.
:_a :phone "555-1212".
N3 Rules Processors and Open Issues
- Rules are processed with CWM, a forward chaining reasoner which can be used for querying, checking, transforming and filtering information. Its core language is RDF, extended to include rules, and it uses RDF/XML or RDF/N3 serializations as required
- Open issues: negation, disjunction, existential quantified variables in rule consequent, datatypes usage.

