N-Triples | |
Extension: | .nt |
Mime: | application/n-triples |
Owner: | W3C |
Genre: | semantic web |
Latest Release Version: | RDF 1.1 N-Triples (REC) |
Container For: | RDF data |
Extended To: | Turtle |
N-Triples is a format for storing and transmitting data. It is a line-based, plain text serialisation format for RDF (Resource Description Framework) graphs, and a subset of the Turtle (Terse RDF Triple Language) format.[1] [2] [3] N-Triples should not be confused with Notation3 which is a superset of Turtle. N-Triples was primarily developed by Dave Beckett at the University of Bristol and Art Barstow at the World Wide Web Consortium (W3C).[4]
N-Triples was designed to be a simpler format than Notation3 and Turtle, and therefore easier for software to parse and generate. However, because it lacks some of the shortcuts provided by other RDF serialisations (such as CURIEs and nested resources, which are provided by both RDF/XML and Turtle) it can be onerous to type out large amounts of data by hand, and difficult to read.
There is very little variation in how an RDF graph can be represented in N-Triples. This makes it a very convenient format to provide "model answers" for RDF test suites.
As N-Triples is a subset of Turtle and Notation3, by definition all tools which support input in either of those formats will support N-Triples. In addition, some tools like Cwm have specific support for N-Triples.
Each line of the file has either the form of a comment or of a statement: A statement consists of four parts, separated by whitespace:
Subjects may take the form of a URI or a blank node; predicates must be a URI; objects may be a URI, blank node or a literal. URIs are delimited with less-than and greater-than signs used as angle brackets. Blank nodes are represented by an alphanumeric string, prefixed with an underscore and colon (_:
). Literals are represented as printable ASCII strings (with backslash escapes),[5] delimited with double-quote characters, and optionally suffixed with a language or datatype indicator. Language indicators are an at sign followed by an RFC 3066 language tag; datatype indicators are a double-caret followed by a URI. Comments consist of a line beginning with a hash sign.
The N-Triples statements below are equivalent to this RDF/XML:
(The symbol ↵ is used to indicate a place where a line has been wrapped for legibility. N-Triples do not allow lines to be wrapped arbitrarily: the line endings indicate the end of a statement.)
N-Quads | |
Extension: | .nq |
Mime: | application/n-quads |
Owner: | W3C |
Genre: | semantic web |
Latest Release Version: | RDF 1.1 N-Quads (REC) |
Container For: | RDF data |
The related N-Quads superset extends N-Triples with an optional context value at the fourth position.[6] [7] [8]