New Version Available: "RDF 1.1 Test Cases" (Document Status Update, 25 February 2014)
The RDF Working Group has produced a W3C Recommendation for a new version of RDF which adds features to this 2004 version, while remaining compatible. Please see "RDF 1.1 Test Cases" for a new version of this document, and the "What's New in RDF 1.1" document for the differences between this version of RDF and RDF 1.1.
Please refer to the errata for this document, which may include some normative corrections.
See also translations.
Copyright © 2004 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C liability, trademark, document use and software licensing rules apply.
This document describes the RDF Test Cases deliverable for the RDF Core Working Group as defined in the Working Group's Charter.
This document has been reviewed by W3C Members and other interested parties, and it has been endorsed by the Director as a W3C Recommendation. W3C's role in making the Recommendation is to draw attention to the specification and to promote its widespread deployment. This enhances the functionality and interoperability of the Web.
This is one document in a set of six (Primer, Concepts, Syntax, Semantics, Vocabulary, and Test Cases) intended to jointly replace the original Resource Description Framework specifications, RDF Model and Syntax (1999 Recommendation) and RDF Schema (2000 Candidate Recommendation). It has been developed by the RDF Core Working Group as part of the W3C Semantic Web Activity (Activity Statement, Group Charter) for publication on 10 February 2004.
Changes to this document since the Proposed Recommendation Working Draft are detailed in the change log.
The public is invited to send comments to www-rdf-comments@w3.org (archive) and to participate in general discussion of related technology on www-rdf-interest@w3.org (archive).
A list of implementations is available.
The W3C maintains a list of any patent disclosures related to this work.
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/.
One of the deliverables specified in Charter of the RDF Core Working Group is: a set of machine-processable test cases corresponding to technical issues addressed by the Working Group. This document describes the test cases that fulfill that deliverable but it does not contain the test cases themselves. The test cases are available at http://www.w3.org/2000/10/rdf-tests/rdfcore/.
The RDF Interest Group and other members of the RDF community have identified issues/ambiguities in the [RDFMS] Specification and the [RDF-SCHEMA] Candidate Recommendation. These issues have been collected and categorized in the RDF Core Working Group Issue Tracking document. The RDF Core Working Group uses this issue list to guide its work. The issues list is a working document; it is updated as new issues are identified. It is updated as the Working Group makes decisions as documented in the Attention Developers section of the document.
The complete specification of RDF consists of a number of documents:
A comprehensive and complete test suite for RDF should cover all of the rules in the Formal Grammar for RDF. The Working Group, however, is not chartered to deliver such a test suite but rather to create test cases for the issues the Working Group addresses (when applicable). Although the Working Group will not create test cases for some grammar rules (e.g. rule [6.1]), if such test cases are donated to the W3C the Consortium may add such test cases to this set of test cases.
The RDF Errata documents known errors in [RDFMS]. Since errata are considered normative changes to a W3C Specification and Working Group decisions are not normative until a specification is a W3C Recommendation, none of the decisions made by the RDF Core Working Group have (to date) been reflected in the errata.
The Test Case Repository [REPOSITORY] contains subdirectories, each containing test cases devoted to a single issue. Each directory contains a manifest file describing the tests in that directory. Where an issue originated with the RDF Issue Tracking process [ISSUES], the manifest will indicate this fact.
The Test Case Repository contains ZIP files of all Approved test cases [APPROVED] as well as a ZIP archive of all Approved and Not Approved test cases [FULLTESTS]
The Manifest file [MANIFEST] contains a machine-readable manifest of the test cases. The format of this file is described below.
The manifest file [MANIFEST] contains a machine-readable description of the test cases in RDF/XML. Care has been taken to ensure that this file follows a simple format to assist in machine-processing the test cases.
The file consists of a simple header [MANIFEST-HEAD], individual descriptions of the test cases, and a closing footer [MANIFEST-TAIL].
The test cases are divided into the following categories:
<test:PositiveParserTest rdf:about="http://w3.example.org/test001"> <test:issue rdf:resource="http://w3.example.org/rdf-tracking/#example1" /> <test:status>APPROVED</test:status> <test:approval rdf:resource="http://rdfcore.example.org/archives/001.html" /> <test:description> This is a simple positive parser test example. </test:description> <test:inputDocument> <test:RDF-XML-Document rdf:about="http://w3.example.org/test001.rdf" /> </test:inputDocument> <test:outputDocument> <test:NT-Document rdf:about="http://w3.example.org/test001.nt" /> </test:outputDocument> <test:warning>Some parsers may produce a warning when running this test</test:warning> </test:PositiveParserTest>
<test:NegativeParserTest rdf:about="http://w3.example.org/error001"> <test:issue rdf:resource="http://w3.example.org/rdf-tracking/#example1" /> <test:status>APPROVED</test:status> <test:inputDocument> <test:RDF-XML-Document rdf:about="http://w3.example.org/error001.rdf" /> </test:inputDocument> </test:NegativeParserTest>
<test:entailmentRules rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#" />then the test succeeds if the entailment holds according to the rules of RDF-entailment as specified in [RDF-SEMANTICS]. If the following two elements are present
<test:entailmentRules rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#" /> <test:entailmentRules rdf:resource="http://www.w3.org/2000/01/rdf-schema#" />then the test succeeds if the entailment holds according to the rules of RDFS-entailment as specified in [RDF-SEMANTICS]. For test cases that use simple entailment, the following marker is used:
<test:entailmentRules rdf:resource="http://www.w3.org/2000/10/rdf-tests/rdfcore/testSchema#simpleEntailment" />
<test:PositiveEntailmentTest rdf:about="http://w3.example.org/rdfs-domain-and-range/conjunction-test"> <test:description> This test demonstrates the conjunctive nature of range and domain. </test:description> <test:entailmentRules rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#" /> <test:entailmentRules rdf:resource="http://www.w3.org/2000/01/rdf-schema#" /> <test:premiseDocument> <test:NT-Document rdf:about="http://w3.example.org/rdfs-domain-and-range/test001.nt" /> </test:premiseDocument> <test:premiseDocument> <test:NT-Document rdf:about="http://w3.example.org/rdfs-domain-and-range/test002.nt" /> </test:premiseDocument> <test:premiseDocument> <test:NT-Document rdf:about="http://w3.example.org/rdfs-domain-and-range/test003.nt" /> </test:premiseDocument> <test:conclusionDocument> <test:NT-Document rdf:about="http://w3.example.org/rdfs-domain-and-range/test004.nt" /> </test:conclusionDocument> </test:PositiveEntailmentTest>
According to [RDF-SEMANTICS], a premise document that contains a semantic error with respect to any constraints imposed by the entailment rules selected will be false in any interpretation (and hence entail anything).
Support for such situations is provided by the manifest format by declaring an premise or conclusion pseudo-document as follows:
<test:conclusionDocument> <test:False-Document/> </test:conclusionDocument>
By convention, such a pseudo-document is said to come out false under any interpretation.
<test:NegativeEntailmentTest rdf:about="http://w3.example.org/statement-entailment/test001"> <test:status>PENDING</test:status> <test:approval rdf:resource="http://rdfcore.example.org/Archives/Public/w3c-rdfcore-wg/2002Feb/0476.html" /> <test:description> RDF Core WG RESOLVED that a reified statement was a stating, not a statement. The following entailment does not, therefore, hold. </test:description> <test:entailmentRules rdf:resource="http://www.w3.org/1999/02/22-rdf-syntax-ns#" /> <test:entailmentRules rdf:resource="http://www.w3.org/2000/01/rdf-schema#" /> <test:premiseDocument> <test:NT-Document rdf:about="http://w3.example.org/statement-entailment/test001a.nt" /> </test:premiseDocument> <test:conclusionDocument> <test:NT-Document rdf:about="http://w3.example.org/statement-entailment/test001b.nt" /> </test:conclusionDocument> </test:NegativeEntailmentTest>
<test:entailmentRules rdf:resource="http://www.w3.org/2000/10/rdf-tests/rdfcore/datatypes#" /> <test:datatypeSupport rdf:resource="http://www.w3.org/2001/XMLSchema#integer" /> <test:datatypeSupport rdf:resource="http://dt.example.org/datatype#foo" />For the purposes of the test suite, if a test case requires datatype support for a set of datatypes, { T, U, V, ... } then the following three pieces of machinery are required:
<test:MiscellaneousTest rdf:about="http://w3.example.org/misc001"> <test:status>PENDING</test:status> <test:description> A serializer asked to output the graph described in the test001 document should raise an exception since it cannot be described using RDF/XML. </test:description> <test:document> <test:NT-Document rdf:about="http://w3.example.org/nonserializable/test001.nt" /> </test:document> </test:MiscellaneousTest>
In addition, each test case description may have the following common attributes:
<test:issue rdf:resource="http://www.w3.org/2000/03/rdf-tracking/#rdfs-no-cycles-in-subClassOf" />
<test:status>APPROVED</test:status>
<test:approval rdf:resource="http://lists.w3.org/Archives/Public/w3c-rdfcore-wg/2002Feb/0476.html" />
<test:discussion rdf:resource="http://rdfcore.example.org/" />
<test:description> Text describing the test case goes here. </test:description>
<test:warning> Text describing the warning goes here. </test:warning>
The test cases in the following table have been approved.
The test case repository contains test cases that have not been approved. Such test cases are not enumerated in this document but a list of them is available at http://www.w3.org/2000/10/rdf-tests/rdfcore/allTestCases.html.
The test case manifest format was deliberately chosen to be a simple, declarative description of the test cases. Parser tests can be run in conjunction with simple tools such as ntc[NTC]. A parser should pass all the positive parser tests, and reject all the negative parser tests. Tools like Euler [EULER] have been used to run the entailment tests.
Due to the rules of entailment tests, a positive or negative entailment test case with an empty conclusion document can be used to illustrate semantic constraints associated with sets of entailment rules.
The test cases have been created to illustrate the resolution of particular issues on the RDF Issue Tracking list. Consequently, test case results should always be interpreted in conjunction with the resolution of the associated issue and the description (if any) attached to the test case in the manifest.
N-Triples is a line-based, plain text format for encoding an RDF graph. It was designed to be a fixed subset of N3[N3] [N3-Primer] and hence N3 tools such as cwm [CWM], n-triples2kif [N-TRIPLES2KIF], and Euler [EULER] can be used to read and process it. cwm can output this format when invoked as "cwm -ntriples".
It is recommended, but not required, that N-Triples content is stored in files with an '.nt' suffix to distinguish them from N3.
The Internet media type / MIME type of N-Triples is text/plain and the character encoding is 7-bit US-ASCII.
NOTE: N-Triples is an RDF syntax for expressing RDF test cases and defining the correspondence between RDF/XML and the RDF abstract syntax. RDF/XML [RDF-SYNTAX] is the recommended syntax for applications to exchange RDF information.
An N-Triples document is a sequence of US-ASCII characters and is defined by the ntripleDoc grammar term below. Parsing it results in a sequence of RDF triples formed from the subject, predicate and object productions.
This EBNF is the notation used in XML 1.0 second edition
ntripleDoc | ::= | line* | |
line | ::= | ws* ( comment | triple )? eoln | |
comment | ::= | '#' ( character - ( cr | lf ) )* | |
triple | ::= | subject ws+ predicate ws+ object ws* '.' ws* | |
subject | ::= | uriref | nodeID | |
predicate | ::= | uriref | |
object | ::= | uriref | nodeID | literal | |
uriref | ::= | '<' absoluteURI '>' | |
nodeID | ::= | '_:' name | |
literal | ::= | langString | datatypeString | |
langString | ::= | '"' string '"' ( '@' language )? | |
datatypeString | ::= | '"' string '"' '^^' uriref | |
language | ::= | [a-z]+ ('-' [a-z0-9]+ )* encoding a language tag. |
|
ws | ::= | space | tab | |
eoln | ::= | cr | lf | cr lf | |
space | ::= | #x20 /* US-ASCII space - decimal 32 */ | |
cr | ::= | #xD /* US-ASCII carriage return - decimal 13 */ | |
lf | ::= | #xA /* US-ASCII line feed - decimal 10 */ | |
tab | ::= | #x9 /* US-ASCII horizontal tab - decimal 9 */ | |
string | ::= | character* with escapes as defined in section Strings | |
name | ::= | [A-Za-z][A-Za-z0-9]* | |
absoluteURI | ::= | character+ with escapes as defined in section URI References | |
character | ::= | [#x20-#x7E] /* US-ASCII space to decimal 126 */ |
These productions encode concepts defined in the RDF Concepts and Abstract Syntax [RDF-CONCEPTS] working draft as follows:
N-Triples production | RDF Concept encoded |
---|---|
triple | triple |
subject | subject |
predicate | predicate |
object | object |
absoluteURI | RDF URI reference |
nodeID | Identifier for a blank node |
langString | plain literal |
datatypeString | typed literal |
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:
Unicode character (with code point u) |
N-Triples encoding |
---|---|
[#x0-#x8] | \uHHHH 4 required hexadecimal digits HHHH encoding Unicode character u |
#x9 | \t |
#xA | \n |
[#xB-#xC] | \uHHHH 4 required hexadecimal digits HHHH encoding Unicode character u |
#xD | \r |
[#xE-#x1F] | \uHHHH 4 required hexadecimal digits HHHH encoding Unicode character u |
[#x20-#x21] | the character u |
#x22 | \" |
[#x23-#x5B] | the character u |
#x5C | \\ |
[#x5D-#x7E] | the character u |
[#x7F-#xFFFF] | \uHHHH 4 required hexadecimal digits HHHH encoding Unicode character u |
[#10000-#x10FFFF] | \UHHHHHHHH 8 required hexadecimal digits HHHHHHHH encoding Unicode character u |
where H is a hexadecimal digit: [#x30-#x39],[#x41-#x46] (0-9, uppercase A-F).
This escaping satisfies the [CHARMOD] section Reference Processing Model on making the full Unicode character range U+0 to U+10FFFF available to applications and providing only one way to escape any character.
The absoluteURI production encodes a Unicode string representing an RDF URI references as specified in [RDF-CONCEPTS]. These are encoded in N-Triples using the escapes described in section Strings.
The following N-Triples file:
<http://www.w3.org/2001/08/rdf-test/> <http://purl.org/dc/elements/1.1/creator> "Dave Beckett" . <http://www.w3.org/2001/08/rdf-test/> <http://purl.org/dc/elements/1.1/creator> "Jan Grant" . <http://www.w3.org/2001/08/rdf-test/> <http://purl.org/dc/elements/1.1/publisher> _:a . _:a <http://purl.org/dc/elements/1.1/title> "World Wide Web Consortium" . _:a <http://purl.org/dc/elements/1.1/source> <http://www.w3.org/> .
represents the same RDF graph as the following RDF/XML:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/"> <rdf:Description rdf:about="http://www.w3.org/2001/08/rdf-test/"> <dc:creator>Jan Grant</dc:creator> <dc:creator>Dave Beckett</dc:creator> <dc:publisher> <rdf:Description> <dc:title>World Wide Web Consortium</dc:title> <dc:source rdf:resource="http://www.w3.org/"/> </rdf:Description> </dc:publisher> </rdf:Description> </rdf:RDF>
The N-Triple test file at http://www.w3.org/2000/10/rdf-tests/rdfcore/ntriples/test.nt contains multiple tests of legal N-Triples.
Many thanks to Art Barstow (ex-W3C), former main editor of this document, for his sterling work on editing and managing the RDF test cases, which he had been doing well before the RDF Core WG started.
The editors would also like to thank Jos DeRoo, of AGFA, for his excellent work in the implementation of an RDF reasoner capable of running the entailment test cases.
Thanks are also due to the RDF parser implementers who took the time to run, and submit corrections to, our parser tests.
The following Working Group members have directly contributed to this document and/or contributed test cases.
This document is a product of extended deliberations by the RDF Core Working Group, whose members have included: Art Barstow (W3C) Dave Beckett (ILRT), Dan Brickley (W3C/ILRT), Dan Connolly (W3C), Jeremy Carroll (Hewlett Packard), Ron Daniel (Interwoven Inc), Bill dehOra (InterX), Jos De Roo (AGFA), Jan Grant (ILRT), Graham Klyne (Clearswift and Nine by Nine), Frank Manola (MITRE Corporation), Brian McBride (Hewlett Packard), Eric Miller (W3C), Stephen Petschulat (IBM), Patrick Stickler (Nokia), Aaron Swartz (HWG), Mike Dean (BBN Technologies / Verizon), R. V. Guha (Alpiri Inc), Pat Hayes (IHMC), Sergey Melnik (Stanford University), Martyn Horner (Profium Ltd).
This specification also draws upon an earlier RDF Model and Syntax document edited by Ora Lassilla and Ralph Swick, and RDF Schema edited by Dan Brickley and R. V. Guha. RDF and RDF Schema Working group members who contributed to this earlier work are: Nick Arnett (Verity), Tim Berners-Lee (W3C), Tim Bray (Textuality), Dan Brickley (ILRT / University of Bristol), Walter Chang (Adobe), Sailesh Chutani (Oracle), Dan Connolly (W3C), Ron Daniel (DATAFUSION), Charles Frankston (Microsoft), Patrick Gannon (CommerceNet), RV Guha (Epinions, previously of Netscape Communications), Tom Hill (Apple Computer), Arthur van Hoff (Marimba), Renato Iannella (DSTC), Sandeep Jain (Oracle), Kevin Jones, (InterMind), Emiko Kezuka (Digital Vision Laboratories), Joe Lapp (webMethods Inc.), Ora Lassila (Nokia Research Center), Andrew Layman (Microsoft), Ralph LeVan (OCLC), John McCarthy (Lawrence Berkeley National Laboratory), Chris McConnell (Microsoft), Murray Maloney (Grif), Michael Mealling (Network Solutions), Norbert Mikula (DataChannel), Eric Miller (OCLC), Jim Miller (W3C, emeritus), Frank Olken (Lawrence Berkeley National Laboratory), Jean Paoli (Microsoft), Sri Raghavan (Digital/Compaq), Lisa Rein (webMethods Inc.), Paul Resnick (University of Michigan), Bill Roberts (KnowledgeCite), Tsuyoshi Sakata (Digital Vision Laboratories), Bob Schloss (IBM), Leon Shklar (Pencom Web Works), David Singer (IBM), Wei (William) Song (SISU), Neel Sundaresan (IBM), Ralph Swick (W3C), Naohiko Uramoto (IBM), Charles Wicksteed (Reuters Ltd.), Misha Wolf (Reuters Ltd.), Lauren Wood (SoftQuad).
Added explicit simple entailment marker to entailment tests.
Reworded the pass and failure criteria for negative entailment tests according to suggested wording from Pat Hayes.
Added test case for RDF/XML without an enclosing rdf:RDF element (rdf-element-not-mandatory/test001).
Removed N-Triples reference to language tags and RFC3066, use the RDF concepts definition. A language tag cannot start with a digit.
Added test cases for intensional interpretation of datatypes.
Added test case: plain literals and xsd:string denotations overlap.
Editorial change. The caption on the test case table now makes it clear that it refers only to the resolution of relative URLs within the table.
Editorial change. Updated section 3. N-Triples NOTE on the purpose of N-Triples to say it is used to map abstract RDF syntax and RDF/XML.
Terminological change. Updated section 2.1. Organization To use the more acceptable term, "graph equivalence".
Substantive change. Updated section 2.1. Organization to include fourth condition for datatype support when describing datatype entailment tests.
Editorial change. Updated references throughout to remove URLs from prose; additional changes as suggested by Susan Lesch.
Editorial change. Updated section 3.1. Extended Backus-Naur Form (EBNF) Grammar to add a new table showing how the N-Triples productions encode the respective RDF concepts from [RDF-CONCEPTS].
Editorial change. Updated section 3.3 URI References to say less about URI detail and defer to [RDF-CONCEPTS]. Removed reference to RFC2396 (URIs). Made after comment by Duerst, 2003-05-08 as outlined. Also addresses comment by Patel-Schneider, 2003-05-30.
Editorial change. Updated section 3.2 Strings and the N-Triples escape sequence table to list the encodings from Unicode character to N-Triples. Made after comment by Patel-Schneider, 2003-05-27 as outlined.
Substantive change. Updated datatypeString to use string rather than langString after removal of language tag from all typed literals as approved in RDF Core telcon 2003-05-09.
Entailment test definitions changed to actually test proper entailments, not pseudo-entailments.
Support for datatype-aware entailment tests in the manifest.
Pointer to RDF-CONCEPTS for the definition of graph isomorphism / equality.
Addition of the always false pseudo-document for entailment tests.
Updated the test case list in this document.
Test case names changed to fragment references into individual manifest documents.
Production language. Changed to match RFC 3066. Added [RFC 2396] to normative references.
3 N-Triples NOTE reworded. Point to RDF/XML as exchange syntax.
Production character: should be "to 126"
3.2 Strings Removed suggestion to use UTF-8 for apps.
Added 3.5. N-Triples Tests pointing at the http://www.w3.org/2000/10/rdf-tests/rdfcore/ntriples/test.nt test file.
Use uppercase hexadecimal digits. Define H and use it for \uHHHH, \uHHHHHHHH.
Removed xmlString.
Changed the N-Triples language separator token to @ in langString
Added RDF datatyping support using datatypeString using the form ^^<datatypeURI>
Updated 3.3 URI References to allow Unicode characters in URIs
Merged Future Work into Open Issues
Test case list expanded and reorganized to reflect additional approved test cases
New section 2 describing organization of parser tests, the types of tests and examples of manifest format that describes them.
Updated editors, added thanks to Art Barstow.
Changed literal to be langString | xmlString (now gone)
N-Triples remains an ASCII format for now - closed issue on UTF-8 encoding.
Update references to RDF Model Theory, Syntax WDs
Changed the Approved Test Cases table so that it includes links to related files and the Working Group decision.
Removed the Test Cases Not Approved table and added a link to the repository's list of the not approved test cases.
Added links to ZIP files of the repository's test cases.
Specify the Future Work and Contributors sections as Informative.
Renamed token bNode to nodeID.
Added RDF Model Theory reference.
Added URI Encoding section, pointing at Charmod rules and updated absoluteURI grammar rule to use it.
Removed references to Python literals, reason for \-escaping.
Added 4, 8 required digits for \u, \U string escapes.
Renamed section URIs to URI References.