N-Quads is a line-based, plain text format for encoding an RDF dataset.
This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.
The N-Quads format has a similar flavour as N-Triples [N-TRIPLES]. The main distinction is that N-Quads allows encoding multiple graphs. This document is intended to become a Working Group Note.
This document was published by the RDF Working Group as a First Public Working Group Note. If you wish to make comments regarding this document, please send them to email@example.com (subscribe, archives). All comments are welcome.
Publication as a Working Group Note does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.
This document was produced by a group operating under the 5 February 2004 W3C Patent Policy. W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.
This document defines an easy to parse line-based language named N-Quads.
N-quads statments are a sequence of RDF terms representing the subject, predicate, object and graph label of an RDF Triple and the graph it is part of in a dataset. These may be seperated by white space (spaces
#x20 or tabs
#x9). This sequence is terminated by a '
.' and a new line (optional at the end of a document).
The simplest statement is a sequence of (subject, predicate, object) terms forming an RDF triple and an optional IRI labeling what graph in a dataset the triple belongs to, all are separated by whitespace and terminated by '
.' after each statement.
The graph label IRI can be ommited, in which case the triples are considered part of the default graph of the RDF dataset.
IRIs may be written only as absolute IRIs.
IRIs are enclosed in '<' and '>' and may contain numeric escape sequences (described below). For example
Literals are used to identify values such as strings, numbers, dates.
Literals (Grammar production Literal) have a lexical form followed by a language tag, a datatype IRI, or neither.
The representation of the lexical form consists of an initial delimiter
" (U+0022), a sequence of permitted characters or numeric escape sequence or string escape sequence, and a final delimiter. Literals may not contain the characters
CR. In addition '
\' (U+005C) may not appear in any quoted literal except as part of an escape sequence.
The corresponding RDF lexical form is the characters between the delimiters, after processing any escape sequences.
If present, the language tag is preceded by a '
If there is no language tag, there may be a datatype IRI, preceeded by '
^^' (U+005E U+005E). If there is no datatype IRI and no language tag, the datatype is
Include examples with a few escapes for new lines, etc
RDF blank nodes in N-Quads are expressed as
_: followed by a blank node label which is a series of name characters.
The characters in the label are built upon PN_CHARS_BASE, liberalized as follows:
_and digits may appear anywhere in a blank node label.
.may appear anywhere except the first or last character.
U+2040are permitted anywhere except the first character.
A fresh RDF blank node is allocated for each unique blank node label in a document. Repeated use of the same blank node label identifies the same RDF blank node.
As well as sections marked as non-normative, all authoring guidelines, diagrams, examples, and notes in this specification are non-normative. Everything else in this specification is normative.
The key words MUST, MUST NOT, REQUIRED, SHOULD, SHOULD NOT, RECOMMENDED, MAY, and OPTIONAL in this specification are to be interpreted as described in [RFC2119].
This specification defines conformance criteria for:
A conforming N-Quad document is a Unicode string that conforms to the grammar and additional constraints defined in section 4. Grammar, starting with the
nquadsDoc production. A N-Quad document serializes an RDF dataset.
A conforming N-Quad parser is a system capable of reading N-Quad documents on behalf of an application. It makes the serialized RDF graph, as defined in section 5. Parsing, available to the application, usually through some form of API.
The IRI that identifies the N-Quad language is:
The media type of N-Quads is
The content encoding of N-Quads is always UTF-8.
See N-Quads Media Type for the media type
A N-Quads 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 EBNF used here is defined in XML 1.0 [EBNF-NOTATION].
Escape sequence rules are the same as Turtle
[TURTLE-TR]. However, as only the
STRING_LITERAL_QUOTE production is allowed new lines in literals MUST be escaped.
||::=||statement? (EOL statement)
Productions for terminals
It may be simple, but should still be defined.
The Internet Media Type / MIME Type for N-Quads is "application/n-quads".
It is recommended that N-Quads files have the extension ".nq" (all lowercase) on all platforms.
It is recommended that N-Quads files stored on Macintosh HFS file systems be given a file type of "TEXT".
This information that follows will be submitted to the IESG for review, approval, and registration with IANA.