N-Triples
Filename extension |
.nt | |
---|---|---|
Internet media type |
application/n-triples | |
Developed by | Container for RDF data | |
Extended to | Turtle | |
Website | www |
N-Triples is a format for storing and transmitting data. It is a line-based, plain text
N-Triples was designed to be a simpler format than Notation3 and Turtle, and therefore easier for software to parse and generate. However, because it lacks some of the shortcuts provided by other RDF serialisations (such as CURIEs and nested resources, which are provided by both RDF/XML and Turtle) it can be onerous to type out large amounts of data by hand, and difficult to read.
Usage
There is very little variation in how an RDF
Implementations
As N-Triples is a subset of Turtle and Notation3, by definition all tools which support input in either of those formats will support N-Triples. In addition, some tools like Cwm have specific support for N-Triples.
File format
Each line of the file has either the form of a comment or of a statement: A statement consists of four parts, separated by
- the subject,
- the predicate,
- the object,
- a full stop which means the termination of a statement
Subjects may take the form of a
Example
The N-Triples statements below are equivalent to this RDF/XML:
- RDF/XML
<rdf:RDF xmlns="http://xmlns.com/foaf/0.1/"
xmlns:dc="http://purl.org/dc/terms/"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" >
<Document rdf:about="http://www.w3.org/2001/sw/RDFCore/ntriples/">
<dc:title xml:lang="en-US">N-Triples</dc:title>
<maker>
<Person rdf:nodeID="art">
<name>Art Barstow</name>
</Person>
</maker>
<maker>
<Person rdf:nodeID="dave">
<name>Dave Beckett</name>
</Person>
</maker>
</Document>
</rdf:RDF>
- N-Triples
<http://www.w3.org/2001/sw/RDFCore/ntriples/> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> ↵
<http://xmlns.com/foaf/0.1/Document> .
<http://www.w3.org/2001/sw/RDFCore/ntriples/> <http://purl.org/dc/terms/title> "N-Triples"@en-US .
<http://www.w3.org/2001/sw/RDFCore/ntriples/> <http://xmlns.com/foaf/0.1/maker> _:art .
<http://www.w3.org/2001/sw/RDFCore/ntriples/> <http://xmlns.com/foaf/0.1/maker> _:dave .
_:art <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
_:art <http://xmlns.com/foaf/0.1/name> "Art Barstow".
_:dave <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> .
_:dave <http://xmlns.com/foaf/0.1/name> "Dave Beckett".
(The symbol ↵ is used to indicate a place where a line has been wrapped for legibility. N-Triples do not allow lines to be wrapped arbitrarily: the line endings indicate the end of a statement.)
N-Quads
Filename extension |
.nq | |
---|---|---|
Internet media type |
application/n-quads | |
Developed by | Container for RDF data | |
Website | www |
The related N-Quads superset extends N-Triples with an optional context value at the fourth position.[6][7][8]
<http://one.example/subject1> <http://one.example/predicate1> <http://one.example/object1> <http://example.org/graph3> . # comments here
# or on a line by themselves
_:subject1 <http://an.example/predicate1> "object1" <http://example.org/graph1> .
_:subject2 <http://an.example/predicate2> "object2" <http://example.org/graph5> .
See also
References
- ^ "RDF 1.1 N-Triples". W3C Recommendation 25 February 2014. www.w3.org. Retrieved 2014-02-25.
- ^ "N-Triples". W3C RDF Core WG Internal Working Draft. www.w3.org. Retrieved 2008-02-17.
- ^ a b "RDF Test Cases - N-Triples". W3C Recommendation 10 Feb 2004. www.w3.org. Retrieved 2008-02-17.
- ^ "XML and Semantic Web W3C Standards Timeline" (PDF).
- ^ Jan Grant, Dave Beckett (2004-02-10). "RDF Test Cases / N-Triples / Strings". W3C Recommendation. W3C. Retrieved 2012-04-25.
N-Triples strings are sequences of US-ASCII character productions encoding [UNICODE] character strings. The characters outside the US-ASCII range and some other specific characters are made available by \-escape sequences as follows ...
- ^ "RDF 1.1 N-Quads". www.w3.org.
- ^ "RDF 1.1 N-Quads". www.w3.org.
- ^ "Archived copy". Archived from the original on 2013-04-26. Retrieved 2013-04-26.
{{cite web}}
: CS1 maint: archived copy as title (link)