Notation3

{{Short description|Compact non-XML format for RDF models}}

{{Infobox file format

| name = Notation3

| icon =

| icon_size = 100px

| logo =

| extension = .n3

| mime = text/n3;charset=utf-8

| type code =

| uniform type =

| magic =

| owner = Tim Berners-Lee

| genre = semantic web

| container for = RDF data

| extended from =

| extended to =

| standard = [http://www.w3.org/TeamSubmission/n3/ n3]

| url = {{URL|https://www.w3.org/TeamSubmission/n3/}}

}}

Notation3, or N3 as it is more commonly known, is a shorthand non-XML serialization of Resource Description Framework models, designed with human-readability in mind: N3 is much more compact and readable than XML RDF notation. The format is being developed by Tim Berners-Lee and others from the Semantic Web community. A formalization of the logic underlying N3 was published by Berners-Lee and others in 2008.{{Cite journal | last1 = Berners-Lee | first1 = T. I. M. | last2 = Connolly | first2 = D. A. N. | last3 = Kagal | first3 = L. | last4 = Scharf | first4 = Y. | last5 = Hendler | first5 = J. I. M. | title = N3Logic: A logical framework for the World Wide Web | doi = 10.1017/S1471068407003213 | journal = Theory and Practice of Logic Programming | volume = 8 | issue = 3 | year = 2008 | pages = 249–269 | arxiv = 0711.1533 }}

N3 has several features that go beyond a serialization for RDF models, such as support for RDF-based rules. Turtle is a simplified, RDF-only subset of N3.

Examples

The following is an RDF model in standard XML notation:

xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

xmlns:dc="http://purl.org/dc/elements/1.1/">

Tony Benn

Wikipedia

may be written in Notation3 like this:

@prefix dc: .

dc:title "Tony Benn";

dc:publisher "Wikipedia".

This N3 code above would also be in valid Turtle syntax.

Comparison of Notation3, Turtle, and N-Triples

{{incomplete list|date=June 2018}}

class="wikitable"

! scope="col" colspan="2" | Feature !! scope="col" | Notation3 !! scope="col" | Turtle !! scope="col" | N-Triples

colspan="2" {{rh2|align=right}} | Character encoding

| colspan="2" align=center | UTF-8 || {{safe|ASCII}}

scope="row" rowspan="5" {{rh2|align=right}} | Directives

| {{code|@base}} || {{ya}} || {{ya}} || {{na}}

{{code|@forAll}}{{ya}}{{na}}{{na}}
{{code|@forSome}}{{ya}}{{na}}{{na}}
{{code|@keywords}}{{ya}}{{na}}{{na}}
{{code|@prefix}}{{ya}}{{ya}}{{na}}
scope="row" rowspan="3" {{rh2|align=right}} | Lists
{{code|()}} {{small|(DAML lists)}}{{ya}}{{ya}}{{na}}
{{code|{ … }}} {{small|(statement lists)}}{{ya}}{{na}}{{na}}
scope="row" rowspan="4" {{rh2|align=right}} | Literals

| {{code|true}} / {{code|false}}
{{small|(Boolean)}} || {{ya}} || {{ya}} || {{na}}

{{code|xsd:decimal}}
{{small|(decimal arbitrary length)}}
{{ya}}{{ya}}{{na}}
{{code|xsd:double}}
{{small|(decimal double)}}
{{ya}}{{ya}}{{na}}
{{code|xsd:integer}}
{{small|(decimal integer)}}
{{ya}}{{ya}}{{na}}
scope="row" rowspan="9" {{rh2|align=right}} | Syntactic sugar

| RDF paths || {{ya}} || {{na}} || {{na}}

QNames{{ya}}{{ya}}{{na}}
{{code|a}}/{{code|@a}} {{small|(equiv. to {{code|rdf:type}})}}{{ya}}{{ya}}{{na}}
{{code|[]}} {{small|(shorthand for blank node)}}{{ya}}{{ya}}{{na}}
{{code|=>}} {{small|(x implies y)}}{{ya}}{{na}}{{na}}
{{code|<=}} {{small|(y implies x)}}{{ya}}{{na}}{{na}}
{{code|=}} {{small|(x is equivalent to y)}}{{ya}}{{na}}{{na}}
{{code|,}} {{small|(repeat object in list)}}{{ya}}{{ya}}{{na}}
{{code|;}} {{small|(repeat subject/verb in list)}}{{ya}}{{ya}}{{na}}

See also

References