Copyright ©2001 W3C® (MIT, INRIA, Keio), All Rights Reserved. W3C liability, trademark, document use and software licensing rules apply.
This editors version of a W3C Working Draft revises the specification of the XML syntax of RDF as originally described in RDF Model & Syntax. This document presents the syntax as amended and clarified by the RDF Core Working Group with the specification now based on the XML Information Set along with mapping rules for creating RDF models as described in the RDF Model Theory W3C Working Draft.
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 the editors working draft of the W3C Working Draft for the RDF Core Working Group produced as part of the W3C Semantic Web Activity. It incorporates decisions made by the Working Group updating the XML syntax for RDF from the original RDF Model & Syntax ([RDFMS]) document and includes a re-representing of the syntax in terms of the XML Information Set with rules for generation of RDF models.
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. This is the current state of an ongoing work on the syntax and mapping process and may not yet record all of the work in the grammar section of the original document.
This is a draft document and may be updated, replaced, or obsoleted by other documents at any time. It is inappropriate to use it 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://www.w3.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/.
1 Introduction
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
4.3 Notation Forms
5 RDF/XML Grammar
6 Serialising an RDF Graph to RDF/XML
7 Acknowledgments
8 References
A Issues affecting RDF/XML Syntax (Non-Normative)
A.1 Document Issues / Tasks (Non-Normative)
A.2 RDF Core WG Open Issues affecting RDF/XML Syntax (Non-Normative)
A.3 RDF Core WG Decided Issues affecting RDF/XML Syntax (Non-Normative)
A.4 RDF Core WG 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)
This document describes the XML ([XML]) syntax for RDF as originally defined in the RDF Model & Syntax ([RDFMS]) W3C Recommendation. Subsequent implementations of this syntax and comparison of the resulting RDF models have shown that there was ambiguity - implementations generated different models 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 model 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 WG 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 model more clearly shown. The mapping to the RDF model 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 model, 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 model) may be used.
In particular:
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 node describe resources that can be labelled with URIs, string literals or are blank. The arcs connect the nodes and are all labelled with URIs. This graph is more precisely called a directed edge-labelled 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 is also interpreted as an attribute, relationship or predicate of the resource with a value given by the object node content.
In order to encode the 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 labelling subject nodes are stored in XML attribute values. The nodes labelled 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/.
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:
This corresponds to the node/arc stripes:
[http://www.w3.org/TR/rdf-syntax-grammar]
-[http://example.org/stuff/1.0/editor]->
[]
-[http://example.org/stuff/1.0/homePage]->
[http://purl.org/net/dajobe/]
In RDF/XML this sequence of 5 nodes and arcs corresponds to 5 XML elements:
<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:
<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.
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.
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 replacing the
rdf:Description
element name with the namespaced-element
corresponding to the URI of the value of the type relationship.
The above forms the basis of the RDF/XML syntax and although there are some other abbreviated forms, such as for generating the RDF list properties and for skipping having to write down a blank element node, which breaks the striping but is useful for, amongst other uses, encoding properties with multiple-values.
The example above filled out and completed, using some abbreviations gives:
<?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 is working on an RDF primer document.
This syntax operates on an XML document as a sequence of nodes in document order in the style of [XPATH] Information Set Mapping serialised into document-order. 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 W3C Recommendation ([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:
Note: Outside RDF/XML processing, all Information Items should be made available to the application. This particularly applies to the handling of XML content inside parseTypeLiteralPropertyElt.
This section is intended to satisfy the requirements for Conformance in the [INFOSET] specification.
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 properties, and all have the string-value property that may be part of the node or computed from the string-value of contained nodes.
Created from an Document Information Item and takes the following properties and their values from the element information item: document-element, children and base-uri. The property language is set to the empty string.
Created from an Element Information Item and takes the following properties and their values from the element information item: local-name, namespace-name, children, attributes, parent and base-uri. When this node is created from such values, the URI property is defined with a string value of the concatenation of the value of the namespace-name property and the value of the local-name property. On creation the li-counter and bag-li-counter properties are added with initial integer values 1.
On creation, if the ·attributes· property contains an attribute node xml:lang (that is, the local-name property of the attribute has value "lang" and the namespace-name property of the attribute has value "http://www.w3.org/XML/1998/namespace") then that attribute is removed from the list of attributes and the property ·language· on the element node is set to the string-value of the attribute. If no such attribute is present, the property language on the element node is set to the value of the language property on the parent node.
The subject property may be added and takes the value of an Identifier node. This is used on elements that deal with one node in the RDF model, this generally being the subject of a statement.
Takes no properties but marks the end of the containing element in the sequence.
Created from an Attribute Information Item and takes the properties local-name, namespace-name and owner element and their values from respective element information item properties. When this node is created from such values, two properties and values are defined. Firstly the string-value property 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· property is defined with a string value of the concatenation of the value of the namespace-name property and the value of the local-name property.
Created from a sequence of one or more consecutive Character Information Items. Has the single property ·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.]
A node for a typed identifier which can have the following three properties: ·identifier·, ·identifier-type· and ·string-value·. These nodes are created by giving two values for the ·identifier· and ·identifier-type· properties. The identifier property takes a string value and the identifier-type property can take values "URI" or "bnodeID".
The ·string-value· property is defined from the other properties as follows: If ·identifier-type· is "URI" then the value is the concatenation of "<", the value of the ·identifier· property and ">". If ·identifier-type· is "bnodeID" then the value is the concatenation of "_:" and the value of the ·identifier· property.
For further information on identifiers in the RDF model, see section 3.9.
A node for a literal which can have the following three properties: literal-value, literal-language and ·string-value·. These nodes are created by giving two values for the ·literal-value· and ·literal-language· properties which both take string values.
The ·string-value· property is defined from the other properties as follows: If ·literal-language· is empty then the value is the concatenation of """, the value of the ·literal-value· property and """. Otherwise the value is the concatenation of """, the value of the ·literal-value· property ""-", and the value of the ·literal-language· property.
A node for an XML literal which can have the following three properties: ·literal-value·, ·literal-language· and ·string-value·. These nodes are created by giving two values for the ·literal-value· and ·literal-language· properties which both take string values.
The ·string-value· property is defined from the other properties as follows: If ·literal-language· is empty then the value is the concatenation of "xml"", the value of the ·literal-value· property and """. Otherwise the value is the concatenation of "xml"", the value of the ·literal-value· property ""-", and the value of the ·literal-language· property.
To transform the Infoset into the sequence of nodes, each information item is transformed as described above to generate a tree of nodes with properties and values. Each element node is then replaced as described below to turn the tree of nodes into a sequence in document order.
The Internet Media Type / MIME type for RDF is "application/rdf+xml" - see RFC 3032 (RFC3023) 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).
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
this is not required. The namespace contains the following names only:
RDF Description
ID about bagID parseType resource
subject predicate object
Seq Bag Alt Statement Property
type value
li _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
Implementors Note: The names aboutEach and aboutEachPrefix were removed from the language by the RDF Core WG - see the issues rdfms-abouteach and rdfms-abouteachprefix for further information.
The RDF model uses three types of identifiers (or labels) for nodes and arcs in the graph - absolute URI references, literals and unlabelled or blank nodes. The latter are given local identifiers in the N-Triples serialisation of the model in order to represent the graph correctly. These identifiers can be generated and must match the name production in N-Triples.
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.10, or constructed. The constructed URIs in RDF are either made from XML Namespace qualified element or attributes names (QNames) or from the value of rdf:ID or 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.10.
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·.
NOTE: 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
NOTE: An empty same document reference "" resolve 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
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]).
The following notation is used for describing the 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 properties |
start_element(prop1=value1, prop2=value2, ...) children end_element() |
A sequence of element node with properties, a possibly empty list of nodes as element content and an end element node |
attribute(prop1=value1, prop2=value2, ...) |
An attribute node with properties |
identifier(prop1=value1, prop2=value2, ...) |
An identifier node with properties |
text() | A text node |
literal(prop1=value1, prop2=value2, ...) |
A literal node with properties |
xml(prop1=value1, prop2=value2, ...) |
An XML literal node with properties |
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 |
The following notation forms are used to indicate
A sequence of lines of N-Triples output from a grammar production adding to an RDF model.
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 |
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 initialised 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.
root(document-element=RDF,
children=list(RDF))
start_element(URI = rdf:RDF,
attributes=set())
nodeElementList
end_element()
ws* (nodeElement ws* )*
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:
e.subject.string-value <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <e.URI> .
e.subject.string-value <a.URI> <a.string-value> .
e.subject.string-value <a.URI> o.string-value .
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:
S5 Add the following statement to the model:
n.string-value <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag> .
For the generated statements above (excluding S5) in the following order
If the statement was generated by S4 from a propertyElt and has an existing identifier e.subject then s := e.subject. Otherwise generate a local blank node identifier i and s := identifier(identifier=i, identifier-type="bnodeID")
Then reify the statement with node s using the reification rules in section 5.26 and apply the bag expansion rules in section 5.28 on node n to give a URI u. Then the following statement is added to the model:
n.string-value <u.string-value> s.string-value .
White space as defined by [XML] definition White Space Rule [3] S in section Common Syntactic Constructs
ws* (propertyElt ws* ) *
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.
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
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.
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 WG but all the cases have not been entirely resolved at this time. The solution will be based on serialising the XML element content in l to a string in a form defined by Exclusive XML Canonicalisation W3C Candidate Recommendation
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.
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()
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.
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()
If there are no attributes or only the optional rdf:ID attribute i then o := literal(literal-value="", literal-language=e.language) and the following statement is added to the model:
e.parent.subject.string-value <e.URI> o.string-value .
and then if i is given, the above statement is reified with identifier(identifier=concat(e.base-uri, "#", i.string-value), identifier-type="URI") using the reification rules in section 5.26.
Test: Indicated by test002.rdf and test002.nt
Test: Indicated by test005.rdf and test005.nt
Otherwise
If optional rdf:bagID attribute b is given, n := identifier(identifier=concat(e.base-uri, "#", b.string-value), identifier-type="URI")
The following can then be done in any order:
Add the following statement to the model:
e.parent.subject.string-value <e.URI> r.string-value .
and then if rdf:ID attribute i is given, the above statement is reified with identifier(identifier=concat(e.base-uri, "#", i.string-value), identifier-type="URI") using the reification rules in section 5.26.
For all propertyAttr a (in any order)
If a.URI = rdf:type then the following statement is added to the model:
r.string-value <a.URI> <a.string-value> .
Otherwise o := literal(literal-value=a.string-value, literal-language=e.language) andthe following statement is added to the model:
r.string-value <a.URI> o.string-value .
If node n is given then generate a local blank node identifier i and s := identifier(identifier=i, identifier-type="bnodeID"). Each statement above is then reified with node s using the reification rules in section 5.26 and the bag expansion rules in section 5.28 is applied on node n to give URI u. Then the following statement is added to the model:
n.string-value <u.string-value> s.string-value; .
Test: Indicated by test013.rdf and test013.nt
Test: Indicated by test014.rdf and test014.nt
If node n was created, add the following statement to the model:
n.string-value <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag> .
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
attribute(URI = rdf:about,
string-value=URI-reference)
attribute(URI = rdf:bagID,
string-value=rdf-id)
Constraint: See the constraint on rdf:ID values which also applies to rdf:bagID values.
attribute(URI=anyURI - ( rdf:RDF | rdf:Description | rdf:ID | rdf:about | rdf:bagID | rdf:parseType | rdf:resource | rdf:li ),
string-value=anyString)
attribute(URI = rdf:resource,
string-value=URI-reference)
attribute(URI = rdf:parseType,
string-value="Literal")
attribute(URI = rdf:parseType,
string-value="Resource")
attribute(URI = rdf:parseType,
string-value=anyString - ("Resource" | "Literal") )
An attribute ·string-value· interpreted as a URI reference defined in Uniform Resource Identifiers (URI) ([URIS]) BNF production URI-reference.
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
An attribute ·string-value· matching any legal [XML] token Nmtoken
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> .
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.
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.
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 but don't expect the RDF/XML that comes out to be exactly the same.
There are two different approaches to serialising RDF.
The basic approach uses the basic RDF syntax from [RDFMS]. In this:
rdf:Description
element, using an rdf:about
attribute.rdf:resource
attribute specifying
the object of the triple.The basic serialisation 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 serialisation proves unsatisfactory. The basic serialisation does not conform to more restricted sub-dialects of RDF, such as RSS[RSS] or CC/PP[CC/PP]. Hence, it is not appropriate for such applications, for which dialect specific serialisers are needed.
If more human readable output is needed the following factors should be considered:
It is not possible to use the RDF/XML serialisation for serialising 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. 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 serialising RDF/XML using the full grammar in a top-down recursive descent fashion is discussed in [UNPARSING].
The following people provided valuable contributions to the document:
This section records local issues to be resolved and issues that were reported to the RDF Core WG related to the XML syntax and their disposition. This section is not the definitive list or description of the latter - see the RDF Core WG issues list. Decided issues may also have associated test cases which can be found in the RDF Test Cases W3C Working Draft.
Add more an introductory section on how the syntax works including examples (graph, XML elements) based on the descriptive version in Dan Brickley's RDF: Understanding the Striped RDF/XML Syntax
(Feedback on 2001-12-18 draft): Consider basing on Infoset rather than SAX
(Feedback on 2001-12-18 draft): Consider changing nodeset terms to be, for example, events to prevent confusion with RDF graph nodes.
(Feedback on 2001-12-18 draft): Better introduction text with respect to RDF model, graph, model theory, N-Triples.
Does the treatment of literals conform to charmod ? [CHARMOD]
Action: ?
Does the treatment of uri-references conform with charmod? [CHARMOD]
Action: ?
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
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
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
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 recognised.
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.
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.
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.
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.
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
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.
On 7th December 2001, the WG decided to remove rdf:aboutEach from the language and consequently this issue was closed.
Action: None needed.
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.
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:
Action: None needed.
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.
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."
Action: None needed.
On 18th January 2002, the WG authorised 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 based on the Draft for RDF Media Type registration by Aaron Swartz.
Action: Added RDF MIME type section.
On 18th January 2002, the WG decided that "xml:base be allowed, and honoured, 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.10 Base URIs
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.
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.
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 - todo
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.
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.
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.
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.
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.
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 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 }* }
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.
Changes since the 18 December 2001 working draft
(Newest at top)
Changes since the 06 September 2001 working draft