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) 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 primary storage devices) or transmitted (e ...
format for RDF (Resource Description Framework) graphs, and a subset of the
Turtle Turtles are an order of reptiles known as Testudines, characterized by a special shell developed mainly from their ribs. Modern turtles are divided into two major groups, the Pleurodira (side necked turtles) and Cryptodira (hidden necked t ...
(Terse RDF Triple Language) format. N-Triples should not be confused with
Notation3 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 ...
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 Red brick university, red brick Russell Group research university in Bristol, England. It received its royal charter in 1909, although it can trace its roots to a Society of Merchant Venturers, Merchant Venturers' sc ...
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 and led by Tim Berners-Lee, the consortium is made up of member organizations that maintain full-time staff working to ...
(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 the process of analyzing a string of symbols, either in natural language, computer languages or data structures, conforming to the rules of a formal grammar. The term ''parsing'' comes from Lati ...
and generate. However, because it lacks some of the shortcuts provided by other RDF serialisations (such as
CURIE In computing, a CURIE (or ''Compact URI'') defines a generic, abbreviated syntax for expressing Uniform Resource Identifiers (URIs). It is an abbreviated URI expressed in a compact syntax, and may be found in both XML and non-XML grammars. A 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 discr ...
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 mec ...
: * 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. It is used for several purposes, most often to mark the end of a declarative sentence (as distinguished from a question or exclamatio ...
which means the termination of a statement Subjects may take the form of a
URI Uri may refer to: Places * Canton of Uri, a canton in Switzerland * Úri, a village and commune in Hungary * Uri, Iran, a village in East Azerbaijan Province * Uri, Jammu and Kashmir, a town in India * Uri (island), an island off Malakula Isla ...
or a ''
blank node In RDF, a blank node (also called ''bnode'') is a node in an RDF graph representing a resource for which a URI or literal is not given. The resource represented by a blank node is also called an anonymous resource. According to the RDF standard a ...
''; 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 A bracket is either of two tall fore- or back-facing punctuation marks commonly used to isolate a segment of text or data from its surroundings. Typically deployed in symmetric pairs, an individual bracket may be identified as a 'left' or 'r ...
. 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 normally read aloud as "at"; it is also commonly called the at symbol, commercial at, or address sign. It is used as an accounting and invoice abbreviation meaning "at a rate of" (e.g. 7 widgets @ £2 per widget = £14), but ...
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 proofread ...
followed by a URI. Comments consist of a line beginning with a
hash sign The symbol is known variously in English-speaking regions as the number sign, hash, or 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 abbreviati ...
.


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 format ...
*
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 s ...


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