Turtle (syntax)

Last updated

Terse RDF Triple Language
Filename extension
.ttl
Internet media type
text/turtle
Developed by Dave Beckett
Latest release
RDF 1.1 Turtle (REC)
25 February 2014
Type of format Semantic Web
Container for RDF data
Extended from N-Triples, Notation3
Extended to TriG_(syntax)
Website www.w3.org/TR/turtle/

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.

Contents

RDF represents information using semantic triples, which comprise a subject, predicate, and object. Each item in the triple is expressed as a Web URI. Turtle provides a way to group three URIs to make a triple, and provides ways to abbreviate such information, for example by factoring out common portions of URIs. For example, information about Huckleberry Finn could be expressed as:

<http://example.org/person/Mark_Twain>    <http://example.org/relation/author>    <http://example.org/books/Huckleberry_Finn> .

History

Turtle was defined by Dave Beckett as a subset of Tim Berners-Lee and Dan Connolly's Notation3 (N3) language, and a superset of the minimal N-Triples format. Unlike full N3, which has an expressive power that goes much beyond RDF, Turtle can only serialize valid RDF graphs. Turtle is an alternative to RDF/XML, the original syntax and standard for writing RDF. As opposed to RDF/XML, Turtle does not rely on XML and is generally recognized as being more readable and easier to edit manually than its XML counterpart.

SPARQL, the query language for RDF, uses a syntax similar to Turtle for expressing query patterns.

In 2011, a working group of the World Wide Web Consortium (W3C) started working on an updated version of RDF, with the intention of publishing it along with a standardised version of Turtle. This Turtle specification was published as a W3C Recommendation on 25 February 2014. [1]

A significant proportion of RDF toolkits include Turtle parsing and serializing capability. Some examples of such toolkits are Redland, RDF4J, Jena, Python's RDFLib and JavaScript's N3.js.

Example

The following example defines 3 prefixes ("rdf", "dc", and "ex"), and uses them in expressing a statement about the editorship of the RDF/XML document:

@prefixrdf:<http://www.w3.org/1999/02/22-rdf-syntax-ns#>.@prefixdc:<http://purl.org/dc/elements/1.1/>.@prefixex:<http://example.org/stuff/1.0/>.<http://www.w3.org/TR/rdf-syntax-grammar>dc:title"RDF/XML Syntax Specification (Revised)";ex:editor[ex:fullname"Dave Beckett";ex:homePage<http://purl.org/net/dajobe/>].

(Turtle examples are also valid Notation3).

The example encodes an RDF graph made of four triples, which express these facts:

Here are the triples made explicit in N-Triples notation:

<http://www.w3.org/TR/rdf-syntax-grammar><http://purl.org/dc/elements/1.1/title>"RDF/XML Syntax Specification (Revised)".<http://www.w3.org/TR/rdf-syntax-grammar><http://example.org/stuff/1.0/editor>_:bnode._:bnode<http://example.org/stuff/1.0/fullname>"Dave Beckett"._:bnode<http://example.org/stuff/1.0/homePage><http://purl.org/net/dajobe/>.

The MIME type of Turtle is text/turtle. The character encoding of Turtle content is always UTF-8. [2]

Named graphs

TriG RDF syntax extends Turtle with support for named graphs.

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.

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.

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.

An RDF query language is a computer language, specifically a query language for databases, able to retrieve and manipulate data stored in Resource Description Framework (RDF) format.

Redland is a set of free software libraries written in C that provide support for the Resource Description Framework (RDF), created by Dave Beckett.

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

RDF/XML is a syntax, defined by the W3C, to express an RDF graph as an XML document. RDF/XML is sometimes misleadingly called simply RDF because it was introduced among the other W3C specifications defining RDF and it was historically the first W3C standard RDF serialization format.

SPARUL, or SPARQL/Update, was a declarative data manipulation language that extended the SPARQL 1.0 query language standard. SPARUL provided the ability to insert, delete and update RDF data held within a triple store or quad store. SPARUL was originally written by Hewlett-Packard and has been used as the foundation for the current W3C recommendation entitled SPARQL 1.1 Update. With the publication of SPARQL 1.1, SPARUL is superseded and should only be consulted as a source of inspiration for possible future refinements of SPARQL, but not for real-world applications.

N-Triples is a format for storing and transmitting data. It is a line-based, plain text serialisation format for RDF graphs, and a subset of the Turtle 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 and Art Barstow at the World Wide Web Consortium (W3C).

TriG is a serialization format for RDF graphs. It is a plain text format for serializing named graphs and RDF Datasets which offers a compact and readable alternative to the XML-based TriX syntax.

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

Shapes Constraint Language (SHACL) is a World Wide Web Consortium (W3C) standard language for describing Resource Description Framework (RDF) graphs. SHACL has been designed to enhance the semantic and technical interoperability layers of ontologies expressed as RDF graphs.

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

Shape Expressions (ShEx) is a data modelling language for validating and describing a Resource Description Framework (RDF).

References

  1. "RDF 1.1 Turtle - Terse RDF Triple LanguageTurtle". World Wide Web Consortium (W3C). 25 February 2014. Retrieved 16 December 2015.
  2. "MIME Media Types: text/turtle". Internet Assigned Numbers Authority (IANA). 28 March 2011. Retrieved 27 November 2011.