W3C

Editors version of RDF/XML Syntax Specification (Revised)

Editors version of W3C Working Draft XX Month 2002

This version:
http://ilrt.org/discovery/2001/07/rdf-syntax-grammar/
$Revision: 1.269 $
Latest W3C version:
http://www.w3.org/TR/rdf-syntax-grammar
Previous versions:
http://www.w3.org/TR/2002/WD-rdf-syntax-grammar-20020325
CVS history
Editor:
Dave Beckett (University of Bristol)

Abstract

This specification defines an XML syntax for the Resource Description Framework (RDF) as amended and clarified by the RDF Core Working Group from that originally described in RDF Model & Syntax. The syntax is updated to be specified in terms of XML, XML Namespaces, the XML Information Set with new support for XML Base. It specifies the RDF graph, the abstract syntax for all RDF documents. For each part of the RDF/XML syntax, it defines the mapping rules for generating the RDF graph as defined in the RDF Model Theory. This is done using the N-Triples graph serializing test format which enables more precise recording of the mapping in a machine processable and testable form. These tests are gathered and published in the RDF Test Cases.

Status of this Document

This is the editors version of a W3C RDF Core Working Group Working Draft produced as part of the W3C Semantic Web Activity (Activity Statement). It incorporates decisions made by the Working Group updating the XML syntax for RDF from the original RDF Model & Syntax [RDF-MS] document in terms of the XML Information Set [INFOSET] including new support in this draft for XML Base [XML-BASE].

This document is being released for review by W3C Members and other interested parties to encourage feedback and comments, especially with regard to how the changes affect existing implementations and content. The current state is that it represents the majority of the syntax as described in the grammar section of the original document, with some removed parts (see rdfms-abouteach) and the mapping to the RDF graph is considered complete. The detailed changes from the previous 18 December 2001 draft are described in the Changes section however the main changes are as follows: the completion of the rules for generating the graph for rdf:bagID, handling xml:lang with literals, handling XML Literals (not yet complete), the addition of XML Base support, an updated introduction with new examples and other changes after RDF Core Working Group decisions made since the last draft.

This is a public W3C Working Draft and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use W3C Working Drafts as reference material or to cite as other than "work in progress". A list of current W3C Recommendations and other technical documents can be found at http://ilrt.org/TR/.

Comments on this document are invited and should be sent to the public mailing list www-rdf-comments@w3.org. An archive of comments is available at http://lists.w3.org/Archives/Public/www-rdf-comments/.

Table of contents

1 Introduction
2 The RDF Graph
  2.1 URI References
  2.2 String Literals
  2.3 XML Literals
  2.4 Nodes
  2.5 RDF Triples
  2.6 The Graph
  2.7 Graph Equality

2 An XML syntax for RDF
3 Data Model
  3.1 Nodes
  3.2 Information Set Mapping
  3.3 RDF MIME type, file extension and Macintosh file type
  3.4 The RDF Namespace
  3.5 Identifiers
  3.6 Base URIs
4 Notation
  4.1 Terminology
  4.2 Grammar Notation
5 RDF/XML Grammar
  5.0 Grammar Summary
  5.1 Grammar start ... 5.25 rdf-id
  5.26 Reification Rules
  5.27 List Expansion Rules
  5.28 Bag Expansion Rules
6 Serializing an RDF Graph to RDF/XML
7 Acknowledgments
8 References

Appendices

A Issues affecting RDF/XML Syntax (Non-Normative)
  A.1 Document Issues / Tasks (Non-Normative)
  A.2 RDF Core Working Group Open Issues affecting RDF/XML Syntax (Non-Normative)
  A.3 RDF Core Working Group Decided Issues affecting RDF/XML Syntax (Non-Normative)
  A.4 RDF Core Working Group Postponed Issues affecting RDF/XML Syntax (Non-Normative)
B Syntax Schemas (Non-Normative)
  B.1 RELAX NG Syntax Schema (Non-Normative)
  B.2 Other Syntax Schemas (Non-Normative)
C Changes (Non-Normative)


1 Introduction

This document describes the XML [XML] syntax for RDF as originally defined in the RDF Model & Syntax [RDF-MS] W3C Recommendation. Subsequent implementations of this syntax and comparison of the resulting RDF graphs have shown that there was ambiguity - implementations generated different graphs and certain syntax forms were not widely implemented. These issues were generally made as either feedback to the www-rdf-comments@w3.org (archive) or from discussions on the RDF Interest Group list www-rdf-interest@w3.org (archive) .

The RDF Core Working Group is chartered to respond to the need for a number of fixes, clarifications and improvements to the specification of RDF's abstract graph and XML syntax. The Working Group invites feedback from the developer community on the effects of its proposals on existing implementations and documents.

Several decisions including amendments and deletions to the grammar are referred to below. The definitive record of the decisions is the RDF Core Working Group issues list.

This document re-represents the original EBNF grammar in terms of the XML Information Set [INFOSET] items which moves from the rather low-level details, such as particular forms of empty elements. This allows the grammar to be more precisely recorded and the mapping from the XML syntax to the RDF graph more clearly shown. The mapping to the RDF graph is done by emitting statements in the form defined in the N-Triples section of RDF Test Cases [RDF-TESTS] Working Draft which creates an RDF graph, that has semantics defined by RDF Model Theory [RDF-MODEL] Working Draft.

This document illustrates one way to create the N-Triples from the XML - any other method that results in the same N-Triples (RDF graph) may be used.

In particular:

2 The RDF Graph

This section gives a formal definition of the RDF graph. The RDF graph is sometimes referred to as the (data) model of RDF (see the RDF Primer [RDF-PRIMER], and RDF Model & Syntax [RDF-MS]). It can also be thought of as the abstract syntax for RDF. In brief, the RDF graph is a directed graph with labelled edges and partially labelled nodes.

A goal of this section is the precise definition of equality between RDF graphs. This benefits interoperability (two conformant implementations are more likely to be practically interoperable if they have a precise conception of the way in which they are the same). It is required for the specification of the RDF Test Cases [RDF-TESTS], which depend on equality of RDF graphs for their execution. It is required by the RDF Model Theory [RDF-MODEL] which assigns the same meaning to any pair of equal RDF graphs.

Note: Many RDF applications and frameworks do not need to implement RDF graph equality. They do need to respect equality when assigning meaning to RDF graphs. RDF recommendations do not define conformance or compliance levels.

The specification of the RDF graph commences with the labels used in the graph. These can be URI references, string literals, or XML literals. For each sort of label, equality is defined.

This section then specifies a set of nodes used to construct an RDF graph; followed by the arcs (more fondly known as triples) used in the graph. For each of these, equality is defined.

The last two subsections formally define the graph and graph equality respectively.

2.1 URI References

Within the RDF graph, the basis for URI references is the lexical space of the anyURI datatype as defined in [XML Schema Part 2: Datatypes]. This is further constrained to relate to an absolute rather than a relative URI reference, and to be in Unicode Normal Form C [NFC] in conformance with [CHARMOD].

Precisely, an RDF URI Reference is a Unicode string [UNICODE] that is in Normal Form C [NFC] such that if disallowed characters were escaped according to the percent escaping algorithm below it would produce a US-ASCII string that is an absolute URI reference as defined by Uniform Resource Identifiers (URI) [URIS] as modified by [RFC-2732].

The disallowed characters that must be escaped include all non-ASCII characters, plus the excluded characters listed in Section 2.4 of [URIS], except for the number sign (#) and percent sign (%) characters and the square bracket characters re-allowed in [RFC-2732]. Disallowed characters must be escaped as follows:

  1. Each disallowed character is converted to UTF-8 [IETF RFC 2279] as one or more bytes.

  2. Any bytes corresponding to a disallowed character are escaped with the URI escaping mechanism (that is, converted to %HH, where HH is the hexadecimal notation of the byte value).

  3. The original character is replaced by the resulting character sequence.

Two RDF URI reference are equal if and only if they compare as equal, character by character, as Unicode strings.

An RDF URI reference is not equal to either a string literal nor an XML literal.

@@@ which test cases charmod-uri @@@

Test: Indicated by test001.rdf and test001.nt

Test: Indicated by test004.rdf and test004.nt

2.2 String Literals

A string literal is a string paired with a language tag.

RDF uses language identifiers that are possible legal value for xml:lang as specified by section 2.12 Language Identification in [XML]. Equality of language identifiers (as specified in [RFC-3066]) is defined by case insensitive character by character comparison.

Note: This direct comparison between language identifiers is appropriate for the purpose of defining equality between RDF graphs, but is linguistically naive. [RFC-3066] also suggests more advanced comparison techniques, which are generally more appropriate.

An RDF string literal is composed of a Unicode string [UNICODE] that is in Normal Form C [NFC] and a language tag that is either null or as specified above.

Two RDF string literals are equal if both components are equal. The Unicode string components are compared on a character by character basis. The language tag components are equal if both are null or if both are defined and equal as language identifiers.

Note: This is compatible with the early uniform normalization processing model of [CHARMOD].

Note: String literals with Unicode string components beginning with a composing character (as defined by [CHARMOD]) are allowed however they may cause interoperability problems, particularly with XML version 1.1 [XML 1.1].

@@@ which test cases charmod-litral @@@

Test: Indicated by test001.rdf and test001.nt

Test: Indicated by test004.rdf and test004.nt

2.3 XML Literals

An XML literal in an RDF graph is composed of a Unicode string [UNICODE] (the XML content) paired with a language tag. The XML content can be used to form an XML document by enclosing it with <tag> and </tag> and encoding the resulting string in UTF-8. No escaping is applied in this process. This resulting document is a well-formed XML document [XML] that also conforms to XML Namespaces [XML-NS]. The language tag is either null or as specified above for RDF string literals.

@@@ links to XML Namespaces and 1.1 specs @@@

Thus, the XML content of an XML literal is self-contained in the sense that any namespaces prefixes used within it must be defined within it, and the only entity references permitted are those to the predefined entities.

Note: If compatibility with XML version 1.1 is desired, then XML fragments in RDF graphs must be restricted to those that are fully normalized according to [XML 1.1].

Two XML literals are equal if both components are equal. The comparison between the XML content components is defined below. The language tag components are equal if both are null or if both are defined and equal as language identifiers.

2.3.1 Equality between XML Content Components

The precise definition of equality between the XML content of two XML literals is implementation dependent.

The definition given here is used by the RDF Test Cases [RDF-TESTS] and also constrains any implementation defined equality.

To compare the XML content of two XML literals perform the following steps:

  1. Form an XML document from each XML content string by enclosing it with <tag> and </tag> and encoding the resulting string in UTF-8.
  2. Take the exclusive canonicalization without comments [XC14N] of the element content of the root element of each document. (This is referred to as the canonical form of the XML Literal).
  3. Compare the two resulting UTF-8 strings byte by byte.

Implementations may specialize this definition of equality (i.e. if two XML literals compare equal according to an implementation then they must compare equal according to this definition, but not conversely).

In particular, implementations may treat XML comments as significant, and may treat namespaces that are in scope but not visibly utilized (as defined by [XC14N]) as significant.

@@@@ should this para be moved to a longer non-normative appendix which would have the goal of showing the DPH that they can do nearly nothing and still conform with this rather opaque requirement. @@@@

The use of character by character equality between XML fragments is discouraged, except in the case where XML fragments have already been canonicalized with an appropriate treatment of namespaces.

Note: This specification uses canonicalization in the definition of equality rather than requiring canonicalization on input to clarify that implementations that do not wish to implement equality do not need to use a canonicalization library.

@@@ would a test case showing where naivity is insuifficient be helpful, it would contain two character-by-character identical XML fragments which had qnames with namespace prefixes bound to different namespaces @@@

@@@ which test cases xml-literal @@@

Test: Indicated by test001.rdf and test001.nt

Test: Indicated by test004.rdf and test004.nt

2.4 RDF Literals

An RDF literal is either an XML literal or a string literal.

Two RDF literals are equal if and only if they are either both XML literals and equal or both string literals and equal.

2.5 Nodes

@@@ The term node is used in this doc as both a concept within the graph and a different concept within the grammar. Should we change to using the word "vertex" for the graph node. @@@

An RDF graph is defined using sets of nodes. Many of the nodes are blank, and some of the nodes are labelled with RDF literals or RDF URI references.

A tidy set of nodes is one in which no two nodes have equal labels. A tidy set of nodes may have any number of distinct blank nodes.

Two nodes are equal if and only if they are the same node. In particular, two different blank nodes are not equal.

2.6 RDF Triples

An RDF triple consists of a node called the subject, an RDF URI reference called the predicate, and a node called the object.

The predicate is often referred to as the property of the triple.

The set consisting of the two nodes of a triple is tidy.

@@@ do we want to add the literals as subjects issues to the list and reference from here @@@

The subject must not be labelled with an RDF literal.

Two RDF triples are equal if and only if their subjects are equal, their predicates are equal, and their objects are equal.

2.7 The Graph

An RDF graph is a set of RDF triples.

The nodes of an RDF graph is the set of nodes that are either subject or object of some triple in the graph.

The nodes of an RDF graph is a tidy set of nodes.

The triples may be referred to as the arcs of the RDF graph.

Note: The definition of an RDF graph diverges from the definition of a directed graph in a standard text such as @@@ missing ref @@@ in that: (a) all nodes must be in at least one arc; (b) all the arcs are labelled; (c) some of the nodes are labelled; (d) labels on nodes are required to be distinct; (e) some labels are shared between nodes and arcs.

2.8 Graph Equality

Two RDF graphs are equal if and only if they are isomorphic.

An RDF graph isomorphism is a directed graph isomorphism that respects the labels on both arcs and nodes.

An RDF Graph isomorphism I between two graphs G and G' is a bijection between the nodes of G and the nodes of G', such that:

for all nodes n, s, o in G and all RDF URI references p.

@@@@ I note that I have used a system of typed objects with identity and with named components without introducing or defining it. (Notice that an XML Literal xml"foo"-"en" is distinct from a String Literal "foo"-"en"). Personally I think that introducing and defining such a system will confuse more than enlighten. I could be persuaded ...

2 An XML syntax for RDF

The RDF Model Theory [RDF-MODEL] provides a formal description of RDF. This can be thought of as a graph consisting of nodes and arcs. The nodes can be labeled with URIs, literals or are blank and denote resources. The arcs connect the nodes and are all labeled with URIs. This graph is more precisely called a directed edge-labeled graph; each edge is an arc with a direction (an arrow) connecting two nodes. These edges can be described as triples of subject node, at the blunt end of the arrow/arc, property arc and an object node at the sharp end of the arrow/arc. The property arc can also be also interpreted as either a relationship between two resources or as defining an attribute value (object node) for some resource subject node. .

In order to encode the RDF graph in XML, the nodes and arcs are turned into XML elements, attributes, element content and attribute values. The URI labels for properties and object nodes are written in XML via XML Namespaces [XML-NS] which gives a namespace URI for a short prefix along with namespace-qualified elements and attributes names called local names. The (namespace URI, local name) pair are chosen such that concatenating them forms the original node URI. The URIs labeling subject and object nodes are stored in XML attribute values. The nodes labeled by string literals (which are always object nodes) become element text content or attribute values.

This transformation turns paths in the graph of the form Node, Arc, Node, Arc, Node, Arc, ... into sequences of elements inside elements. This results in a striping when the elements are written down; alternating between node elements and property elements. The Node at the start of the sequence is always a subject node and turns into a containing element called an rdf:Description that is written at the top level of RDF/XML, below the XML document element (in this case rdf:RDF). So the chains of stripes start at the top of an RDF/XML document and always begin with nodes.

For example, Figure 1 below a graph written as ASCII saying: there exists a document (this one) with a title, "RDF/XML Syntax Specification (Revised)" and this document has an editor, the editor has a name "Dave Beckett" and a home page http://purl.org/net/dajobe/.

Graph for RDF/XML Example
Figure 1: Graph for RDF/XML Example (SVG version)

Where the nodes are represented as ovals and contain their URI if it is known, the properties such as "has an editor" have been given URIs and these have been used to label the appropriate arc, and the strings have been written in rectangles.

If we take the path through the graph shown in Figure 2:

One Path Through the Graph
Figure 2: One Path Through the Graph (SVG version)

This corresponds to the node/arc stripes:

  1. Node [http://www.w3.org/TR/rdf-syntax-grammar]
  2. Arc -[http://example.org/stuff/1.0/editor]->
  3. Node []
  4. Arc -[http://example.org/stuff/1.0/homePage]->
  5. Node [http://purl.org/net/dajobe/]

In RDF/XML this sequence of 5 nodes and arcs corresponds to 5 XML elements shown in Example 1:

Example 1: Striped RDF/XML (nodes and arcs)
<rdf:Description>
  <ex:editor>
    <rdf:Description>
      <ex:homePage>
        <rdf:Description>
        </rdf:Description>
      </ex:homePage>
    </rdf:Description>
  </ex:editor>
</rdf:Description>

Which consists of some nodes with known URIs that can be filled in and others that remain blank, as shown in Example 2:

Example 2: Striped RDF/XML with known node URIs added
<rdf:Description rdf:about="http://www.w3.org/TR/rdf-syntax-grammar">
  <ex:editor>
    <rdf:Description>
      <ex:homePage>
        <rdf:Description rdf:about="http://purl.org/net/dajobe/">
        </rdf:Description>
      </ex:homePage>
    </rdf:Description>
  </ex:editor>
</rdf:Description>

There are several abbreviations that can be used to make very common uses more easy to write down. It is typical for the same resource to be described with multiple properties and values at the same time, so multiple child elements can be put inside rdf:Description, all of which are properties of that node as shown in Example 3 (here adding dc:format not shown in the graphs above):

Example 3: Adding more properties to a resource node
<rdf:Description rdf:about="http://www.w3.org/TR/rdf-syntax-grammar">
  <dc:title>RDF/XML Syntax Specification (Revised)<dc:title>
  <dc:format>text/html<dc:format>
    ...
</rdf:Description>

When the property value is a string it can be encoded more simply as an XML attribute and value, as an attribute of the node element. This is known as a property attribute and shown in Example 4:

Example 4: Turning string-valued properties from child elements to attributes
<rdf:Description rdf:about="http://www.w3.org/TR/rdf-syntax-grammar"
                 dc:title="RDF/XML Syntax Specification (Revised)"
                 dc:format="text/html">
  ...
</rdf:Description>

Another very common use is when a node is an instance of a class with rdf:type relationship, usually called a typed node. This shorthand is done by removing the rdf:type property and value and replacing the rdf:Description element name with the namespaced-element corresponding to the URI of the value of the type relationship as shown in Example 5 (using a different graph to those above):

Example 5: Replacing rdf:type property with a typed node
<rdf:Description rdf:about="http://example.org/thing">
  <rdf:type rdf:resource="http://example.org/stuff/1.0/document"/ >
  ...
</rdf:Description>

<ex:document rdf:about="http://example.org/thing">
  ...
</ex:document>

The above forms the basis of the RDF/XML syntax and although there are some other abbreviated forms not covered here at this time includes generating the RDF list properties and for skipping having to write down a blank element node. The latter breaks the striping but is useful for, amongst other uses, encoding properties with multiple-values.

The original example above filled out and completed, using some abbreviations gives Example 6:

Example 6: Full RDF/XML example
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
         xmlns:dc="http://purl.org/dc/elements/1.1/"
         xmlns:ex="http://example.org/stuff/1.0/">
  <rdf:Description rdf:about="http://www.w3.org/TR/rdf-syntax-grammar">
    <dc:title>RDF/XML Syntax Specification (Revised)</dc:title>
    <ex:editor rdf:parseType="Resource">
      <ex:fullName>Dave Beckett</ex:fullName>
      <ex:homePage rdf:resource="http://purl.org/net/dajobe/" />
    </ex:editor>
  </rdf:Description>
</rdf:RDF>

For a longer introduction to the RDF/XML striped syntax with a historical perspective, see RDF: Understanding the Striped RDF/XML Syntax [STRIPEDRDF].

Note: This section is still under development and the Working Group has developed an RDF Primer [RDF-PRIMER] that goes into more detail of introducing RDF.

3 Data Model

This syntax operates on an XML document as a sequence of nodes in document order in the style of [XPATH]  Information Set Mapping serialized into a sequence called document order which is defined in Section 3.2 Information Set Mapping. The resulting nodes are intended to be similar to the events that are produced by the [SAX2] XML API. This model is conceptual only and does not mandate any implementation method; in particular the use of [XPATH] or [SAX2] is not required.

The syntax does not support non-well-formed XML documents, nor documents that otherwise don't have an XML Information Set; for example, that don't conform to XML Namespaces [XML-NS].

The Infoset requires supports for XML Base [XML-BASE] which generates information item properties [base URI] below. The use this property in RDF/XML is discussed in section 3.10

This specification requires an information set as defined in [INFOSET] which supports at least the following information items and properties for RDF/XML:

Document Information Item
[document element], [children], [base URI]
Element Information Item
[local name], [namespace name], [children], [attributes], [parent], [base URI]
Attribute Information Item
[local name], [namespace name], [normalized value], [owner element]
Character Information Item
[character code]
Processing Instruction Information Item
Unexpanded Entity Reference Information Item
Comment Information Item
Document Type Declaration Information Item
Unparsed Entity Information Item
Notation Information Item
Namespace Information Item
No mapping made to data model nodes

Open Issue: The handling of XML content inside parseTypeLiteralPropertyElt requires some other Information Items, yet to be determined but based on the requirements for Exclusive XML Canonicalization W3C Candidate Recommendation.

This section is intended to satisfy the requirements for Conformance in the [INFOSET] specification.

3.1 Nodes

There are six types of node defined in the following subsections. Most nodes are constructed from an Infoset information item (except for Identifier). The effect of a node constructor is to create a new node with a unique identity, distinct from all other nodes. Nodes have accessor operations on them, and all have the string-value accessor that may be part of the node or computed.

3.1.1 Root Node

Created from an Document Information Item and takes the following accessors and their values from the element information item properties: document-element, children and base-uri. The property language is set to the empty string.

3.1.2 Element Node

Created from an Element Information Item and takes the following accessors and their values from the element information item properties: local-name, namespace-name, children, attributes, parent and base-uri. When this node is created from such values, the URI accessor is defined with a string value of the concatenation of the value of the namespace-name accessor and the value of the local-name accessor. On creation the li-counter and bag-li-counter accessors are added with initial integer values 1.

On creation, if the ·attributes· accessor contains an attribute node xml:lang (that is, the local-name accessor of the attribute has value "lang" and the namespace-name accessor of the attribute has value "http://www.w3.org/XML/1998/namespace") then that attribute is removed from the list of attributes and the accessor ·language· on the element node is set to the string-value of the attribute. If no such attribute is present, the language accessor on the element node is set to the value of the language accessor on the parent node. All other attributes beginning with xml are removed (that is, with namespace-name accessors values beginning with "http://www.w3.org/XML/1998/namespace"). Note: this does not include xml:base which is already present in the Infoset as the base-uri accessor.

The subject accessor may be added and takes the value of an Identifier node. This is used on elements that deal with one node in the RDF graph, this generally being the subject of a statement.

3.1.3 End Element Node

Has no accessors. Marks the end of the containing element in the sequence.

3.1.4 Attribute Node

Created from an Attribute Information Item and takes the accessors local-name, namespace-name and owner element and their values from the respective element information item properties. When this node is created from such values, two accessors and values are defined. Firstly the string-value accessor is defined with the normalized value as specified by [XML]. An attribute whose normalized value is a zero-length string is not treated specially: it results in an attribute node whose string-value is a zero-length string. Secondly the ·URI· accessor is defined with a string value of the concatenation of the value of the namespace-name accessor and the value of the local-name accessor.

3.1.5 Text Node

Created from a sequence of one or more consecutive Character Information Items. Has the single accessor ·string-value· which has the value of the string made from concatenating the character code property of each of the character information items. [NOTE: Identical to XPath.]

3.1.6 Identifier Node

A node for a typed identifier which can have the following three accessors: ·identifier·, ·identifier-type· and ·string-value·. These nodes are created by giving two values for the ·identifier· and ·identifier-type· accessors. The identifier accessor takes a string value and the identifier-type accessor can take values "URI" or "bnodeID".

The ·string-value· accessor is defined from the other accessors as follows: If ·identifier-type· is "URI" then the value is the concatenation of "<", the value of the ·identifier· accessor and ">". If ·identifier-type· is "bnodeID" then the value is the concatenation of "_:" and the value of the ·identifier· accessor.

For further information on identifiers in the RDF graph, see section 3.5.

3.1.7 Literal Node

A node for a literal which can have the following three accessors: literal-value, literal-language and ·string-value·. These nodes are created by giving two values for the ·literal-value· and ·literal-language· accessors which both take string values.

The ·string-value· accessor is defined from the other accessors as follows: If ·literal-language· is empty then the value is the concatenation of """ (1 double quote), the value of the ·literal-value· accessor and """ (1 double quote). Otherwise the value is the concatenation of """ (1 double quote), the value of the ·literal-value· accessor ""-" (1 double quote and a '-'), and the value of the ·literal-language· accessor. Note that the double-quoted literal-value string must use the N-Triples string escapes for escaping certain characters such as ".

Note: Literals beginning with a Unicode combining character are allowed however they may cause interoperability problems. See [CHARMOD] for further information.

3.1.8 XML Literal Node

A node for an XML literal which can have the following three accessors: ·literal-value·, ·literal-language· and ·string-value·. These nodes are created by giving two values for the ·literal-value· and ·literal-language· accessors which both take string values.

The ·string-value· accessor is defined from the other accessors as follows: If ·literal-language· is empty then the value is the concatenation of "xml"" ('x', 'm', 'l', and 1 double quote), the value of the ·literal-value· accessor and """ (1 double quote). Otherwise the value is the concatenation of "xml"" ('x', 'm', 'l', and 1 double quote), the value of the ·literal-value· accessor ""-" (1 double quote and a '-'), and the value of the ·literal-language· accessor. Note that the double-quoted literal-value string must use the N-Triples string escapes for escaping certain characters such as ".

Note: Literals beginning with a Unicode combining character are allowed however they may cause interoperability problems. See [CHARMOD] for further information.

3.2 Information Set Mapping

To transform the Infoset into the sequence of nodes in document order, each information item is transformed as described above to generate a tree of nodes with accessors and values. Each element node is then replaced as described below to turn the tree of nodes into a sequence in document order.

  1. The original element node
  2. The value of the children accessor, a possibly empty ordered list of nodes.
  3. An end element node

3.3 RDF MIME type, file extension and Macintosh file type

The Internet Media Type / MIME type for RDF is "application/rdf+xml" - see RFC 3032 (RFC-3023) section 8.18. The W3C will register this type when this working draft is more stable.

It is recommended that RDF files have the extension ".rdf" (all lowercase) on all platforms.

It is recommended that RDF files stored on Macintosh HFS file systems be given a file type of "rdf " (all lowercase, with a space character as the fourth letter).

3.4 The RDF Namespace

The RDF Namespace URI is http://www.w3.org/1999/02/22-rdf-syntax-ns# and is typically used in XML with the prefix rdf although other prefix strings may be used. The namespace contains the following names only:

Syntax names (no concepts in the graph)

RDF Description ID about bagID parseType resource li

RDF Classes in the graph

Seq Bag Alt Statement Property

RDF Properties in the graph

subject predicate object type value _n
where n is a non-negative integer.

Any other names are not defined and SHOULD generate a warning when encountered in an application, but should otherwise behave normally, and treated as properties and/or classes as appropriate for their use.

Throughout this document the terminology rdf:name will be used to indicate name is from the RDF namespace and it has a URI of the concatenation of the ·RDF Namespace URI· and name. For example, rdf:type has the URI http://www.w3.org/1999/02/22-rdf-syntax-ns#type

Note: In the 18 December 2001 Working Draft the names aboutEach and aboutEachPrefix were removed from the language and the RDF namespace by the RDF Core Working Group. See the resolution of issues rdfms-abouteach and rdfms-abouteachprefix for further information. The Working Group invites feedback from the community on the effects of this on existing implementations and documents and on the costs and benefits of adopting a new namespace URI to reflect this change (currently not proposed by the Working Group).

3.5 Identifiers

The RDF graph uses three types of identifiers (or labels) for nodes and arcs:

URI references (labeling nodes and arcs)

The URI references can be either given as absolute URIs, relative URIs that have to be resolved to the in-scope base URI as described in section section 3.6, constructed from XML Namespace-qualified element and attributes names (QNames) or from rdf:ID and rdf:bagID attribute values.

XML QNames give URIs by concatenating the namespace URI and the XML local name. For example, if the XML Namespace prefix foo has URI http://example.org/somewhere/ then the QName foo:bar would correspond to the URI http://example.org/somewhere/bar. Note that this restricts which URIs can be made and the same URI can be given in multiple ways.

The rdf:ID and rdf:bagID values generate URIs by considering them as equivalent to the relative URI "#" concatenated with the attribute value. This can then be resolved relative to the in-scope base URI as described in section section 3.6.

Literals (labeling object arcs)

These are Unicode strings or XML content.

Blank node Identifiers (labeling nodes)
These are given local identifiers in the N-Triples serialization which must match the name production in N-Triples.

Note: In the past, some RDF applications have handled these nodes (then called anonymous nodes) by generating arbitrary URIs. This generates a different RDF graph. See also the Skolemization section of the RDF Model Theory [RDF-MODEL] Working Draft.

3.6 Base URIs

RDF/XML supports XML Base [XML-BASE] by being based on the XML Information Set [INFOSET]. This defines a ·base-uri· property for each ·root node· and ·element node·.

RDF/XML uses URI-references throughout and applies the in-scope Base URI to resolve both URI document references of the form "#frag" and self document references of the form "".

Test: Indicated by test001.rdf and test001.nt

Test: Indicated by test004.rdf and test004.nt

Test: Indicated by test008.rdf and test008.nt

Test: Indicated by test013.rdf and test013.nt

Test: Indicated by test016.rdf and test016.nt

An empty same document reference "" resolves against the URI part of the Base URI; any fragment part is ignored. See Uniform Resource Identifiers (URI) [URIS] section 4.2

Test: Indicated by test013.rdf and test013.nt

Implementor Note: When using a hierarchical base URI that has no path component (/), it must be added before using as a base URI for resolving.

Test: Indicated by test011.rdf and test011.nt

4 Notation

4.1 Terminology

The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 [KEYWORDS].

4.2 Grammar Notation

The following notation is used for describing the nodes and grammar EBNF. The RDF/XML grammar is defined here in terms of its information set nodes, using statements of the form:

number node-type node-content

action...

where the node-content is an expression, which may refer to other node-types (as defined in Section 3.1), using constructs of the form given in the following table. The number is used for reference purposes. The action may include generating N-Triples into the model.

Notation for nodes and grammar EBNF.
Notation Meaning
A = B A is equal to B
A != B A is not equal to B
A := B Assigns A the value B
node.property Returns the value of the given node property
root(prop1=value1,
    prop2=value2, ...)
A root node with accessors
start_element(prop1=value1,
    prop2=value2, ...)
children
end_element()
A sequence of element node with accessors, a possibly empty list of nodes as element content and an end element node
attribute(prop1=value1,
    prop2=value2, ...)
An attribute node with accessors
identifier(prop1=value1,
    prop2=value2, ...)
An identifier node with accessors
text() A text node
literal(prop1=value1,
    prop2=value2, ...)
A literal node with accessors
xml(prop1=value1,
    prop2=value2, ...)
An XML literal node with accessors
list(item1, item2, ...); list() An ordered list of items in document order; an empty list
set(item1, item2, ...); set() An unordered set of items; an empty set
* Zero or more of preceding term
? Zero or one of preceding term
+ One or more of preceding term
A | B | ... The A, B, ... terms are alternatives.
A - B The term A but not the term B
"ABC" A string of characters A, B, C in order.
concat(A, B, ..) A string created by concatenating the terms in order.
anyURI Any legal URI.
anyString Any string.
rdf:X See section 3.4

5 RDF/XML Grammar

5.0 Grammar summary

5.2 doc root(document-element=RDF, children=list(RDF))
5.3 RDF start_element(URI = rdf:RDF, attributes=set())
nodeElementList
end_element()
5.4 nodeElementList ws* (nodeElement ws* )*
5.5 nodeElement start_element(URI=anyURI - ( rdf:RDF | rdf:ID | rdf:about | rdf:bagID | rdf:parseType | rdf:resource | rdf:li )
    attributes=set((idAttr | aboutAttr )?, bagIdAttr?, propertyAttr*))
propertyEltList
end_element()
5.6 ws White space as defined by [XML] definition White Space Rule [3] S in section Common Syntactic Constructs
5.7 propertyEltList ws* (propertyElt ws* ) *
5.8 propertyElt resourcePropertyElt | literalPropertyElt | parseTypeLiteralPropertyElt | parseTypeResourcePropertyElt | parseTypeOtherPropertyElt | emptyPropertyElt
5.9 resourcePropertyElt start_element(URI=anyURI - ( rdf:RDF | rdf:Description | rdf:ID | rdf:about | rdf:bagID | rdf:parseType | rdf:resource ), attributes=set(idAttr?))
ws* nodeElement ws*
end_element()
5.10 literalPropertyElt start_element(URI=anyURI - ( rdf:RDF | rdf:Description | rdf:ID | rdf:about | rdf:bagID | rdf:parseType | rdf:resource ), attributes=set(idAttr?))
text()
end_element()
5.11 parseTypeLiteralPropertyElt start_element(URI=anyURI - ( rdf:RDF | rdf:Description | rdf:ID | rdf:about | rdf:bagID | rdf:parseType | rdf:resource ), attributes=set(idAttr?, parseLiteral))
literal
end_element()
5.12 parseTypeResourcePropertyElt start_element(URI=anyURI - ( rdf:RDF | rdf:Description | rdf:ID | rdf:about | rdf:bagID | rdf:parseType | rdf:resource ), attributes=set(idAttr?, parseResource))
propertyEltList
end_element()
5.13 parseTypeOtherPropertyElt start_element(URI=anyURI - ( rdf:RDF | rdf:Description | rdf:ID | rdf:about | rdf:bagID | rdf:parseType | rdf:resource ), attributes=set(idAttr?, parseOther))
propertyEltList
end_element()
5.14 emptyPropertyElt start_element(URI=anyURI - ( rdf:RDF | rdf:Description | rdf:ID | rdf:about | rdf:bagID | rdf:parseType | rdf:resource ), attributes=set(idAttr? resourceAttr?, bagIdAttr?, propertyAttr*))
end_element()
5.15 idAttr attribute(URI = rdf:ID, string-value=rdf-id)
5.16 aboutAttr attribute(URI = rdf:about, string-value=URI-reference)
5.17 bagIdAttr attribute(URI = rdf:bagID, string-value=rdf-id)
5.18 propertyAttr attribute(URI=anyURI - ( rdf:RDF | rdf:Description | rdf:ID | rdf:about | rdf:bagID | rdf:parseType | rdf:resource | rdf:li ), string-value=anyString)
5.19 resourceAttr attribute(URI = rdf:resource, string-value=URI-reference)
5.20 parseLiteral attribute(URI = rdf:parseType, string-value="Literal")
5.21 parseResource attribute(URI = rdf:parseType, string-value="Resource")
5.22 parseOther attribute(URI = rdf:parseType, string-value=anyString - ("Resource" | "Literal") )
5.24 literal Any XML element content that is allowed according to [XML] definition Content of Elements Rule [43] content. in section 3.1 Start-Tags, End-Tags, and Empty-Element Tags

5.1 Grammar start

If the RDF/XML is a standalone XML content, then the grammar starts with Root Node  doc.

If the content is known to be RDF/XML by context, such as when RDF/XML is embedded inside other XML content, then the grammar can either start at Element Node  RDF (only when an element is legal at that point in the XML) or at production nodeElementList (only when element content is legal, since this is a list of elements). For such embedded RDF/XML, the ·base-uri· value on the outermost element must be initialized from the containing XML since no Root Node  will be available. Note that if such embedding occurs, the grammar may be entered several times but no state is expected to be preserved.

5.2 Production doc

root(document-element=RDF,
    children=list(RDF))

5.3 Production RDF

start_element(URI = rdf:RDF,
    attributes=set())
nodeElementList
end_element()

5.4 Production nodeElementList

ws* (nodeElement ws* )*

5.5 Production nodeElement

start_element(URI=anyURI - ( rdf:RDF | rdf:ID | rdf:about | rdf:bagID | rdf:parseType | rdf:resource | rdf:li )
    attributes=set((idAttr | aboutAttr )?, bagIdAttr?, propertyAttr*))
propertyEltList
end_element()

For element e, the processing of some of the attributes have to be done before other work such as dealing with children nodes or other attributes. These can be processed in any order:

The following can then be performed in any order:

If an attribute a with a.URI = rdf:bagID is present, n := identifier(identifier=concat(e.base-uri, "#", a.string-value), identifier-type="URI") then in any order:

5.6 Production ws

White space as defined by [XML] definition White Space Rule [3] S in section Common Syntactic Constructs

5.7 Production propertyEltList

ws* (propertyElt ws* ) *

5.8 Production propertyElt

resourcePropertyElt | literalPropertyElt | parseTypeLiteralPropertyElt | parseTypeResourcePropertyElt | parseTypeOtherPropertyElt | emptyPropertyElt

If element e has e.URI = rdf:li then apply the list expansion rules on element e.parent in section 5.27 to give a new URI u and e.URI := u.

5.9 Production resourcePropertyElt

start_element(URI=anyURI - ( rdf:RDF | rdf:Description | rdf:ID | rdf:about | rdf:bagID | rdf:parseType | rdf:resource ),
    attributes=set(idAttr?))
ws* nodeElement ws*
end_element()

For element e, and the single contained nodeElement n the following statement is added to the model:

   e.parent.subject.string-value <e.URI> n.subject.string-value .

If the rdf:ID attribute a is given, the above statement is reified with i := identifier(identifier=concat(e.base-uri, "#", a.string-value), identifier-type="URI") using the reification rules in section 5.26 and e.subject := i

5.10 Production literalPropertyElt

start_element(URI=anyURI - ( rdf:RDF | rdf:Description | rdf:ID | rdf:about | rdf:bagID | rdf:parseType | rdf:resource ),
    attributes=set(idAttr?))
text()
end_element()

Note: The empty literal case is defined in production emptyPropertyElt

For element e, and the text node t then o := literal(literal-value=t.string-value, literal-language=e.language) and the following statement is added to the model:

e.parent.subject.string-value <e.URI> o.string-value .

If the rdf:ID attribute a is given, the above statement is reified with i := identifier(identifier=concat(e.base-uri, "#", a.string-value), identifier-type="URI") using the reification rules in section 5.26 and e.subject := i.

5.11 Production parseTypeLiteralPropertyElt

start_element(URI=anyURI - ( rdf:RDF | rdf:Description | rdf:ID | rdf:about | rdf:bagID | rdf:parseType | rdf:resource ),
    attributes=set(idAttr?, parseLiteral))
literal
end_element()

For element e and the literal l, then o := xml(literal-value=l.string-value, literal-language=e.language) and the following statement is added to the model:

e.parent.subject.string-value <e.URI> o.string-value .

Test: Empty literal case indicated by test009.rdf and test009.nt

If the rdf:ID attribute a is given, the above statement is reified with i := identifier(identifier=concat(e.base-uri, "#", a.string-value), identifier-type="URI") using the reification rules in section 5.26 and e.subject := i.

Open Issue: The result of a literal from rdf:parseType="Literal" content has been generally decided by the RDF Core Working Group but all the cases have not been entirely resolved at this time. The solution will be based on serializing the XML element content in l to a string in a form defined by Exclusive XML Canonicalization W3C Candidate Recommendation.

5.12 Production parseTypeResourcePropertyElt

start_element(URI=anyURI - ( rdf:RDF | rdf:Description | rdf:ID | rdf:about | rdf:bagID | rdf:parseType | rdf:resource ),
    attributes=set(idAttr?, parseResource))
propertyEltList
end_element()

For element e with possibly empty element content c.

Generate a local blank node identifier i and n := identifier(identifier=i, identifier-type="bnodeID").

Add the following statement to the model:

e.parent.subject.string-value <e.URI> n.string-value .

Test: Indicated by test004.rdf and test004.nt

If the rdf:ID attribute a is given, the statement above is reified with i := identifier(identifier=concat(e.base-uri, "#", a.string-value), identifier-type="URI") using the reification rules in section 5.26 and e.subject := i.

If the element content c is not an empty, then use node n to create a new sequence of nodes as follows:

start_element(URI=rdf:Description,
    subject=n,
    attributes=set())
c
end_element()

Then process the resulting sequence using production nodeElement.

5.13 Production parseTypeOtherPropertyElt

start_element(URI=anyURI - ( rdf:RDF | rdf:Description | rdf:ID | rdf:about | rdf:bagID | rdf:parseType | rdf:resource ),
    attributes=set(idAttr?, parseOther))
propertyEltList
end_element()

All rdf:parseType attribute values other than the strings "Resource" or "Literal" are treated as if the value was "Literal". Processing MUST continue at production parseTypeLiteralPropertyElt. No extra triples are generated for other rdf:parseType values.

5.14 Production emptyPropertyElt

start_element(URI=anyURI - ( rdf:RDF | rdf:Description | rdf:ID | rdf:about | rdf:bagID | rdf:parseType | rdf:resource ),
    attributes=set(idAttr? resourceAttr?, bagIdAttr?, propertyAttr*))
end_element()

5.15 Production idAttr

attribute(URI = rdf:ID,
    string-value=rdf-id)

Constraint: The names used as values of rdf:ID and rdf:bagID attributes must be unique in a single RDF/XML document since they come from the same set of names. This applies with respect to the in-scope base-uri property of the current element; so the same value can appear on different elements in the same document but only if the in-scope base-uri values were different.

Test: Indicated by test014.rdf and test014.nt

5.16 Production aboutAttr

attribute(URI = rdf:about,
    string-value=URI-reference)

5.17 Production bagIdAttr

attribute(URI = rdf:bagID,
    string-value=rdf-id)

Constraint: See the constraint on rdf:ID values which also applies to rdf:bagID values.

5.18 Production propertyAttr

attribute(URI=anyURI - ( rdf:RDF | rdf:Description | rdf:ID | rdf:about | rdf:bagID | rdf:parseType | rdf:resource | rdf:li ),
    string-value=anyString)

5.19 Production resourceAttr

attribute(URI = rdf:resource,
    string-value=URI-reference)

5.20 Production parseLiteral

attribute(URI = rdf:parseType,
    string-value="Literal")

5.21 Production parseResource

attribute(URI = rdf:parseType,
    string-value="Resource")

5.22 Production parseOther

attribute(URI = rdf:parseType,
    string-value=anyString - ("Resource" | "Literal") )

5.23 Production URI-reference

An attribute ·string-value· interpreted as a URI reference defined in Uniform Resource Identifiers (URI) [URIS] BNF production URI-reference.

5.24 Production literal

Any XML element content that is allowed according to [XML] definition Content of Elements Rule [43] content. in section 3.1 Start-Tags, End-Tags, and Empty-Element Tags

5.25 Production rdf-id

An attribute ·string-value· matching any legal [XML] token Nmtoken

5.26 Reification Rules

For a statement with terms s, p and o corresponding to the N-Triples:

s p o .

add the following statements to the model using the given Identifier Node r:

r.string-value <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> s .
r.string-value <http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate> p .
r.string-value <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> o .
r.string-value <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement> .

5.27 List Expansion Rules

For the given element e, generate a new URI u := concat("http://www.w3.org/1999/02/22-rdf-syntax-ns#_", e.li-counter), increment the e.li-counter property by 1 and return u.

5.28 Bag Expansion Rules

For the given element e, generate a new URI u := concat("http://www.w3.org/1999/02/22-rdf-syntax-ns#_", e.bag-li-counter), increment the e.bag-li-counter property by 1 and return u.

6 Serializing an RDF Graph to RDF/XML

It is not possible for all graphs that can be expressed in the RDF Model Theory [RDF-MODEL] to be encoded in this syntax. If you do a round trip from RDF/XML to RDF graph and then back to RDF/XML the meaning will be the same (the graphs) but the RDF/XML that comes out may not be exactly the same.

There are two different approaches to serializing RDF.

The basic approach uses the basic RDF syntax from [RDF-MS]. In this:

The basic serialization is recommended for applications in which the output RDF/XML is to be used only in further RDF processing. Where the intent is for the output RDF/XML file to be read by people, the basic serialization proves unsatisfactory. The basic serialization does not conform to more restricted sub-dialects of RDF, such as [RSS] or [CC/PP]. Hence, it is not appropriate for such applications, for which dialect specific serializers are needed.

If more human readable output is needed the following factors should be considered:

It is not possible to use the RDF/XML serialization for serializing an RDF graph in which any triple has a property label which cannot be expressed as a XML namespace-qualified name (QName). It is recommended that implementors of RDF serializers in order to break a URI into a namespace name and a local name, split it after the last XML non-Name character, ensuring that the first character of the name is a Letter or '_'. If the URI ends in a non-Name character then throw a "this graph cannot be serialized in RDF 1.0" exception or error.

An approach to serializing RDF/XML using the full grammar in a top-down recursive descent fashion is discussed in [UNPARSING].

7 Acknowledgments (Informative)

The following people provided valuable contributions to the document:

8 References

Normative References

[RDF-MS]
Resource Description Framework (RDF) Model and Syntax Specification, O. Lassila and R. Swick, Editors. World Wide Web Consortium. 22 February 1999. This version is http://www.w3.org/TR/1999/REC-rdf-syntax-19990222. The latest version of RDF M&S is available at http://www.w3.org/TR/REC-rdf-syntax.
[XML]
Extensible Markup Language (XML) 1.0, Second Edition, T. Bray, J. Paoli, C.M. Sperberg-McQueen and E. Maler, Editors. World Wide Web Consortium. 6 October 2000. This version is http://www.w3.org/TR/2000/REC-xml-20001006. latest version of XML is available at http://www.w3.org/TR/REC-xml.
[XML-NS]
Namespaces in XML, T. Bray, D. Hollander and A. Layman, Editors. World Wide Web Consortium. 14 January 1999. This version is http://www.w3.org/TR/1999/REC-xml-names-19990114. The latest version of Namespaces in XML is available at http://www.w3.org/TR/REC-xml-names.
[INFOSET]
XML Information Set, J. Cowan and R. Tobin, Editors. World Wide Web Consortium. 24 October 2001. This version is http://www.w3.org/TR/2001/REC-xml-infoset-20011024. The latest version of XML Information set is available at http://www.w3.org/TR/xml-infoset.
[URIS]
RFC 2396 - Uniform Resource Identifiers (URI): Generic Syntax, T. Berners-Lee, R. Fielding and L. Masinter, IETF, August 1998. This document is http://www.isi.edu/in-notes/rfc2396.txt.
[RDF-TESTS]
RDF Test Cases, A. Barstow and D. Beckett, Editors. Work in progress. World Wide Web Consortium, 15 November 2001. This version of the RDF Test Cases is http://www.w3.org/TR/2001/WD-rdf-testcases-20011115/. The latest version of the RDF Test Cases is at http://www.w3.org/TR/rdf-testcases.
[KEYWORDS]
RFC 2119 - Key words for use in RFCs to Indicate Requirement Levels, S. Bradner, IETF. March 1997. This document is http://www.ietf.org/rfc/rfc2119.txt.
[RFC-3023]
RFC 3032 - XML Media Types, M. Murata, S. St.Laurent, D.Kohn, IETF. January 2001. This document is http://www.ietf.org/rfc/rfc3023.txt.
[XML-BASE]
XML Base, J. Marsh, Editor, W3C Recommendation. World Wide Web Consortium, 27 June 2001. This version of XML Base is http://www.w3.org/TR/2001/REC-xmlbase-20010627/. The latest version of XML Base is at http://www.w3.org/TR/xmlbase/.
[UNICODE]
The Unicode Consortium, The Unicode Standard, Version 3, ISBN 0-201-61633-5, as updated from time to time by the publication of new versions. (See http://www.unicode.org/unicode/standard/versions/ for the latest version and additional information on versions of the standard and of the Unicode Character Database).
[NFC]
Unicode Normalization Forms, Unicode Standard Annex #15, Mark Davis, Martin Dürst. (See http://www.unicode.org/unicode/reports/tr15/ for the latest version).
[XC14N]
Exclusive XML Canonicalization , John Boyer, Donald E. Eastlake 3rd, and Joseph Reagle, Editors. World Wide Web Consortium. 12 February 2002. This version is http://www.w3.org/TR/2002/CR-xml-exc-c14n-20020212. The latest version of Exclusive XML Canonicalization is available at http://www.w3.org/TR/xml-exc-c14n .
[RFC-2732]
RFC 2732 - Format for Literal IPv6 Addresses in URL's, R. Hinden, B. Carpenter, L. Masinter, IETF. 1999. This document is http://www.ietf.org/rfc/rfc2732.txt.

Informational References

[CHARMOD]
Character Model for the World Wide Web 1.0, M. Dürst, F. Yergeau, R. Ishida, M. Wolf, A. Freytag, T Texin, Editors, World Wide Web Consortium Working Draft, work in progress, 20 February 2002. This version of the Character Model is http://www.w3.org/TR/2002/WD-charmod-20020220/. The latest version of the Character Model is at http://www.w3.org/TR/charmod/.
[RDF-MODEL]
RDF Model Theory, P. Hayes, Editor. Work in progress. World Wide Web Consortium, 14 February 2002. This version of the RDF Model Theory is http://www.w3.org/TR/2002/WD-rdf-mt-20020214. The latest version of the RDF Model Theory is at http://www.w3.org/TR/rdf-mt/.
[RDF-PRIMER]
RDF Primer, F. Manola, E. Miller, Editors, World Wide Web Consortium W3C Working Draft, work in progress, 19 March 2002. This version of the RDF Primer is http://www.w3.org/TR/2002/WD-rdf-primer-20020319/. The latest version of the RDF Primer is at http://www.w3.org/TR/rdf-primer/.
STRIPEDRDF
RDF: Understanding the Striped RDF/XML Syntax, D. Brickley, W3C, 2001. This document is http://www.w3.org/2001/10/stripes/.
XPATH
XML Path Language (XPath) Version 1.0, J. Clark and S. DeRose, Editors. World Wide Web Consortium, 16 November 1999. This version of XPath is http://www.w3.org/TR/1999/REC-xpath-19991116. The latest version of XPath is at http://www.w3.org/TR/xpath.
SAX2
SAX Simple API for XML, version 2, D. Megginson, SourceForge, 5 May 2000. This document is http://sax.sourceforge.net/.
RSS
RDF Site Summary (RSS) 1.0, G. Beged-Dov, D. Brickley, R. Dornfest, I. Davis, L. Dodds, J. Eisenzopf, D. Galbraith, R.V. Guha, K. MacLeod, E. Miller, A. Swartz, E. van der Vlist, 2000. This document is http://purl.org/rss/1.0/spec.
CC/PP
Composite Capability/Preference Profiles (CC/PP): Structure and Vocabularies, G. Klyne, F. Reynolds, C. Woodrow, H. Ohto, World Wide Web Consortium Working Draft, work in progress, 15 March 2001. This version is http://www.w3.org/TR/2001/WD-CCPP-struct-vocab-20010315/. The latest version of CC/PP structure and Vocabularies is available at http://www.w3.org/TR/CCPP-struct-vocab.
UNPARSING
Unparsing RDF/XML, J. J. Carroll, HP Labs Technical Report, HPL-2001-294, 2001. This document is available at http://www.hpl.hp.com/techreports/2001/HPL-2001-294.html.
RELAXNG
RELAX NG Specification, James Clark and MURATA Makoto, editors, OASIS, 3 December 2001. This version of RELAX NG is http://www.oasis-open.org/committees/relax-ng/spec-20011203.html. The latest is at http://relaxng.org/.
RELAXNG-NX
RELAX NG Non-XML Syntax, James Clark, 3 December 2001. This document is http://www.thaiopensource.com/relaxng/nonxml/.
XML Schema Part 0: Primer
XML Schema Part 0: Primer - W3C Recommendation, World Wide Web Consortium, 2 May 2001.
XML Schema Part 1: Structures
XML Schema Part 1: Structures - W3C Recommendation, World Wide Web Consortium, 2 May 2001.
XML Schema Part 2: Datatypes
XML Schema Part 2: Datatypes - W3C Recommendation, World Wide Web Consortium, 2 May 2001.
Schematron
Schematron, Rick Jelliffe, Academia Sinica Computing Centre, Taibei.
[RFC-3066]
RFC 3066 - Tags for the Identification of Languages ,H. Alvestrand, IETF. 2001. This document is http://www.ietf.org/rfc/rfc3066.txt.
[XML 1.1]
@@@@ todo @@@@

Appendix A: Issues affecting RDF/XML Syntax (Non-Normative)

This section records local issues to be resolved and issues that were reported to the RDF Core Working Group related to the XML syntax and their disposition. This section is not the definitive list or description of the latter - see the RDF Core Working Group issues list. Decided issues may also have associated test cases which can be found in the RDF Test Cases W3C Working Draft.

A.1: Document Issues / Tasks (Non-Normative)

task-infoset

(Feedback on 2001-12-18 draft): Consider basing on Infoset rather than SAX

task-renaming

(Feedback on 2001-12-18 draft): Consider changing nodeset terms to be, for example, events to prevent confusion with RDF graph nodes.

task-intro

(Feedback on 2001-12-18 draft): Better introduction text with respect to RDF model, graph, model theory, N-Triples.

A.2: RDF Core Working Group Open Issues affecting RDF/XML Syntax (Non-Normative)

rdf-charmod-uris

Does the treatment of uri-references conform with charmod? [CHARMOD]

Action: ?

A.3: RDF Core Working Group Decided Issues affecting RDF/XML Syntax (Non-Normative)

rdf-ns-prefix-confusion

On 25th May 2001, the WG decided that ALL attributes must be namespace qualified. There is a description of the decision, including detail on the grammar productions affected and a collection of test cases

Action: Removal of original grammar productions 6.6, 6.7, 6.8, 6.9, 6.11, 6.18, 6.32, 6.33

rdfms-abouteachprefix

On 1st June 2001, the WG decided that aboutEachPrefix would be removed from the RDF Model and Syntax Recommendation on the grounds that there is a lack of implementation experience, and it therefore should not be in the recommendation. A future version of RDF may consider support for this feature.

Action: Removal of original grammar production 6.8

rdf-containers-syntax-ambiguity
rdf-containers-syntax-vs-schema

On 29th June 2001, the WG decided that containers will match the typed node production in the grammar (production 6.13) and that the container specific productions (productions 6.25 to 6.31) and any references to them be removed from the grammar. rdf:li elements will be translated to rdf:_nnn elements when they are found matching either a propertyElt (production 6.12) or a a typedNode (production 6.13). The decision includes a set of test cases.

Action: Removal of original grammar productions 6.25, 6.26, 6.27, 6.28, 6.29, 6.30, 6.31

rdfms-empty-property-elements

On 8th June 2001 the WG decided how empty property elements should be interpreted. The decision is fully represented by the test cases.

Action: Inserted pointers to the the test cases into the grammar at the places where empty property elements are recognized.

rdfms-aboutEach-on-object

On 29th June 2001, the WG decided that rdf:aboutEach attributes are not allowed on an rdf:Description (or typed node) element which is the object of a statement.

Action: None needed - rdf:aboutEach removed from the language on 7th December 2001.

rdfms-syntax-desc-clarity

The language describing the syntax is unclear [in section 6]

On 26th October 2001, the WG decided that this issue is closed by the new approach to defining the syntax in this document.

Action: A main goal of this document is to make the syntax clearer and more precise. In particular the grammar section and the pointers to schemas for XML validation help address this.

rdfms-formal-grammar

A formal grammar for RDF.

On 26th October 2001, the WG decided that this issue is closed by the new approach to defining the syntax in this document.

Action: A main goal of this document is to make the syntax clearer and more precise. In particular the grammar section and the pointers to schemas for XML validation help address this.

rdfms-validating-embedded-rdf

On 9th November 2001, the RDFCore WG resolved to postpone the issue "for later consideration on the grounds that it is out of scope of its current charter to change the current RDF/XML syntax to the extent necessary to address it."

Action: None required.

rdfms-rdf-names-use

On 30th November 2001, the WG decided that this issue was closed by the following resolution.

The use of rdf:RDF, rdf:ID, rdf:about, rdf:resource, rdf:bagID, rdf:parseType, rdf:aboutEach and rdf:li except as reserved names as specified in the grammar is an error. [Later rdf:aboutEach was removed from the language on 7th December 2001]

On 25th February 2002, the WG further resolved that:.

The WG reaffirmed its decision not to restrict names in the RDF namespaces which are not syntactic. The WG decided that an RDF processor SHOULD emit a warning when encountering names in the RDF namespace which are not defined, but should otherwise behave normally.

Action: Added note to section 3.4 RDF Namespace

rdfms-abouteach

processing rdf:aboutEach requires a processing of sub-property relations.

On 7th December 2001, the WG resolved to remove rdf:aboutEach from the language.

Action: Removed from the grammar.

rdfms-propElt-id-with-dr

On 7th December 2001, the WG decided to remove rdf:aboutEach from the language and consequently this issue was closed.

Action: None needed.

rdfms-difference-between-ID-and-about

What is the difference between using and ID attribute to 'create' a new resource and an about attribute to refer to it?

On 14th December 2001, the WG decided that this document resolves the issue.

Action: See section on Identifiers for details.

rdfms-qname-uri-mapping

On 11th January 2002, the WG resolved (revised) "to not change the algorithm for mapping qnames to uris and close this issue on the grounds":

  1. Such a change would be a major change to the mapping of RDF/XML syntax to the model and would be beyond our charter.
  2. It would cause the same RDF/XML to generate a different graph from existing versus revised implementations
  3. Existing code may generate wrong (illegal) graphs for some RDF/XML.

Action: None needed.

rdfms-reification-required

On 11th January 2002, the WG resolved (revised) "that a parser is not required to create bags of reified statements for all rdf:Description elements, only those which are explicitly reified using an rdf:ID on a propertyElt or by an rdf:bagID on the rdf:Description.

Existing test cases such as rdf-ns-prefix-confusion test0001 (test0001.rdf, test0001.nt) demonstrate this resolution."

Action: None needed - matches the existing syntax description.

rdfms-replace-value

On 11th January 2002, the WG resolved (revised) "to not change the name of this property at this time on the grounds:

and resolves to recast the issue as a need to clarify the semantics of rdf:value."

At the February 2002 face to face meeting, the RDFCore WG resolved:

Action: None needed.

mime-types-for-rdf-docs

On 18th January 2002, the WG authorized the removal of this issue from this document by the adding a new section with the wording proposed now included in the RDF MIME type section.

When the WG is ready (documents are stable), the MIME content-type registration for application/rdf+xml will proceed.

Action: Added RDF MIME type section.

rdfms-xml-base

On 18th January 2002, the WG decided that "xml:base be allowed, and honored, anywhere in an RDF document".

On 25th February 2002, the WG decided (1) that xml:base applies to RDF's use of document references (fragments)
(2) that xml:base hierarchical URIs without a path component shall have it set to /.
(3) the scope of xml:base attributes should be taken into account when checking for duplicate rdf:ID values

Action: Added details in Section 3 Data Model near introduction of Infoset and added new Section 3.6 Base URIs

rdfms-nested-bagIDs

What triples are generated for nested description elements with bagIDs?

On 25th February 2002, the WG decided that this issue was closed by the following resolution.

A bagID reifies the property attributes on the same element as the bagid, the type node and statements immediately arising from property elements that are immediate children of the element containing the bagId. In particular a property element whose statement is part of the bag, which has property attributes, those statements are not part of the bag.

Action: bagID algorithm added to nodeElement emptyPropertyElt.

rdfms-not-id-and-resource-attr

The propertyElt production 6.12 of the grammar does not allow both an ID attribute and a resource attribute to be specified.

On 25th February 2002, the WG decide that this issue was closed by making rdf:ID always specify the ID of the reified statement (parent node, property element, node).

Action: Updated 5.14 Production emptyPropertyElt and Relax NG schema to reflect decision.

rdfms-xmllang

Why isn't xml:lang information represented within the RDF data model?

On 25th February 2002, the WG decided that this issue was closed by the following resolution.

A literal consists of three components:

Action: Added the language node term from the value of xml:lang attributes, added sections Literal Node, and XML Literal Node and updated parseTypeOtherPropertyElt for parseType.

rdfms-xml-literal-namespaces

How should a parser process namespaces in a literal which is XML markup?

On 15th March 2002, the WG decided that this issue was closed by the following resolution.

Action: FIXME - This resolution is not yet folded into the document.

rdf-charmod-literals

Does the treatment of literals conform to charmod ? [CHARMOD]

On 5th April 2002, the RDFCore WG resolved this issue by approving test cases white, black 1 and black 2 submitted for consideration. The grey test cases were not approved; instead the WG decided to add text to the syntax specification pointing out that literals beginning with a combining character may not be serializable in RDF/XML, depending on the outcome of [CHARMOD], and may cause interoperability problems.

Action: Notes added: 1, 2
FIXME - more needed

A.4: RDF Core Working Group Postponed Issues affecting RDF/XML Syntax (Non-Normative)

rdfms-quoting

The syntax needs a more convenient way to express the reification of a statement.

On 26th October 2001, the WG decided that this issue was postponed for consideration by a future Working Group.

Action: None required.

rdfms-qnames-cant-represent-all-uris

The RDF XML syntax cannot represent all possible Property URI's.

On 26th October 2001, the WG decided that this issue was postponed for consideration by a future Working Group.

Action: None required.

rdfms-qnames-as-attrib-values

Suggestion that Qnames should be allowed as values for attributes such as rdf:about.

On 26th October 2001, the WG decided that this issue was postponed for consideration by a future Working Group.

Action: None required.

rdfms-syntax-incomplete

The RDF/XML syntax can't represent an an arbritary graph structure.

On 26th October 2001, the WG decided that this issue was postponed for consideration by a future Working Group.

Action: None required.

B Syntax Schemas (Non-Normative)

Two schema language authors submitted schemas for RDF/XML based on the revised grammar in the previous version of this draft. We include pointers to these schemas for information purposes and an example schema; they are not part of this specification.

B.1 RELAX NG Schema - Non XML (Non-Normative)

This is an example schema in RELAX NG's non-XML format (for ease of reading) but applications should use the standard XML version. These formats are described in RELAX NG ([RELAXNG]) and RELAX NG Non-XML Syntax ([RELAXNG-NX]).

RELAX NG Schema (Non-XML) for RDF/XML
#
# RELAX NG Schema (non-XML) for RDF/XML Syntax
#
# This schema is for information only and NON-NORMATIVE
#
# It is based on one originally written by James Clark in
# http://lists.w3.org/Archives/Public/www-rdf-comments/2001JulSep/0248.html
# and updated with later changes.
#

namespace local = ""
namespace rdf = "http://www.w3.org/1999/02/22-rdf-syntax-ns#"
datatypes xsd = "http://www.w3.org/2001/XMLSchema-datatypes"

start = doc
doc = 
  RDF

RDF =
  element rdf:RDF { nodeElementList }

nodeElementList = 
  nodeElement*

  # Should be something like:
  #  ws* , (  nodeElement , ws* )*
  # but RELAXNG does this by default, ignoring whitespace separating tags.

nodeElement =
  element * - (local:*
               |rdf:RDF
	       |rdf:ID|rdf:about
	       |rdf:bagID|rdf:parseType|rdf:resource
               |rdf:li ) {
      (idAttr | aboutAttr )?, bagIdAttr?, propertyAttr*, propertyEltList
  }

  # It is not possible to say "and not things
  # beginning with _ in the rdf: namespace" in RELAX NG.

ws = 
  " "

  # Not used in this RELAX NG schema; but should be any legal XML
  # whitespace defined by http://www.w3.org/TR/2000/REC-xml-20001006#NT-S


propertyEltList = 
  propertyElt*

  # Should be something like:
  #  ws* , ( propertyElt , ws* )*
  # but RELAXNG does this by default, ignoring whitespace separating tags.

propertyElt = 
  resourcePropertyElt | 
  literalPropertyElt | 
  parseTypeLiteralPropertyElt |
  parseTypeResourcePropertyElt |
  parseTypeOtherPropertyElt |
  emptyPropertyElt

resourcePropertyElt = 
  element * - (local:*
	       |rdf:RDF|rdf:Description
	       |rdf:ID|rdf:about
	       |rdf:bagID|rdf:parseType|rdf:resource) {
      idAttr?, nodeElement
  }

literalPropertyElt =
  element * - (local:*
               |rdf:RDF|rdf:Description
	       |rdf:ID|rdf:about
	       |rdf:bagID|rdf:parseType|rdf:resource) {
      idAttr?, text 
  }

parseTypeLiteralPropertyElt = 
  element * - (local:*
               |rdf:RDF|rdf:Description
               |rdf:ID|rdf:about
               |rdf:bagID|rdf:parseType|rdf:resource) {
      idAttr?, parseLiteral, literal 
  }

parseTypeResourcePropertyElt = 
  element * - (local:*
               |rdf:RDF|rdf:Description
               |rdf:ID|rdf:about
               |rdf:bagID|rdf:parseType|rdf:resource) {
      idAttr?, parseResource, propertyEltList
  }

parseTypeOtherPropertyElt = 
  element * - (local:*
               |rdf:RDF|rdf:Description
               |rdf:ID|rdf:about
               |rdf:bagID|rdf:parseType|rdf:resource) {
      idAttr?, parseOther, any
  }

emptyPropertyElt =
   element * - (local:*
                |rdf:RDF|rdf:Description
                |rdf:ID|rdf:about
		|rdf:bagID|rdf:parseType|rdf:resource) {
       idAttr?, resourceAttr?, bagIdAttr?, propertyAttr* 
   }

idAttr = 
  attribute rdf:ID { 
      IDsymbol 
  }

aboutAttr = 
  attribute rdf:about { 
      URI-reference 
  }

bagIdAttr = 
  attribute rdf:bagID {
      IDsymbol
  }

propertyAttr = 
  attribute * - (local:* 
                 |rdf:RDF|rdf:Description
                 |rdf:ID|rdf:about
		 |rdf:bagID|rdf:parseType|rdf:resource
		 |rdf:li) {
      string
  }

resourceAttr = 
  attribute rdf:resource {
      URI-reference 
  }

parseLiteral = 
  attribute rdf:parseType {
      "Literal" 
  }

parseResource = 
  attribute rdf:parseType {
      "Resource" 
  }

parseOther = 
  attribute rdf:parseType {
      text
  }

URI-reference = 
  string

literal =
  any

IDsymbol = 
  xsd:NMTOKEN

any =
  mixed { element * { attribute * { text }*, any }* }


B.2 Other Syntax Schemas (Non-Normative)

Two schema language authors submitted schemas for RDF/XML based on the new grammar in the previous version of this draft. We include pointers to these schemas for information purposes; they are not part of this specification.

C Changes

Changes since the 18 December 2001 working draft

(Newest at top)

Changes since the 06 September 2001 working draft


RDF/XML Metadata