N-Triples

Last updated
N-Triples
Filename extension
.nt
Internet media type
application/n-triples
Developed by W3C
Latest release
RDF 1.1 N-Triples (REC)
February 25, 2014;9 years ago (2014-02-25)
Type of format semantic web
Container for RDF data
Extended to Turtle
Website www.w3.org/TR/n-triples/

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]

Contents

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.

Usage

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. [3]

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:

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.

Example

The N-Triples statements below are equivalent to this RDF/XML:

<rdf:RDFxmlns="http://xmlns.com/foaf/0.1/"xmlns:dc="http://purl.org/dc/terms/"xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><Documentrdf:about="http://www.w3.org/2001/sw/RDFCore/ntriples/"><dc:titlexml:lang="en-US">N-Triples</dc:title><maker><Personrdf:nodeID="art"><name>ArtBarstow</name></Person></maker><maker><Personrdf:nodeID="dave"><name>DaveBeckett</name></Person></maker></Document></rdf:RDF>
<http://www.w3.org/2001/sw/RDFCore/ntriples/><http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://xmlns.com/foaf/0.1/Document>.<http://www.w3.org/2001/sw/RDFCore/ntriples/><http://purl.org/dc/terms/title>"N-Triples"@en-US.<http://www.w3.org/2001/sw/RDFCore/ntriples/><http://xmlns.com/foaf/0.1/maker>_:art.<http://www.w3.org/2001/sw/RDFCore/ntriples/><http://xmlns.com/foaf/0.1/maker>_:dave._:art<http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://xmlns.com/foaf/0.1/Person>._:art<http://xmlns.com/foaf/0.1/name>"Art Barstow"._:dave<http://www.w3.org/1999/02/22-rdf-syntax-ns#type><http://xmlns.com/foaf/0.1/Person>._:dave<http://xmlns.com/foaf/0.1/name>"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

N-Quads
Filename extension
.nq
Internet media type
application/n-quads
Developed by W3C
Latest release
RDF 1.1 N-Quads (REC)
February 25, 2014;9 years ago (2014-02-25)
Type of format semantic web
Container for RDF data
Website www.w3.org/TR/n-quads/

The related N-Quads superset extends N-Triples with an optional context value at the fourth position. [6] [7] [8]

<http://one.example/subject1><http://one.example/predicate1><http://one.example/object1><http://example.org/graph3>.# comments here# or on a line by themselves_:subject1<http://an.example/predicate1>"object1"<http://example.org/graph1>._:subject2<http://an.example/predicate2>"object2"<http://example.org/graph5>.

See also

Related Research Articles

<span class="mw-page-title-main">Semantic Web</span> Extension of the Web to facilitate data exchange

The Semantic Web, sometimes known as Web 3.0, is an extension of the World Wide Web through standards set by the World Wide Web Consortium (W3C). The goal of the Semantic Web is to make Internet data machine-readable.

The Resource Description Framework (RDF) is a World Wide Web Consortium (W3C) standard originally designed as a data model for metadata. It has come to be used as a general method for description and exchange of graph data. RDF provides a variety of syntax notations and data serialization formats, with Turtle currently being the most widely used notation.

XML namespaces are used for providing uniquely named elements and attributes in an XML document. They are defined in a W3C recommendation. An XML instance may contain element or attribute names from more than one XML vocabulary. If each vocabulary is given a namespace, the ambiguity between identically named elements or attributes can be resolved.

RDF Schema (Resource Description Framework Schema, variously abbreviated as RDFS, RDF(S), RDF-S, or RDF/S) is a set of classes with certain properties using the RDF extensible knowledge representation data model, providing basic elements for the description of ontologies. It uses various forms of RDF vocabularies, intended to structure RDF resources. RDF and RDFS can be saved in a triplestore, then one can extract some knowledge from them using a query language, like SPARQL.

SPARQL is an RDF query language—that is, a semantic query language for databases—able to retrieve and manipulate data stored in Resource Description Framework (RDF) format. It was made a standard by the RDF Data Access Working Group (DAWG) of the World Wide Web Consortium, and is recognized as one of the key technologies of the semantic web. On 15 January 2008, SPARQL 1.0 was acknowledged by W3C as an official recommendation, and SPARQL 1.1 in March, 2013.

<span class="mw-page-title-main">FOAF</span> Semantic Web ontology to describe relations between people

FOAF is a machine-readable ontology describing persons, their activities and their relations to other people and objects. Anyone can use FOAF to describe themselves. FOAF allows groups of people to describe social networks without the need for a centralised database.

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.

GRDDL is a markup format for Gleaning Resource Descriptions from Dialects of Languages. It is a W3C Recommendation, and enables users to obtain RDF triples out of XML documents, including XHTML. The GRDDL specification shows examples using XSLT, however it was intended to be abstract enough to allow for other implementations as well. It became a Recommendation on September 11, 2007.

RDFa or Resource Description Framework in Attributes is a W3C Recommendation that adds a set of attribute-level extensions to HTML, XHTML and various XML-based document types for embedding rich metadata within Web documents. The Resource Description Framework (RDF) data-model mapping enables its use for embedding RDF subject-predicate-object expressions within XHTML documents. It also enables the extraction of RDF model triples by compliant user agents.

<span class="mw-page-title-main">RDFLib</span> Python library to serialize, parse and process RDF data

RDFLib is a Python library for working with RDF, a simple yet powerful language for representing information. This library contains parsers/serializers for almost all of the known RDF serializations, such as RDF/XML, Turtle, N-Triples, & JSON-LD, many of which are now supported in their updated form. The library also contains both in-memory and persistent Graph back-ends for storing RDF information and numerous convenience functions for declaring graph namespaces, lodging SPARQL queries and so on. It is in continuous development with the most recent stable release, rdflib 6.1.1 having been released on 20 December 2021. It was originally created by Daniel Krech with the first release in November, 2002.

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 for storing RDF data, along with N-Triples, JSON-LD and RDF/XML.

<span class="mw-page-title-main">Blank node</span>

In RDF, a blank node 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 blank node can only be used as subject or object of an RDF triple.

In computing, a CURIE 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 CURIE may be considered a datatype.

<span class="mw-page-title-main">Named graph</span> Extension of the RDF data model

Named graphs are a key concept of Semantic Web architecture in which a set of Resource Description Framework statements are identified using a URI, allowing descriptions to be made of that set of statements such as context, provenance information or other such metadata.

XHTML+RDFa is an extended version of the XHTML markup language for supporting RDF through a collection of attributes and processing rules in the form of well-formed XML documents. XHTML+RDFa is one of the techniques used to develop Semantic Web content by embedding rich semantic markup. Version 1.1 of the language is a superset of XHTML 1.1, integrating the attributes according to RDFa Core 1.1. In other words, it is an RDFa support through XHTML Modularization.

JSON-LD is a method of encoding linked data using JSON. One goal for JSON-LD was to require as little effort as possible from developers to transform their existing JSON to JSON-LD. JSON-LD allows data to be serialized in a way that is similar to traditional JSON. It was initially developed by the JSON for Linking Data Community Group before being transferred to the RDF Working Group for review, improvement, and standardization, and is currently maintained by the JSON-LD Working Group. JSON-LD is a World Wide Web Consortium Recommendation.

A document type declaration, or DOCTYPE, is an instruction that associates a particular XML or SGML document with a document type definition (DTD). In the serialized form of the document, it manifests as a short string of markup that conforms to a particular syntax.

A semantic triple, or RDF triple or simply triple, is the atomic data entity in the Resource Description Framework (RDF) data model. As its name indicates, a triple is a set of three entities that codifies a statement about semantic data in the form of subject–predicate–object expressions.

Linked Data Notifications (LDN) is a W3C Recommendation that describes a communications protocol based on HTTP, URI, and RDF on how servers (receivers) can receive messages pushed to them by applications (senders), as well as how other applications (consumers) may retrieve those messages. Any web resource can advertise a receiving endpoint (inbox) for notification messages. Messages are expressed in RDF, and can contain arbitrary data.

The PROV standard defines a data model, serializations, and definitions to support the interchange of provenance information on the Web. Here provenance includes all "information about entities, activities, and people involved in producing a piece of data or thing, which can be used to form assessments about its quality, reliability or trustworthiness".

References

  1. "RDF 1.1 N-Triples". W3C Recommendation 25 February 2014. www.w3.org. Retrieved 2014-02-25.
  2. "N-Triples". W3C RDF Core WG Internal Working Draft. www.w3.org. Retrieved 2008-02-17.
  3. 1 2 "RDF Test Cases - N-Triples". W3C Recommendation 10 Feb 2004. www.w3.org. Retrieved 2008-02-17.
  4. "XML and Semantic Web W3C Standards Timeline" (PDF).
  5. Jan Grant, Dave Beckett (2004-02-10). "RDF Test Cases / N-Triples / Strings". W3C Recommendation. W3C. Retrieved 2012-04-25. N-Triples strings are sequences of US-ASCII character productions encoding [UNICODE] character strings. The characters outside the US-ASCII range and some other specific characters are made available by \-escape sequences as follows ...
  6. "RDF 1.1 N-Quads". www.w3.org.
  7. "RDF 1.1 N-Quads". www.w3.org.
  8. "Archived copy". Archived from the original on 2013-04-26. Retrieved 2013-04-26.{{cite web}}: CS1 maint: archived copy as title (link)