The below lists are taken directly from the W3 team submission on Turtle in January 2008.
Turtle compared to N-Triples
Turtle as an offshoot of N-Triples adds the following syntax, some of which have been discussed in earlier pages.
- Whitespace restrictions removed
- Text content-encoding changed from ASCII to UTF-8
- @prefix
- QNames
- ,
- ;
- []
- a
- ()
- Decimal integer literals (xsd:integer)
- Decimal double literals (xsd:double)
- Decimal arbitrary length literals (xsd:decimal)
- Boolean literals
- @base
Turtle compared to Notation3
The following is not a complete list but highlight some of the syntax which remains in N3 but is not in Turtle.
- { ... }
- is of
- paths like :a.:b.:c and :a^:b^:c
- @keywords
- => implies
- = equivalence
- @forAll
- @forSome
- <=
Turtle compared to SPARQL
The SPARQL Query Language for RDF uses a Turtle/N3 style syntax for Triples including the same abbreviations mentioned earlier. The following syntax however are not in Turtle but are SPARQL. The following is not a complete list.
- RDF Literals are allowed in triple subjects
- Variables are allowed in any part of the triple of the form ?name or $name
- Long literals can use use single quote (') characters: ''' ... '''
- The constants allowed for XSD booleans: true and false are case independent. In Turtle they are not, only lowercase forms are allowed.
- SPARQL allows '.'s in names in all positions apart from the first or last. These would correspond to rules:
name ::= nameStartChar ( ( nameChar | '.' )* nameChar )?
prefixName ::= ( nameStartChar - '_' ) ( ( nameChar | ' .' )* nameChar )? - SPARQL allows digits in the first character of the PN_LOCAL lexical token. In Turtle, the only ascii characters allowed in a nameStartChar are [A-Z] | "_" | [a-z].
- Turtle allows prefix and base declarations anywhere outside of a triple. In SPARQL, they are only allowed in the Prologue (at the start of the SPARQL query).