N-Triples
Encyclopedia
N-Triples is a format for storing and transmitting data. It is a line-based, plain text serialisation format for RDF
Resource Description Framework
The Resource Description Framework is a family of World Wide Web Consortium specifications originally designed as a metadata data model...

 (Resource Description Framework) graphs, and a subset of the Turtle
Turtle (syntax)
Turtle is a serialization format for Resource Description Framework graphs. A subset of Tim Berners-Lee and Dan Connolly's Notation3 language, it was defined by Dave Beckett, and is a superset of the minimal N-Triples format. Unlike full N3, Turtle doesn't go beyond RDF's graph model...

 (Terse RDF Triple Language) format. N-Triples should not be confused with Notation 3
Notation 3
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...

 which is a superset of Turtle. N-Triples was primarily developed by Dave Beckett at the University of Bristol
University of Bristol
The University of Bristol is a public research university located in Bristol, United Kingdom. One of the so-called "red brick" universities, it received its Royal Charter in 1909, although its predecessor institution, University College, Bristol, had been in existence since 1876.The University is...

 and Art Barstow at the W3C.

N-Triples was designed to be a simpler format than Notation 3 and Turtle, and therefore easier for software to parse
Parsing
In computer science and linguistics, parsing, or, more formally, syntactic analysis, is the process of analyzing a text, made of a sequence of tokens , to determine its grammatical structure with respect to a given formal grammar...

 and generate. However, because it lacks some of the shortcuts provided by other RDF serialisations (such as CURIE
CURIE
A CURIE defines a generic, abbreviated syntax for expressing URIs. It is an abbreviated URI expressed in CURIE syntax, and may be found in both XML and non-XML grammars...

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 (data structure)
In computer science, a graph is an abstract data structure that is meant to implement the graph and hypergraph concepts from mathematics.A graph data structure consists of a finite set of ordered pairs, called edges or arcs, of certain entities called nodes or vertices...

 can be represented in N-Triples. This makes it a very convenient format to provide "model answers" for RDF test suites.

Implementations

As N-Triples is a subset of Turtle and Notation 3, by definition all tools which support input in either of those formats will support N-Triples. In addition, some tools like Cwm
Cwm
cwm may refer to* the geographical term for a rounded, glaciated valley also known as a corrie or cirque* the Welsh word for a valley, sometimes anglicized to Coombe* cwm , a general-purpose data processor for the semantic web...

 have specific support for N-Triples.

File Format

Each line of the file represents a single statement of information or a comment. Each statement consists of three parts, separated by whitespace
Whitespace (computer science)
In computer science, whitespace is any single character or series of characters that represents horizontal or vertical space in typography. When rendered, a whitespace character does not correspond to a visual mark, but typically does occupy an area on a page...

:
  • the subject,
  • the predicate and
  • the object,

and is terminated with a full stop
Full stop
A full stop is the punctuation mark commonly placed at the end of sentences. In American English, the term used for this punctuation is period. In the 21st century, it is often also called a dot by young people...

.

Subjects may take the form of a URI
Úri
Úriis a village and commune in the comitatus of Pest in Hungary....

 or a named node; predicates must be a URI; objects may be a URI, named node or a literal. URIs are delimited with less-than and greater-than signs used as angle brackets. Named nodes are represented by an alphanumeric string, prefixed with an underscore and colon (_:). Literals are represented by a C-style string, optionally suffixed with a language or datatype indicator. Language indicators are an at sign
At sign
The at sign , also called the ampersat, apetail, arroba, atmark, at symbol, commercial at or monkey tail, is formally an abbreviation of the accounting and commercial invoice term "at the rate of"...

 followed by an RFC 3066 language tag; datatype indicators are a double-caret
Caret
Caret usually refers to the spacing symbol ^ in ASCII and other character sets. In Unicode, however, the corresponding character is , whereas the Unicode character named caret is actually a similar but lowered symbol: ....

 followed by a URI. Comments consist of a line beginning with a hash sign
Number sign
Number sign is a name for the symbol #, which is used for a variety of purposes including, in some countries, the designation of a number...

.

By definition, all N-Triples files are encoded in US-ASCII, with characters outside the range of ASCII handled by escapes.

Example


  1. The N-Triples statements below are equivalent to this RDF/XML:
  2. xmlns:dc="http://purl.org/dc/terms/"
  3. xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
  4. N-Triples
  5. Art Barstow
  6. Dave Beckett



.
"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.)

External links

The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK