Dave Beckett

This is the original N-Triples draft from 2001. The version you probably want is the actual W3C Recommendation N-Triples from 2004.
-- Dave, 2007

$Revision: 1.8 $

1. Introduction

N-Triples is a line-based, plain text format (MIME Type text/plain) for representing the correct answers for parsing RDF/XML[RDFMS] test cases as part of the RDF Core working group.

Test cases in N-Triples can be found linked from the RDF Core issues tracking area especially the attention developers and closed issues sections.

This format was designed to be a fixed subset of N3[N3][N3-Primer] and hence N3 tools such as cwm, n-triples2kif.pl and Euler can be used to process it.

2. Extended Backus-Naur Form (EBNF) Grammar

An N-Triples document is defined by the ntripleDoc grammar term below and parsing it results in a sequence of RDF statements formed from the subject, predicate and object terms. The meaning of these are defined either in [RDFMS] or is ongoing as part of the RDF Core WG activity.

This EBNF is similar to the notation used in XML 1.0 second edition

line::=ws* (comment | triple) ? eoln 
comment::='#' [^ cr lf ]* 
triple::=subject ws+ predicate ws+ object ws* '.' ws* 
subject::=uriref | anonNode 
object::=uriref | anonNode | qLiteral 
uriref::='<' absoluteURI '>' 
anonNode::='_' ':' name 
qLiteral::='"' string '"' 
ws::=space | tab 
eoln::=cr? lf 
space::=ASCII space - decimal 32 
cr::=ASCII carriage return - decimal 13 
lf::=ASCII linefeed - decimal 10 
tab::=ASCII horizontal tab - decimal 9 
string::=character* with escapes as defined in section String Escaping 
absoluteURI::=[^ < > space]+ 
character::=An ASCII character from decimal 32 (space) to decimal 255# See issues

3. String Escaping

After [N3] the following escapes are defined (and no others):

Escape sequence Meaning
\\ ASCII backspace character (decimal 92)
\" ASCII double quote (decimal 34)
\n ASCII linefeed (decimal 10) - lf character
\r ASCII carriage return (decimal 13) - cr character
\t ASCII horizontal tab (decimal 9) - tab character

This is based on a subset of the allowed escapes in [N3] which is in turn based on Python string literals. It is a subset since not all that complexity is needed or required and for example, the \ before real newlines (cr or lf) could not be allowed since that would break the line-basis of N-Triples.

4. Issues

5. History

N-Triples was named and decided as the test-case format in the RDF Core WG 2001-06-01 meeting; see the minutes and chat logs

It was based on discussions from the long thread on RDF Core WG in May 2001 - Test cases: format of input and output mostly summarised in this message from Dan Connolly.

The original version of the grammar was based on emails to RDF Core list from Art Barstow: 1, 2 and change to 'triple' rule to allow ws* before '.' from Jan Grant.

6. References

[RDFMS] RDF Model and Syntax by Lassila and Swick (ed.), 22 February 1999.

[N3] Notation 3 by Tim Berners-Lee, over period 1998-.

[N3-Primer] Primer: Getting into RDF & Semantic Web using N3 by Tim Berners-Lee, over period 2000-.

A. Changes

Copyright 2001 Dave Beckett, Institute for Learning and Research Technology, University of Bristol

Validate me