Proposed TriG Specification (the short form)

Editor's Draft 26 June 2010

This version:
Previous version:
Latest version:
Chris Bizer (Freie Universität Berlin)
Richard Cyganiak (Freie Universität Berlin)


The Resource Description Framework (RDF) is a general-purpose language for representing information in the Web. The Turtle Language provides a textual syntax for expressing an RDF graph. This document defines a language called TriG, which extends Turtle to label and represent multiple RDF graphs in the same document.

Status of this Document

This is a proposed replacement for the Freie Universität Berlin TriG Syntax specificaion. It has not been endorsed by any formal W3C process or by the members.

This specification relies heavily upon a Proposed Turtle Specification, maintained in parallel.

1. Introduction

This document defines a language called TriG which represents multiple Named Graphs [NGraph] within a single document. Named Graphs can provide RDF Datasets [RData] in SPARQL [SPARQL].

As with Turtle, it is syntactically valid to concatonate TriG documents. Likewise, zero or more Turtle documents maybe concatonated within TriG's "{}"s, which are used to designate graph boundries. Please see the grammar for a complete definition of the TriG Syntax.

This document defines TriG as an extension to the Turtle Grammar and Turtle Parsing Rules. This grammar shares many productions with the SPARQL Protocol And RDF Query Language (SPARQL) [SPARQLQ] grammar for TriplesBlock. The three grammars share production and terminal names where possible.

This definition of TriG proposes difference rules from those in Bizer and Cyganiak's TriG specification:

2. Examples

See § 2. Examples in Bizer and Cyganiak's TriG specification.

3. TriG Grammar

Like Turtle, A TriG document is a Unicode[UNICODE] character string encoded in UTF-8. Unicode codepoints only in the range U+0 to U+10FFFF inclusive are allowed. The TriG grammar is an extension of the Turtle grammar; the Turtle rules regarding white space, comments and string escapes apply to TriG as well as Turtle.

4.4 Grammar

The EBNF used here is defined in XML 1.0 (Third Edition) [NOTATION]

TriG - Terse RDF Triple Language EBNF
[1]    trigDoc    ::=    ( directive | trigGraph )*
[2]    trigGraph    ::=    IRIref "="? "{" turtleDoc" "}" "."?

4.5 Parsing

Parsing TriG requires a state of four items, two of which, baseURIstack and namespacestack, have been extend from Turtle in order to respect the scoping of @base and @prefix declarations withing trigGraphs:

Reaching the "{" in trigGraph duplicates the top entry in the baseURIstack and namespacestack. That is to say, the top entry in the stack is duplicated and pushed onto the stack. Reaching the "}" in trigGraph pops the top entry off baseURIstack and namespacestack.

@base <http://www.w3.org/People/> .
@prefix : <http://xmlns.com/foaf/0.1/> .

<Eric/ericP-foaf.rdf> = {
  @base <http://www.w3.org/People/Eric/> .
  @prefix ericFoaf: <ericP-foaf.rdf#> .
  ericFoaf:ericP :givenName "Eric" ;
                 :knows <http://norman.walsh.name/knows/who/dan-brickley> ,
                        [ :mbox <mailto:timbl@w3.org> ] ,
                        <http://getopenid.com/amyvdh> .

7. Conformance

Systems conforming to TriG MUST pass all the following test cases: @@ write me @@

8. Media Type and Content Encoding

The media type of TriG is text/turtle. The latest verison of this document http://www.w3.org/TeamSubmission/turtle/ will be updated when the media type for TriG is registered with the IETF. The content encoding of TriG content is always UTF-8. Charset parameters on the mime type are encouraged until such time as the text/ media type tree permits UTF-8 to be sent without a charset parameter. See B. Internet Media Type, File Extension and Macintosh File Type for the media type registration form.

A. References

A.1 Normative

Notation section in Extensible Markup Language (XML) 1.0 (Third Edition), T. Bray, J. Paoli, C.m. Sperberg-McQueen, E. Maler, F. Yergeau editors, W3C Recommendation, 04 February 2004. This version of XML 1.0 is http://www.w3.org/TR/2004/REC-xml-20040204/. The latest version of the Extensible Markup Language (XML) 1.0 is at http://www.w3.org/TR/REC-xml/.
N-Triples section in RDF Test Cases, J. Grant and D. Beckett, Editors, W3C Recommendation, 10 February 2004. This version of the RDF Test Cases is http://www.w3.org/TR/2004/REC-rdf-testcases-20040210/. The latest version of the RDF Test Cases is at http://www.w3.org/TR/rdf-testcases/.
The Unicode Standard Version 3.0, Addison Wesley, Reading MA, 2000, ISBN: 0-201-61633-5. This document is http://www.unicode.org/unicode/standard/standard.html.
Character Model for the World Wide Web 1.0: Fundamentals, M. J. Dürst, F. Yergeau, R. Ishida, M. Wolf, T. Texin editors, W3C Recommendation, 15 February 2005. This version of Character Model for the WWW 1.0: Fundamentals is http://www.w3.org/TR/2005/REC-charmod-20050215/ The latest version of Character Model for the WWW: Fundamentals 1.0 is at http://www.w3.org/TR/charmod/.
Resource Description Framework (RDF): Concepts and Abstract Syntax, G. Klyne, J.J. Carroll editors, W3C Recommendation, 10 February 2004. This version of RDF Concepts and Abstract Syntax is http://www.w3.org/TR/2004/REC-rdf-concepts-20040210/. The latest version of RDF Concepts and Abstract Syntax is http://www.w3.org/TR/rdf-concepts/.
RDF/XML Syntax Specification (Revised), D. Beckett editor, W3C Recommendation, 10 February 2004. This version of RDF/XML is http://www.w3.org/TR/2004/REC-rdf-syntax-grammar-20040210/. The latest version of RDF/XML is http://www.w3.org/TR/rdf-syntax-grammar/.
RFC 3629 UTF-8, a transformation format of ISO 10646, F. Yergeau November 2003
RFC 3986 Uniform Resource Identifier (URI): Generic Syntax, T. Berners-Lee, R. Fielding, L. Masinter January 2005
RFC 3987, "Internationalized Resource Identifiers (IRIs)", M. Dürst , M. Suignard
Unicode Security Considerations, Mark Davis, Michel Suignard
The Unicode Standard, Version 4. ISBN 0-321-18578-1, as updated from time to time by the publication of new versions. The latest version of Unicode and additional information on versions of the standard and of the Unicode Character Database is available at http://www.unicode.org/unicode/standard/versions/.

A.2 Informative

Previous version
Notation 3, Tim Berners-Lee, World Wide Web Consortium
Modernising Semantic Web Markup, Dave Beckett and presentation given at XML Europe 2004, Amsterdam, 20 April 2004
SPARQL Query Language for RDF, E. Prud'hommeaux, A. Seaborne, Editors. World Wide Web Consortium. W3C Recommendation, 15 January 2008. This version is http://www.w3.org/TR/2008/REC-rdf-sparql-query-20080115/. The latest version of SPARQL Query Language for RDF is available at http://www.w3.org/TR/rdf-sparql-query/.

B. Internet Media Type, File Extension and Macintosh File Type (Normative)

Eric Prud'hommeaux
See also:
How to Register a Media Type for a W3C Specification
Internet Media Type registration, consistency of use
TAG Finding 3 June 2002 (Revised 4 September 2002)

The Internet Media Type / MIME Type for TriG is "text/turtle".

It is recommended that TriG files have the extension ".ttl" (all lowercase) on all platforms.

It is recommended that sparql query files stored on Macintosh HFS file systems be given a file type of "TEXT".

This information that follows has been submitted to the IESG for review, approval, and registration with IANA.

Type name:
Subtype name:
Required parameters:
Optional parameters:
charset — this parameter may be required when transfering non-ascii data across some protocols. If present, the value of charset is always UTF-8.
Encoding considerations:
The syntax of TriG is expressed over code points in Unicode [UNICODE]. The encoding is always UTF-8 [RFC3629].
Unicode code points may also be expressed using an \uXXXX (U+0 to U+FFFF) or \UXXXXXXXX syntax (for U+10000 onwards) where X is a hexadecimal digit [0-9A-F]
Security considerations:
TriG uses IRIs as term identifiers. Applications interpreting data expressed in TriG sould address the security issues of Internationalized Resource Identifiers (IRIs) [RFC3987] Section 8, as well as Uniform Resource Identifier (URI): Generic Syntax [RFC3986] Section 7.
Multiple IRIs may have the same appearance. Characters in different scripts may look similar (a Cyrillic "о" may appear similar to a Latin "o"). A character followed by combining characters may have the same visual representation as another character (LATIN SMALL LETTER E followed by COMBINING ACUTE ACCENT has the same visual representation as LATIN SMALL LETTER E WITH ACUTE). Any person or application that is writing or interpreting data in TriG must take care to use the IRI that matches the intended semantics, and avoid IRIs that make look similar. Further information about matching of similar characters can be found in Unicode Security Considerations [UNISEC] and Internationalized Resource Identifiers (IRIs) [RFC3987] Section 8.
Interoperability considerations:
There are no known interoperability issues.
Published specification:
This specification.
Applications which use this media type:
No widely deployed applications are known to use this media type. It may be used by some web services and clients consuming their data.
Additional information:
Magic number(s):
TriG documents may have the strings '@prefix' or '@base' (case dependent) near the beginning of the document.
File extension(s):
Base URI:
The TriG '@base <IRIref>' term can change the current base URI for relative IRIrefs in the query language that are used sequentially later in the document.
Macintosh file type code(s):
Person & email address to contact for further information:
Eric Prud'hommeaux <eric@w3.org>
Intended usage:
Restrictions on usage:
Author/Change controller:
The TriG specification is the product of David Beckett and Tim Berners-Lee. A W3C Working Group may assume maintenance of this document; W3C reserves change control over this specifications.

C. Acknowledgements (Informative)

This work was casually stolen from the work of Chris Bizer, Richard Cyganiak, Jeremy Carrol, and probably some others.

D. Changes (Informative)

Changes since the last publication of this document Bizer and Cyganiak's TriG specification . See the Previous changelog for further information

$Id: Trig.html,v 1.2 2010/06/26 22:50:27 eric Exp $

Valid XHTML + RDFa