Log on:
Powered by Elgg

Home > Group JVDB > 3 Technologies > RDF and Turtle > Turtle Syntax and Turtle Grammar

Disclaimer: The following contains quite a bit of technical information and hence may not be very informative for an individual who has not used RDF.

Syntax

- URIs are written enclosed by "< >" or abbreviated using Turtle's @prefix directive which allows using a short prefix name instead of a long prefix of repreated URIs.

- Literals are written using double quotes for text without linebreaks and in betweem "*** ***" for longer text (e.g. ***long literal***)

- Blank nodes are written as _:nodeID to provide a blank node at given nodeID. It can also be written with "[ ]".

 

Abbreviations

The @base directive along with the @prefix can be used to greatly simplify and abbreviate URIs.

The "," symbol is used to repeat subjects and predicates of triples that only differ at object.

The ";" is used to repeat subjects that differ at predicate and object RDF terms.

Decimal integers, floating point doubles and floating point arbitrary precision numbers may all be written directly and correspond to the XML Schema Datatype in both syntax and datatype URI. Similarly Boolean may be written directly as "true" or "false" and correspond to the XML Schema Datatype in both syntax and datatype URI.

An RDF Collection can be written using a sequence of RDF terms enclosed in "()" and separated by white space.

 

Grammar

White space, inputted "ws" is used to separate two tokens which may otherwise be mistaken for one. Note: In programming languages, a token is a single element of the programming language. For instance a token maybe a keyword, an operator or a punctuation mark.

Comments in turtle are made using "#" at the beginning of the comment and continue on until the end of the line.

Turtle strings and URIs can use "\-escape" sequences to represent Unicode code points.

URIs are resolved relative to the In-scope base URI. In practice this means the the URI is resolved relative to the last @base directive set. (This will be further clarified in the examples section.)