In
computing
Computing is any goal-oriented activity requiring, benefiting from, or creating computer, computing machinery. It includes the study and experimentation of algorithmic processes, and the development of both computer hardware, hardware and softw ...
, Terse RDF Triple Language (Turtle) is a
syntax
In linguistics, syntax ( ) is the study of how words and morphemes combine to form larger units such as phrases and sentences. Central concerns of syntax include word order, grammatical relations, hierarchical sentence structure (constituenc ...
and
file format
A file format is a Computer standard, standard way that information is encoded for storage in a computer file. It specifies how bits are used to encode information in a digital storage medium. File formats may be either proprietary format, pr ...
for expressing data in the
Resource Description Framework
The Resource Description Framework (RDF) is a method to describe and exchange graph data. It was originally designed as a data model for metadata by the World Wide Web Consortium (W3C). It provides a variety of syntax notations and formats, of whi ...
(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.
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/books/Huckleberry_Finn>
<http://example.org/relation/author>
<http://example.org/person/Mark_Twain> .
History
Turtle was defined by Dave Beckett as a subset of
Tim Berners-Lee
Sir Timothy John Berners-Lee (born 8 June 1955), also known as TimBL, is an English computer scientist best known as the inventor of the World Wide Web, the HTML markup language, the URL system, and HTTP. He is a professorial research fellow a ...
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
Extensible Markup Language (XML) is a markup language and file format for storing, transmitting, and reconstructing data. It defines a set of rules for encoding electronic document, documents in a format that is both human-readable and Machine-r ...
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
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) 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.
A significant proportion of RDF toolkits include Turtle parsing and serializing capability. Some examples of such toolkits are
Redland,
RDF4J,
Jena
Jena (; ) is a List of cities and towns in Germany, city in Germany and the second largest city in Thuringia. Together with the nearby cities of Erfurt and Weimar, it forms the central metropolitan area of Thuringia with approximately 500,000 in ...
, 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:
@prefix rdf: .
@prefix dc: .
@prefix ex: .
dc:title "RDF/XML Syntax Specification (Revised)" ;
ex:editor
"> ex:fullname "Dave Beckett";
ex:homePage
.
(Turtle examples are also valid
Notation3).
The example encodes an RDF graph made of four triples, which express these facts:
* The W3C technical report on RDF syntax and grammar has the title ''RDF/XML Syntax Specification (Revised)''.
* That report's editor is a certain individual, who in turn
** Has full name ''Dave Beckett''.
** Has a home page at a certain place.
Here are the triples made explicit in
N-Triples notation:
"RDF/XML Syntax Specification (Revised)" .
_:bnode .
_:bnode "Dave Beckett" .
_:bnode .
The
MIME type of Turtle is
text/turtle
. The character encoding of Turtle content is always
UTF-8
UTF-8 is a character encoding standard used for electronic communication. Defined by the Unicode Standard, the name is derived from ''Unicode Transformation Format 8-bit''. Almost every webpage is transmitted as UTF-8.
UTF-8 supports all 1,112,0 ...
.
Named graphs
TriG RDF syntax extends Turtle with support for
named graph
Named graphs are a key concept of Semantic Web architecture in which a set of Resource Description Framework statements (a graph) are identified using a URI, allowing descriptions to be made of that set of statements such as context, provenance ...
s.
See also
*
N-Triples
*
Notation3 (N3)
*
LV2
References
External links
Turtle SpecificationTurtle TL;DR Cheatsheet on Enola.dev
{{Semantic Web
Resource Description Framework
Syntax
Computer file formats