N-Quads
   HOME

TheInfoList



OR:

N-Triples is a format for storing and transmitting data. It is a line-based, plain text
serialisation In computing, serialization (or serialisation, also referred to as pickling in Python) is the process of translating a data structure or object state into a format that can be stored (e.g. files in secondary storage devices, data buffers in ...
format for RDF (Resource Description Framework) graphs, and a subset of the
Turtle Turtles are reptiles of the order (biology), order Testudines, characterized by a special turtle shell, shell developed mainly from their ribs. Modern turtles are divided into two major groups, the Pleurodira (side necked turtles) and Crypt ...
(Terse RDF Triple Language) format. 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 The University of Bristol is a public university, public research university in Bristol, England. It received its royal charter in 1909, although it can trace its roots to a Merchant Venturers' school founded in 1595 and University College, Br ...
and Art Barstow at the
World Wide Web Consortium The World Wide Web Consortium (W3C) is the main international standards organization for the World Wide Web. Founded in 1994 by Tim Berners-Lee, the consortium is made up of member organizations that maintain full-time staff working together in ...
(W3C). N-Triples was designed to be a simpler format than Notation3 and Turtle, and therefore easier for software to
parse Parsing, syntax analysis, or syntactic analysis is a process of analyzing a string of symbols, either in natural language, computer languages or data structures, conforming to the rules of a formal grammar by breaking it into parts. The term ''pa ...
and generate. However, because it lacks some of the shortcuts provided by other RDF serialisations (such as
CURIE Curie may refer to: *Curie family, a family of distinguished scientists: :* Jacques Curie (1856–1941), French physicist, Pierre's brother :* Pierre Curie (1859–1906), French physicist and Nobel Prize winner, Marie's husband :* Marie Curi ...
s 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.


Usage

There is very little variation in how an RDF
graph Graph may refer to: Mathematics *Graph (discrete mathematics), a structure made of vertices and edges **Graph theory, the study of such graphs and their properties *Graph (topology), a topological space resembling a graph in the sense of discret ...
can be represented in N-Triples. This makes it a very convenient format to provide "model answers" fo
RDF test suites


Implementations

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.


File format

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 White space or whitespace may refer to: Technology * Whitespace characters, characters in computing that represent horizontal or vertical space * White spaces (radio), allocated but locally unused radio frequencies * TV White Space Database, a m ...
: * the subject, * the predicate, * the object, * a
full stop The full stop ( Commonwealth English), period (North American English), or full point is a punctuation mark used for several purposes, most often to mark the end of a declarative sentence (as distinguished from a question or exclamation). A ...
which means the termination of a statement 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), delimited with double-quote characters, and optionally suffixed with a language or datatype indicator. Language indicators are an
at sign The at sign () is an accounting and invoice abbreviation meaning "at a rate of" (e.g. 7 Widget (economics), widgets @ £2 per widget = £14), now seen more widely in email addresses and social media platform User (computing), handles. It is norm ...
followed by an RFC 3066 language tag; datatype indicators are a double-
caret Caret () is the name used familiarly for the character provided on most QWERTY keyboards by typing . The symbol has a variety of uses in programming and mathematics. The name "caret" arose from its visual similarity to the original proofre ...
followed by a URI. Comments consist of a line beginning with a
hash sign The symbol is known as the number sign, hash, (or in North America) the pound sign. The symbol has historically been used for a wide range of purposes including the designation of an ordinal number and as a ligatured abbreviation for pounds a ...
.


Example

The N-Triples statements below are equivalent to this RDF/XML: * RDF/XML N-Triples Art Barstow Dave Beckett * N-Triples . "N-Triples"@en-US . _:art . _:dave . _:art . _:art "Art Barstow". _:dave . _:dave "Dave Beckett". (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

The related ''N-Quads'' superset extends N-Triples with an optional context value at the fourth position. . # comments here # or on a line by themselves _:subject1 "object1" . _:subject2 "object2" .


See also

* Notation3 (N3) *
Turtle (syntax) In computing, Terse RDF Triple Language (Turtle) is a syntax and file format for expressing data in the Resource Description Framework (RDF) data model. Turtle syntax is similar to that of SPARQL, an RDF query language. It is a common data for ...
*
TriG (syntax) TriG is a serialization format for RDF (Resource Description Framework) graphs. It is a plain text format for serializing named graph Named graphs are a key concept of Semantic Web architecture in which a set of Resource Description Framework st ...


References


External links


RDF for Intrepid Unix Hackers: Grepping N-Triples

RDF for Intrepid Unix Hackers: Transmuting N-Triples
{{Semantic Web Metadata Computer file formats