RDF Test Cases

W3C Working Draft 15 November 2001

This Version:
Latest Version:
Previous Version:
Art Barstow, W3C <barstow@w3.org>
Dave Beckett, ILRT, University of Bristol <dave.beckett@bristol.ac.uk>


This document describes the RDF Test Cases deliverable for the RDF Core Working Group as defined in the WG's Charter.

Status of this Document

This section describes the status of this document at the time of its publication. Other documents may supersede this document. The latest status of this document series is maintained at the W3C.

This is a Working Draft of the RDF Core Working Group, for review by W3C members and other interested parties. This document has been produced as part of the Semantic Web Activity, and may eventually be advanced toward W3C Recommendation status.

Being a Working Draft document, this specification may be updated, replaced, or obsoleted by other documents at any time. The test cases described and referred to in this document may also be updated, replaced or obsoleted at an any time. It is therefore inappropriate to use W3C Working Drafts as reference material or to cite them as other than "work in progress". A list of current W3C working drafts can be found at http://www.w3.org/TR/.

This draft document will be considered by the W3C and its members according to W3C process. This document is made public for the purpose of receiving comments that inform the W3C membership and staff on issues likely to affect the implementation, acceptance, and adoption of RDF.

Comments should be sent to www-rdf-comments@w3.org. This is the preferred method of providing feedback. Public comments and their responses can be accessed at http://lists.w3.org/Archives/Public/www-rdf-comments/. Alternatively, if you do not wish your comments to be made public, you can send your comments to w3t-semweb-review@w3.org.

Table of Contents

1. Introduction

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 WG. This document describes the test cases that will (when the test cases are completed) fullfill that deliverable but it does not contain the test cases themselves. The test case 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 [RDFSchema] Candidate Recommendation. These issues have been collected and categorized in the RDF 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.

1.1. Scope

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.

1.2. RDF Errata

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.

2. Test Cases

The Test Case Repository is located at http://www.w3.org/2000/10/rdf-tests/rdfcore/. Each directory in the repository is devoted to a single issue. Most directories have a name that is identical to the related issue in the RDF Issue Tracking document. For example, the directory rdf-ns-prefix-confusion is identical to the rdf-ns-prefix-confusion issue. In the other cases, the directory does not have an associated issue in the issue list (e.g. amp-in-url). If a directory is empty, then no test cases have been created for the issue.

The Test Case Repository contains a ZIP file of all Approved test cases as well as a ZIP file of all Approved and Not Approved test cases .

2.1. Organization

Each test case is defined in RDF/XML. The expected result is defined using the [N-Ttriples] syntax. [N-Triples]is a line-based, plain text format for representing a RDF triple. Each RDF/XML file that contains valid RDF has an associated [N-Triples] file. The contents of the [N-Triples] files have been reviewed by the RDF Core Working Group and are considered authoritative (subject to the warnings provided in Status of this Document).

2.2. Naming Conventions

The following file name conventions are typically used:

where NNN is an integer starting with 001. The expected results or [N-Triples] file for a RDF/XML file will have the same number. For example, the [N-Triples] file for RDF/XML file test001.rdf will be test001.nt. Error files contain illegal RDF thus they do not have a corresponding [N-Triples] file.

2.3. Approved Test Cases

The test cases in the following table have been approved.

Issue Test Case Status
amp-in-url [No Issue] test001.nt Approved
amp-in-url [No Issue] test001.rdf Approved
rdf-containers-syntax-vs-schema error001.rdf Approved
rdf-containers-syntax-vs-schema test0008.rdf Approved
rdf-containers-syntax-vs-schema test001.nt Approved
rdf-containers-syntax-vs-schema test001.rdf Approved
rdf-containers-syntax-vs-schema test002.nt Approved
rdf-containers-syntax-vs-schema test002.rdf Approved
rdf-containers-syntax-vs-schema test003.nt Approved
rdf-containers-syntax-vs-schema test003.rdf Approved
rdf-containers-syntax-vs-schema test004.nt Approved
rdf-containers-syntax-vs-schema test004.rdf Approved
rdf-containers-syntax-vs-schema test005.nt Approved
rdf-containers-syntax-vs-schema test005.rdf Approved
rdf-containers-syntax-vs-schema test006.nt Approved
rdf-containers-syntax-vs-schema test006.rdf Approved
rdf-containers-syntax-vs-schema test007.nt Approved
rdf-containers-syntax-vs-schema test007.rdf Approved
rdf-containers-syntax-vs-schema test008.nt Approved
rdf-containers-syntax-vs-schema test008.rdf Approved
rdf-ns-prefix-confusion error0001.rdf Approved
rdf-ns-prefix-confusion error0002.rdf Approved
rdf-ns-prefix-confusion error0003.rdf Approved
rdf-ns-prefix-confusion error0004.rdf Approved
rdf-ns-prefix-confusion error0005.rdf Approved
rdf-ns-prefix-confusion error0006.rdf Approved
rdf-ns-prefix-confusion error0007.rdf Approved
rdf-ns-prefix-confusion error0008.rdf Approved
rdf-ns-prefix-confusion error0009.rdf Approved
rdf-ns-prefix-confusion test0001.nt Approved
rdf-ns-prefix-confusion test0001.rdf Approved
rdf-ns-prefix-confusion test0002.nt Approved
rdf-ns-prefix-confusion test0002.rdf Approved
rdf-ns-prefix-confusion test0003.nt Approved
rdf-ns-prefix-confusion test0003.rdf Approved
rdf-ns-prefix-confusion test0004.nt Approved
rdf-ns-prefix-confusion test0004.rdf Approved
rdf-ns-prefix-confusion test0005.nt Approved
rdf-ns-prefix-confusion test0005.rdf Approved
rdf-ns-prefix-confusion test0006.nt Approved
rdf-ns-prefix-confusion test0006.rdf Approved
rdf-ns-prefix-confusion test0007.nt Approved
rdf-ns-prefix-confusion test0007.rdf Approved
rdf-ns-prefix-confusion test0009.nt Approved
rdf-ns-prefix-confusion test0009.rdf Approved
rdf-ns-prefix-confusion test0010.nt Approved
rdf-ns-prefix-confusion test0010.rdf Approved
rdf-ns-prefix-confusion test0011.nt Approved
rdf-ns-prefix-confusion test0011.rdf Approved
rdf-ns-prefix-confusion test0012.nt Approved
rdf-ns-prefix-confusion test0012.rdf Approved
rdf-ns-prefix-confusion test0013.nt Approved
rdf-ns-prefix-confusion test0013.rdf Approved
rdf-ns-prefix-confusion test0014.nt Approved
rdf-ns-prefix-confusion test0014.rdf Approved
rdfms-empty-property-elements error001.rdf Approved
rdfms-empty-property-elements error002.rdf Approved
rdfms-empty-property-elements error003.rdf Approved
rdfms-empty-property-elements test001.nt Approved
rdfms-empty-property-elements test001.rdf Approved
rdfms-empty-property-elements test002.nt Approved
rdfms-empty-property-elements test002.rdf Approved
rdfms-empty-property-elements test003.nt Approved
rdfms-empty-property-elements test003.rdf Approved
rdfms-empty-property-elements test004.nt Approved
rdfms-empty-property-elements test004.rdf Approved
rdfms-empty-property-elements test005.nt Approved
rdfms-empty-property-elements test005.rdf Approved
rdfms-empty-property-elements test006.nt Approved
rdfms-empty-property-elements test006.rdf Approved
rdfms-empty-property-elements test007.nt Approved
rdfms-empty-property-elements test007.rdf Approved
rdfms-empty-property-elements test008.nt Approved
rdfms-empty-property-elements test008.rdf Approved
rdfms-empty-property-elements test009.nt Approved
rdfms-empty-property-elements test009.rdf Approved
rdfms-empty-property-elements test010.nt Approved
rdfms-empty-property-elements test010.rdf Approved
rdfms-empty-property-elements test011.nt Approved
rdfms-empty-property-elements test011.rdf Approved
rdfms-empty-property-elements test012.nt Approved
rdfms-empty-property-elements test012.rdf Approved
rdfms-empty-property-elements test013.nt Approved
rdfms-empty-property-elements test013.rdf Approved
rdfms-empty-property-elements test014.nt Approved
rdfms-empty-property-elements test014.rdf Approved
rdfms-empty-property-elements test015.nt Approved
rdfms-empty-property-elements test015.rdf Approved
rdfs-no-cycles-in-subClassOf test001.nt Approved
rdfs-no-cycles-in-subClassOf test001.rdf Approved
rdfs-no-cycles-in-subPropertyOf test001.nt Approved
rdfs-no-cycles-in-subPropertyOf test001.rdf Approved
rdfms-identity-anon-resources test001.nt Approved
rdfms-identity-anon-resources test001.rdf Approved
rdfms-identity-anon-resources test002.nt Approved
rdfms-identity-anon-resources test002.rdf Approved
rdfms-identity-anon-resources test003.nt Approved
rdfms-identity-anon-resources test003.rdf Approved
rdfms-identity-anon-resources test004.nt Approved
rdfms-identity-anon-resources test004.rdf Approved
rdfms-identity-anon-resources test005.nt Approved
rdfms-identity-anon-resources test005.rdf Approved
rdfs-domain-and-range test001.nt Approved
rdfs-domain-and-range test001.rdf Approved
rdfs-domain-and-range test002.nt Approved
rdfs-domain-and-range test002.rdf Approved

2.4. Test Cases Not 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/#not_approved .

3. N-Triples

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, n-triples2kif.pl and 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.

3.1. Extended Backus-Naur Form (EBNF) Grammar

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 statements formed from the subject, predicate and object terms. The meaning of these terms are defined in the [RDFMT] being developed as part of the RDF Core WG activity.

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 ::= '"' string '"'
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 linefeed - 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 127 */

3.2 Strings

N-Triples strings are sequences of US-ASCII character productions encoding [Unicode] character strings. The characters outside the US-ASCII range are made available by \-escape sequences as follows:

Encodes Unicode character
\\ Backslash character (decimal 92, #x5c)
\" Double quote (decimal 34, #x22)
\n Linefeed (decimal 10, #xA) - lf character
\r Carriage return (decimal 13, #xD) - cr character
\t Horizontal tab (decimal 9, #x9) - tab character
\uxxxx 4 required hexadecimal digits xxxx encoding character
\Uxxxxxxxx 8 required hexadecimal digitsxxxxxxxx encoding character

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.

It is recommended but not required that the resulting Unicode character string be made available to applications in UTF-8 encoding.

3.3 URI References

URI references are defined and encoded using the rules defined in [Charmod] section Character Encoding in URI References. That is, disallowed characters are represented in UTF-8 and then encoded using the %HH format, where HH is the byte value expressed using hexadecimal notation.

3.4. Example

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>    "Art Barstow" .
<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#"
  <rdf:Description rdf:about="http://www.w3.org/2001/08/rdf-test/">
    <dc:creator>Art Barstow</dc:creator>
    <dc:creator>Dave Beckett</dc:creator>
        <dc:title>World Wide Web Consortium</dc:title>
        <dc:source rdf:resource="http://www.w3.org/"/>


Appendix A: Future Work (Non-Normative)

Among the work that needs to be done:

Appendix B: Contributors (Non-Normative)

The following Working Group members have directly contributed to this document and/or contributed test cases.

Art Barstow W3C
Dave Beckett ILRT, University of Bristol
Jeremy Carroll Hewlett-Packard
Dan Connolly W3C
Jos DeRoo AGFA
Jan Grant ILRT, University of Bristol
Brian McBride Hewlett-Packard
Aaron Swartz HWG


Normative References

Ora Lassila, Ralph R. Swick (editors), Resource Description Framework (RDF) Model and Syntax Specification, 22 February 1999.
Dan Brickley, R.V. Guha (editors), Resource Description Framework (RDF) Schema Specification 1.0, 27 March 2000 (W3C Candidate Recommendation).
The Unicode Standard, Version 3.0, Addison Wesley, Reading MA, 2000, ISBN: 0-201-61633-5
Character Model for the World Wide Web, W3C Working Draft, 26 January 2001.
Patrick Hayes (editor), RDF Model Theory, W3C Working Draft, 25 September 2001.

Non-normative References

Tim Berners-Lee, Notation 3
Tim Berners-Lee, Primer: Getting into RDF & Semantic Web using N3

Change Log (Non-Normative)

Changes since http://www.w3.org/TR/2001/WD-rdf-testcases-20010912/

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 Non-normative.

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.

Open Issues(Non-Normative)

The following issues are open: