Tim Berners-Lee, Editor
Date: 1998, last change: $Id: Notation3.html,v 1.49 2001/11/27 23:59:33 timbl Exp $
Status: This document contains aditional resources about N3.

Up to Design Issues

An readable language for the Semantic Web


n3

Notation 3 Resources

Introduction

This accompanies the N3 specification.

Resources on Notation3 include the following:

Try it!

see also SWAG: Notation3 to RDF Converter, which (as of Aug 2001) is more actively maintained than this form.


Also:

Implementations: Grammars and parsers

The original hand-written grammar is a bit crufty; several more formal grammars have been developed.

http://www.w3.org/2000/10/swap/grammar/predictiveParser.py
Some parsers for Notation3 and its subsets (2004)
Parser level written in Author Notes
notation3.py N3 Python Connolly & Berners-Lee Handwritten, used in cwm, W3C open source
RDF/N3 parser. ? Python Graham Kline
n3.py No () or {} Python Sean Palmer 2002. Still extant? Part of Eep
afon N3 Python Sean Palmer Uses regexps. Roughly same speed as notation3.py
RDF::Notation3 ? Perl Ginger Alliance
notation3 parser N3 Java Jos de Roo Part of Agfa's Euler
N3 parser (?) ? Java Andy SeabourneHP Labs Part of HP's Jena
parser ~Turtle, sans lists PHP Gunnar Grimnes Based on SBP's n3.py, GPL
RAP N3-rdf? PHP chris@bizer.de (Chris Bizer) RDF API for PHP is a software package for searching, manipulating, and serving RDF models, integrated RDF/XML, N3 and N-Triple parser and serializer.
Raptor Turtle C Dave Becket Redland compatible
n3.bnf ? blindfold Sandro Hawke Blindfold is a bnf-driven parser.
flaten3 ? lex, yacc Sandro Hawke "A first pass at an n3 parser using lex and yacc"
n3spark.py ? spark Sandro Hawke A re-implementation of RDF/n3 syntax using the SPARK toolsAug 2001; discussion
rfdn3-gram ? yapps Dan Connolly a Yapps grammar for RDF Notation 3Aug 2001; discussion
EulerMoz

was:Samizdat

? Javascript Euler team Euler-inspired inference in Mozilla/Firefox, with Javascript parsers
n3p.py ? Python Sean Palmer See email
n3parser.js n3/rdf Javascript Tim BL See Developer notes for the AJAR RDF Library for Javascript, part of the Tabulator project. (In fact it will parse full N3, but the store doesn't handle quantification of variables.)
"Turtle/N3 parser" ??? Javascript Open Link Software Inc. See Blog Part of their Open Ajax Toolkit.
predictiveParser.py Any level. Python SWAP The predictiveParser is a generic parser whcih is driven directly by the context-free grammar, as annotated by some rules. This parser does not output triples, it just checks the syntax. See Makefile

This list may be very inaccurate and probably out of date. Mail me with differences you know about, and if you are using this stuff check the web sites and google for new implementations

Test Suites

Here are some manifests of test files. A positive parser test is one which an N3 parser should parse. It has a set of NTriples which should be produced. A negative parser test is a file which should produce an error when an N3 parser tries it.

Test files
Tests Level Author Notes
SWAP

n3parsertests.n3

N3 Scharf et al Positive and negative parser tests.
Turtle tests Turtle DavidBeckett Positive and negative parser tests
NTriples examples NTriples ? Do tests exist? Maybe examples from the RDF specs.

Parser implementers are encouraged to generate test results in RDF in the same form, so that results from multiple implementations can be tabulated.

Reification

Notation3, of any level, can be represneted as an RDF graph using a vocabulary <http://www.w3.org/2004/06/rei#>. Code exists (cwm --reify and cwm --dereify) to convert N3 to such a description and back. This allows, for example, rule files to be manipulated as RDF data.

This reification also allows an RDF graph to be described, quoted, within another RDF graph. (Note that the "reification" described in the RDF 1.0 specification is different, does not quote properly, and is not recommended.) Reification is described in greater detail elsewhere.

Identifying

A notation3 document has fragment identifiers of the form of alphanumeric strings with inital alpha, underscores allowed but not minus signs.

To label something you just invent that name and use it. There is no distinction between definition and reference. This is a fact of life, not of RDF or notation3. (A definitive reference is one in a document demonstrated to be definitive with respect to the namespace... but that is another story.)

<#ora> x:firstname "Ora".

<#ora> x:lastname "Lassila".

or indeed

:ora x:firstname "Ora"; x:lastname "Lassila".

Issues

A summary of recent design issues in Notation3:

  1. Should - signs be allowed in local identifiers and fragment identifiers? (yes)
  2. Should parsers use URI canonicalization to convert RDF symbols on input? Similarly, should we restrict all URIs to be canonicalized on output? (A processing option, on by default, off to be strict for RDF tests)
  3. Should we allow and remove whitespace within a URI in angle brackets? This makes t easy to split long URIs in trhings like email or 80 column source code, and was rather why the <> were originally assciated with URIs. (Yes, not implemented though, or any tests.)
  4. Should we allow "." as an alternative to "!" as a forward path traversal operator? This makes te tokenizer difficutl becaus eof the overloading of ".", but ity looks cute for obejct-oriented users. (No. cwm curently does and the tests include it).
  5. Define literal data to arbitary terminator ( """"""zyzzy"This is a string"zyzzy"""""") or something? (No, not yet)

Much detail on other and old issues are listed separately.

Acknowledgements

Dan Connolly wrote the first N3 parser. Sean Palmer and other folks on irc://openprojects.net/rdfig suggested many things and reviewed new ideas (and scrapped old ones!).   Yosi Scharf crated the parser test suites and worked on consistency between grammar, test suites and code. Thanks to all implementers on N3 software in all countries and langauges!


Change History

2006/01
Added decimal literals, and true and false, in coordination with SPARQL.
2003/03
Added literal numbers
2003/02
Added @forall @forsome
2001/04/10
Removed \a, \b, \f, \v because they are not allowed in XML. Changed "ASCII character" to "byte" for \ooo and \xhh. (duerst)
2000/12/29
Switched from bind to @prefix. Code still support sbind.

Added ( node node ...) list shorthand, as code now reads and writes it.

Added a little about self-describing documents.


References

See also links in the text.

D. Beckett, New Syntaxes for RDF summarizes the state of the art as of 2004.

N3QL, a draft proposal for an RDF query language.

N3-relevant functions

These are not part of the N3 language, but are properties which allow N3 to be used to express rules, and rules which talk about the provence of information, etc. Just as OWL is expressed in RDF by defining properties, so rules, queries, differences, and so on canbe expressed in RDF with the N3 extension to formulae.

The log: namespace has functions, which are built-in meaning for cwm, and in some cases have been also used by other code.

See also:

The prefix are in the namespace <http://www.w3.org/2000/10/log#>. Check the schema for the low-down - here are some highlights

log:implies

This implication links two formulae. The cwm rule engine recognises implies as a primitive, and will, when asked to process a rule file, look for any top level implication and find all matches in the store with the left hand side, generating the corresponding conclusion in each case.

log:Truth

A class of all true formulae.

(The cwm engine will proces rules in the (indirectly command-line specified) formula or any formula which it declares to be a Truth.

The dereifier will output any described formulae whcih are described as being in the class Truth.

log:semantics

The relation between a document and the logical expression it parses to.

log:includes