RDF/XML Syntax Specification (Revised) (original) (raw)
Abstract
The Resource Description Framework (RDF) is a general-purpose language for representing information in the Web.
This document defines anXMLsyntax for RDF called RDF/XML in terms ofXML Namespaces, theXML Information Setand XML Base. The formal grammar for the syntax is annotated with actions generating triples of theRDF Graphas defined inRDF Concepts and Abstract Syntax. This is done using theN-TriplesRDF Graph serializing format which enables more precise recording of the mapping in a machine processable form. The mappings are recorded as tests cases, gathered and published inRDF Test Cases.
Status of this Document
This is a W3CLast Call Working Draftof the RDF Core Working Groupand has been produced as part of the W3CSemantic Web Activity(Activity Statement).
This document is in the Last Call review period, which ends on 21 February 2003. This document has been endorsed by the RDF Core Working Group.
This document revises RDF/XML from the original definition in thegrammar section ofRDF Model & Syntax [RDF-MS] W3C Recommendation after decisions made by the RDF Core Working Group. In particular, the formal grammaris now in terms of theXML Information Set [INFOSET].
In this revision, new support was added forXML Base [XML-BASE], RDF Datatyping with Typed Literals using rdf:datatype
,rdf:nodeID
to allow referencing of Blank Nodes andrdf:parseType="Collection"
for expressing a collection ofNodes. The revision removedrdf:aboutEach
and rdf:aboutEachPrefix
from the syntax (see RDF Core issues rdfms-aboutEach-on-object andrdfms-abouteachprefix).
The detailed changes from the previous8 November 2002 working draftare described in the Changes section.
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 made affect existing implementations and content.
In conformance withW3C policyrequirements, known patent andIPRconstraints associated with this Working Draft are detailed on theRDF Core Working Group Patent Disclosure page.
Comments on this document are invited and should be sent to the public mailing listwww-rdf-comments@w3.org. An archive of comments is available athttp://lists.w3.org/Archives/Public/www-rdf-comments/.
This is a public W3C Last Call Working Draft for review by W3C Members and other interested parties. This section describes the status of this document at the time of its publication. It is a draft document 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://www.w3.org/TR/.
1 Introduction
This document defines theXML [XML]syntax for RDF Graphs which was originally defined in theRDF 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.
The RDF Core Working Groupis charteredto respond to the need for a number of fixes, clarifications and improvements to the specification of RDF's abstract graph and XML syntax as recorded in theRDF Core Working Group issues list. The Working Group invites feedback from the developer community on the effects of its proposals on existing implementations and documents.
This document revises theoriginal RDF/XML grammarin terms ofXML Information Set [INFOSET] Information Items which moves away from the rather low-level details of XML, 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 theN-Triplessection ofRDF Test Cases [RDF-TESTS] Working Draft which creates an RDF Graph, that has semantics defined byRDF Semantics [RDF-SEMANTICS] Working Draft.
The complete specification of RDF consists of a number of documents:
- RDF Primer [RDF-PRIMER]
- RDF Concepts and Abstract Syntax [RDF-CONCEPTS]
- RDF Semantics [RDF-SEMANTICS]
- RDF/XML syntax (this document)
- RDF Vocabulary Description Language 1.0: RDF Schema [RDF-VOCABULARY]
- RDF Test Cases [RDF-TESTS]
2 An XML syntax for RDF
This section introduces the RDF/XML syntax, describes how it encodes RDF Graphs and explains this with examples. If there is any conflict between this informal description and the formal description of the syntax and grammar in sections6 Syntax Data Model and7 RDF/XML Grammar, the latter two sections take precedence.
2.1 Introduction
TheRDF Concepts and Abstract Syntax [RDF-CONCEPTS] working draft defines theRDF Graph data model (Section 3.1) and theRDF Graph syntax (Section 6.2). Along with theRDF Semantics [RDF-SEMANTICS] working draft this provides an abstract syntax with a formal semantics for it. The RDF Graph hasNodesand labeled directed Arcs_that link pairs of Nodes and this is represented as a set of RDF tripleswhere each triple contains a_Subject Node, Property Arc and Object Node. Nodes areRDF URI References, RDF Literalsor are Blank Nodes. Blank Nodes may be given a document-local, non-RDF URI References identifier called aBlank Node Identifier.Arcs are labeled withRDF URI References. The property arc can be interpreted as either a relationship between two nodes or as defining an attribute value (object node) for some subject node.
In order to encode the graph in XML, the nodes and arcs have to be represented by XML element names, attribute names, element content and attribute content. RDF/XML uses XMLQNames to representRDF URI References. The namespace prefixpart of all QNames is associated with a URI Reference as defined inXML Namespaces [XML-NS]. TheRDF URI Referencerepresented by a QName is determined by appending thelocal namepart of the QName to the URI Reference associated with the namespace prefix part of the QName. This is used to shorten theRDF URI Referencesof all property arcs labels and some nodes.RDF URI References identifying subject and object nodes can also be stored as XML attribute values or XML element names via QNames.RDF Literals(which are only object nodes) become either XML element text content or XML attribute values.
A graph can be considered a collection of paths of the form Node, Arc, Node, Arc, Node, Arc, ... Node which cover the entire graph. In RDF/XML these turn into sequences of elements inside elements which alternate between elements for Nodes and Arcs. This has been called a series of Node/Arc stripes. The Node at the start of the sequence turns into the outermost element, the next arc turns into a child element, and so on. The stripes generally start at the top of an RDF/XML document and always begin with nodes.
Several RDF/XML examples are given in the following sections building up to complete RDF/XML documents. Example 7is the first complete RDF/XML document.
2.2 Node Elements and Property Elements
An RDF Graph is given in Figure 1where the nodes are represented as ovals and contain theirRDF URI Referenceswhere they have them, all the arcs are labeled withRDF URI ReferencesandPlain Literalnodes have been written in rectangles.
If we follow one Node, Arc ... , Node path through the graph shown inFigure 2:
This corresponds to the Node/Arc stripes:
- Node with RDF URI Reference
http://www.w3.org/TR/rdf-syntax-grammar
- Arc labeled with RDF URI Reference
http://example.org/terms/editor
- Node with no RDF URI Reference
- Arc labeled with RDF URI Reference
http://example.org/terms/homePage
- Node with RDF URI Reference
http://purl.org/net/dajobe/
In RDF/XML, the sequence of 5 nodes and arcs inFigure 2 corresponds to the usage of 5 XML elements of two types, for the graph nodes and arcs. These are conventionally called Node Elements and_Property Elements_ respectively. In the striping shown inExample 1, rdf:Description
is the node element (used 3 times for the three nodes) andex:editor
and ex:homePage
are the 2 property elements.
<rdf:Description> <ex:editor> <rdf:Description> <ex:homePage> <rdf:Description> </rdf:Description> </ex:homePage> </rdf:Description> </ex:editor> </rdf:Description>
The Figure 2 graph consists of some nodes that areRDF URI References(and others that are not) and this can be added to the RDF/XML using the rdf:about
attribute on node elements to give the result in Example 2:
<rdf:Description rdf:about="" title="undefined" rel="noopener noreferrer">http://www.w3.org/TR/rdf-syntax-grammar"> ex:editor rdf:Description ex:homePage <rdf:Description rdf:about="" title="undefined" rel="noopener noreferrer">http://purl.org/net/dajobe/">
Adding the other two paths through the Figure 1graph to the RDF/XML inExample 2gives the result in Example 3(this example fails to show that the blank node is shared between the two paths, see 2.10):
<rdf:Description rdf:about="" title="undefined" rel="noopener noreferrer">http://www.w3.org/TR/rdf-syntax-grammar"> ex:editor rdf:Description ex:homePage <rdf:Description rdf:about="" title="undefined" rel="noopener noreferrer">http://purl.org/net/dajobe/">
<rdf:Description rdf:about="" title="undefined" rel="noopener noreferrer">http://www.w3.org/TR/rdf-syntax-grammar"> ex:editor rdf:Description ex:fullNameDave Beckett
<rdf:Description rdf:about="" title="undefined" rel="noopener noreferrer">http://www.w3.org/TR/rdf-syntax-grammar"> dc:titleRDF/XML Syntax Specification (Revised)
2.3 Multiple Property Elements
There are several abbreviations that can be used to make common uses easier to write down. In particular, it is common that a subject node in the RDF Graph has multiple outgoing arcs. RDF/XML provides an abbreviation for the corresponding syntax when a node element about a resource has multiple property elements. This can be abbreviated by using multiple child property elements inside the node element describing the subject node.
Taking Example 3, there are two node elements that can take multiple property elements. The subject node with URI Referencehttp://www.w3.org/TR/rdf-syntax-grammar
has property elements ex:editor
and ex:title
and the node element for the blank node can take ex:homePage
and ex:fullName
. This abbreviation gives the result shown in Example 4(this example does show that there is a single blank node):
<rdf:Description rdf:about="" title="undefined" rel="noopener noreferrer">http://www.w3.org/TR/rdf-syntax-grammar"> ex:editor rdf:Description ex:homePage <rdf:Description rdf:about="" title="undefined" rel="noopener noreferrer">http://purl.org/net/dajobe/"> ex:fullNameDave Beckett dc:titleRDF/XML Syntax Specification (Revised)
2.4 Empty Property Elements
When an arc in an RDF Graph points to an object node which has no further arcs, which appears in RDF/XML as an empty node element sequence such as the pair<rdf:Description rdf:about="...">
</rdf:Description>
, this form can be shortened. This is done by using the RDF URI Referenceof the object node as the value of an XML attribute rdf:resource
on the containing property element and making the property element empty.
In this example, the property element ex:homePage
contains an empty node element with theRDF URI Reference http://purl.org/net/dajobe/
. This can be replaced with the empty property element form giving the result shown inExample 5:
<rdf:Description rdf:about="" title="undefined" rel="noopener noreferrer">http://www.w3.org/TR/rdf-syntax-grammar"> ex:editor rdf:Description <ex:homePage rdf:resource="" title="undefined" rel="noopener noreferrer">http://purl.org/net/dajobe/"/> ex:fullNameDave Beckett dc:titleRDF/XML Syntax Specification (Revised)
2.5 Property Attributes
When a property element's content is string literal, it may be possible to use it as an XML attribute on the containing node element. This can be done for multiple properties on the same node element only if the property element name is not repeated (required by XML - attribute names are unique on an XML element) and any in-scope xml:lang
on the property element's string literal (if any) are the same (see Section 2.7) This abbreviation is known as a _Property Attribute_and can be applied to any node element or with therdf:parseType="Resource"
form (see Section 2.11).
This abbreviation can also be used when the property element isrdf:type
and it has an rdf:resource
attribute the value of which is interpreted as aRDF URI Reference object node.
In Example 5:, there are two property elements with string literal content, the dc:title
and ex:fullName
property elements. These can be replaced with property attributes giving the result shown in Example 6:
<rdf:Description rdf:about="http://www.w3.org/TR/rdf-syntax-grammar" dc:title="RDF/XML Syntax Specification (Revised)"> ex:editor <rdf:Description ex:fullName="Dave Beckett"> <ex:homePage rdf:resource="" title="undefined" rel="noopener noreferrer">http://purl.org/net/dajobe/"/>
2.6 Completing the Document - Document Element and XML Declaration
To create a complete RDF/XML document, the serialization of the graph into XML must be contained inside an rdf:RDF
XML element which becomes the top-level XML document element. Conventionally the rdf:RDF
element is also used to declare the XML namespaces that are used, although that is not required. The XML specification also permits an XML declaration at the top of the document with the XML version and possibly the XML content encoding (this is optional but recommended).
This could be done for any of the correct complete graph examples fromExample 4 onwards but taking the smallestExample 6 and adding the final components, gives a complete RDF/XML representation of the originalFigure 1 graph in Example 7:
<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="" title="undefined" rel="noopener noreferrer">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)"> ex:editor <rdf:Description ex:fullName="Dave Beckett"> <ex:homePage rdf:resource="http://purl.org/net/dajobe/" />
2.7 Languages - xml:lang
RDF/XML permits the use of the xml:lang
attribute as defined by2.12 Language Identificationof XML 1.0 [XML]to allow the identification of content language. This can be used on any node element or property element to indicate that the included content is in the given language. The most specific in-scope language present (if any) is applied to property element string literal content or property attribute values. The xml:lang=""
form indicates the absence of a language identifier.
Some examples of marking content languages for RDF properties are shown inExample 8:
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="" title="undefined" rel="noopener noreferrer">http://purl.org/dc/elements/1.1/"> <rdf:Description rdf:about="" title="undefined" rel="noopener noreferrer">http://www.w3.org/TR/rdf-syntax-grammar"> dc:titleRDF/XML Syntax Specification (Revised) <dc:title xml:lang="en">RDF/XML Syntax Specification (Revised) <dc:title xml:lang="en-US">RDF/XML Syntax Specification (Revised)
<rdf:Description rdf:about="http://example.org/buchen/baum" xml:lang="de"> dc:titleDas Baum dc:descriptionDas Buch ist au�ergew�hnlich <dc:title xml:lang="en">The Tree
2.8 XML Literals - rdf:parseType="Literal"
RDF allows XML Literals([RDF-CONCEPTS] Section 5, XML Content within an RDF Graph) to be given as the object node of arcs. These are written in RDF/XML as content of a property element (not a property attribute) and indicated using therdf:parseType="Literal"
attribute on the containing property element.
An example of writing an XML literal is given inExample 9 where there is a single RDF triple with the subject nodeRDF URI Reference http://example.org/item01
, the arc labelRDF URI Reference http://example.org/stuff/1.0/prop
(fromex:prop
) and the object node with XML Literal content beginning a:Box
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:ex="" title="undefined" rel="noopener noreferrer">http://example.org/stuff/1.0/"> <rdf:Description rdf:about="" title="undefined" rel="noopener noreferrer">http://example.org/item01"> <ex:prop rdf:parseType="Literal" xmlns:a="" title="undefined" rel="noopener noreferrer">http://example.org/a#"><a:Box required="true"> <a:widget size="10" /> <a:grommit id="23" />
2.9 Typed Literals - rdf:datatype
RDF allowsTyped Literalsto be given as the object node of arcs. These consist of a literal string (with optional language) and a datatypeRDF URI Reference. This is handled by using the same syntax for literal string nodes in the property element form (not property attribute) but with an additionalrdf:datatype="
datatypeURI"
attribute on the property element. Any RDF URI Reference can be used in the attribute.
An example of an RDFTyped Literalis given in Example 10 where there is a single RDF triple with the subject nodeRDF URI Reference http://example.org/item01
, the arc labelRDF URI Reference http://example.org/stuff/1.0/size
(fromex:size
) and the object node with theTyped Literal("123", http://www.w3.org/2001/XMLSchema#int
, no language xml:lang=""
) intending to be interpreted as a W3C XML Schema datatype int.
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:ex="" title="undefined" rel="noopener noreferrer">http://example.org/stuff/1.0/"> <rdf:Description rdf:about="" title="undefined" rel="noopener noreferrer">http://example.org/item01"> <ex:size rdf:datatype="123" title="undefined" rel="noopener noreferrer">http://www.w3.org/2001/XMLSchema#int">123
2.10 Identifying Blank Nodes - rdf:nodeID
Blank Nodes in the RDF Graph are distinct but have no RDF URI Reference identifier. It is sometimes required that the same graph Blank Node is referred to in the RDF/XML in multiple places, such as at the subject and object of several RDF triples. In this case, a Blank Node Identifiercan be given to the Blank Node for identifying it in the document. Blank node identifiers in RDF/XML are scoped to the XML Information SetDocument Information Item. A Blank Node Identifier is used on a node element to replacerdf:about="
RDF URI Reference"
or on a property element to replacerdf:resource="
RDF URI Reference"
with rdf:nodeID="
Blank Node Identifier"
in both cases.
Taking Example 7 and explicitly giving a Blank Node Identifier of abc
to the blank node in it gives the result shown in Example 11. The second rdf:Description
property element is about the blank node.
<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="" title="undefined" rel="noopener noreferrer">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)"> <ex:editor rdf:nodeID="abc"/>
<rdf:Description rdf:nodeID="abc" ex:fullName="Dave Beckett"> <ex:homePage rdf:resource="" title="undefined" rel="noopener noreferrer">http://purl.org/net/dajobe/"/>
2.11 Omitting Blank Nodes - rdf:parseType="Resource"
Blank Nodes (not RDF URI Reference nodes) in RDF Graphs can be written in a form that allows the<rdf:Description>
</rdf:Description>
pair to be omitted. This can be done by putting anrdf:parseType="Resource"
attribute on the containing property element that turns the property element into a property and node element, which can itself have both property elements and property attributes. Property attributes and the rdf:nodeID
attribute are not permitted on such property elements.
Taking the earlier Example 7, the contents of the ex:editor
property element could be alternatively done in this fashion to give the form shown in Example 12:
<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="" title="undefined" rel="noopener noreferrer">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)"> <ex:editor rdf:parseType="Resource"> ex:fullNameDave Beckett <ex:homePage rdf:resource="" title="undefined" rel="noopener noreferrer">http://purl.org/net/dajobe/"/>
2.12 Omitting Nodes - Property Attributes on an empty Property Element
If all of the property elements on a blank node element have string literal values with the same in-scope xml:lang
value (if present) and each of these property elements appears at most once and there is at most one rdf:type
property element with a RDF URI Reference object node, these can be abbreviated by moving them to be property attributes on the containing property element which is made an empty element.
Taking the earlier Example 5, the ex:editor
property element contains a blank node element with two property elementsex:fullname
and ex:homePage
.ex:homePage
is not suitable here since it does not have a string literal value, so it is being_ignored_. The abbreviated form movesex:fullName
property element to be a property attribute on the ex:editor
property element and the blank node element becomes implicit. The result is shown inExample 13.
<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="" title="undefined" rel="noopener noreferrer">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)"> <ex:editor ex:fullName="Dave Beckett" />
2.13 Typed Node Elements
It is common for RDF Graphs to have rdf:type
arcs from subject nodes. These are conventionally called Typed Nodes in the graph, or Typed Node Elements in the RDF/XML. RDF/XML allows this triple to be expressed more concisely. by replacing the rdf:Description
node element name with the namespaced-element corresponding to theRDF URI Reference of the value of the type relationship. There may, of course, be multiple rdf:type
arcs but only one can be used in this way, the others must remain as property elements or property attributes.
This form is also commonly used in RDF/XML with the built-in classes in The RDF Namespace:rdf:Seq
, rdf:Bag
, rdf:Alt
,rdf:Statement
, rdf:Property
andrdf:List
.
For example, the RDF/XML in Example 14could be written as shown in Example 15.
<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="" title="undefined" rel="noopener noreferrer">http://example.org/stuff/1.0/"> <rdf:Description rdf:about="" title="undefined" rel="noopener noreferrer">http://example.org/thing"> <rdf:type rdf:resource="" title="undefined" rel="noopener noreferrer">http://example.org/stuff/1.0/Document"/> dc:titleA marvelous thing
<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="" title="undefined" rel="noopener noreferrer">http://example.org/stuff/1.0/"> <ex:Document rdf:about="" title="undefined" rel="noopener noreferrer">http://example.org/thing"> dc:titleA marvelous thing
2.14 Abbreviating URIs - rdf:ID
and xml:base
RDF/XML allows further abbreviating RDF URI References in XML attributes in two ways. The XML Infoset provides a base URI attribute xml:base
that sets the base URI for resolving relative RDF URI References, otherwise the base URI is that of the document. This applies to all RDF/XML attributes that deal with RDF URI References which are rdf:about
,rdf:resource
, rdf:ID
, rdf:bagID
and rdf:datatype
.
The rdf:ID
attribute on a node element (not property element, that has another meaning) can be used instead ofrdf:about
and gives a relative RDF URI Reference equivalent to #
concatenated with the rdf:ID
attribute value. So for example if rdf:ID="name"
, that would be equivalent to rdf:about="#name"
. This provides an additional check since the same name can only appear once in the scope of an xml:base
value (or document, if none is given), so is useful for defining a set of distinct, related terms relative to the same RDF URI Reference.
Example 16 shows abbreviating the nodeRDF URI Reference of http://example.org/here/#snack
using anxml:base
of http://example.org/here/
and an rdf:ID
on the rdf:Description
node element. The object node of the ex:prop
arc is an absolute RDF URI Referenceresolved from the rdf:resource
XML attribute content using the in-scope base URI to give theRDF URI Reference http://example.org/here/fruit/apple
.
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:ex="http://example.org/stuff/1.0/" xml:base="" title="undefined" rel="noopener noreferrer">http://example.org/here/"> <rdf:Description rdf:ID="snack"> <ex:prop rdf:resource="fruit/apple"/>
2.15 Container membership property elements - rdf:li
and rdf:_
n
RDF has a set of container membership properties and corresponding property elements that are mostly used with instances of therdf:Seq
, rdf:Bag
and rdf:Alt
classes which may be written as typed node elements. The list properties arerdf:_1
, rdf:_2
etc. and can be written as property elements or property attributes as shown inExample 17. There is an rdf:li
special property element that is equivalent tordf:_1
, rdf:_2
in order, explained in detail in section 7.4. The equivalent RDF/XML to Example 17 written in this form is shown in Example 18.
<rdf:RDF xmlns:rdf="" title="undefined" rel="noopener noreferrer">http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Seq rdf:about="" title="undefined" rel="noopener noreferrer">http://example.org/favourite-fruit"> <rdf:_1 rdf:resource="" title="undefined" rel="noopener noreferrer">http://example.org/banana"/> <rdf:_2 rdf:resource="" title="undefined" rel="noopener noreferrer">http://example.org/apple"/> <rdf:_3 rdf:resource="" title="undefined" rel="noopener noreferrer">http://example.org/pear"/>
<rdf:RDF xmlns:rdf="" title="undefined" rel="noopener noreferrer">http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Seq rdf:about="" title="undefined" rel="noopener noreferrer">http://example.org/favourite-fruit"> <rdf:li rdf:resource="" title="undefined" rel="noopener noreferrer">http://example.org/banana"/> <rdf:li rdf:resource="" title="undefined" rel="noopener noreferrer">http://example.org/apple"/> <rdf:li rdf:resource="" title="undefined" rel="noopener noreferrer">http://example.org/pear"/>
2.16 Collections - rdf:parseType="Collection"
RDF/XML allows an rdf:parseType="Collection"
attribute on a property element to let it contain multiple node elements. These contained node elements give the set of subject nodes of the collection. This syntax form corresponds to a set of triples connecting the collection of subject nodes, the exact triples generated are described in detail inSection 7.2.19 Production parseTypeCollectionPropertyElt.
Example 19 shows a collection of three nodes elements at the end of the ex:hasFruit
property element using this form.
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:ex="" title="undefined" rel="noopener noreferrer">http://example.org/stuff/1.0/"> <rdf:Description rdf:about="" title="undefined" rel="noopener noreferrer">http://example.org/basket"> <ex:hasFruit rdf:parseType="Collection"> <rdf:Description rdf:about="" title="undefined" rel="noopener noreferrer">http://example.org/banana"/> <rdf:Description rdf:about="" title="undefined" rel="noopener noreferrer">http://example.org/apple"/> <rdf:Description rdf:about="" title="undefined" rel="noopener noreferrer">http://example.org/pear"/>
2.17 Reifying Statements - rdf:bagID
and rdf:ID
The rdf:ID
attribute can be used on a property element to reify the triple that it generates (Seesection 7.3 Reification Rules for the full details). The identifier for the triple should be constructed as aRDF URI Referencemade from the relative URI Reference#
concatenated with the rdf:ID
attribute value, resolved against the in-scope base URI. So for example ifrdf:ID="triple"
, that would be equivalent to the RDF URI Referenceformed from relative URI Reference #triple
against the base URI. Each (rdf:ID
attribute value, base URI) pair has to be unique in an RDF/XML document and comes from the same set of values as the rdf:bagID
attribute. See constraint-id.
Example 20 shows a rdf:ID
being used to reify a triple made from the ex:prop
property element giving the reified triple theRDF URI Reference http://example.org/triples/#triple1
.
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:ex="http://example.org/stuff/1.0/" xml:base="" title="undefined" rel="noopener noreferrer">http://example.org/triples/"> <rdf:Description rdf:about="" title="undefined" rel="noopener noreferrer">http://example.org/"> <ex:prop rdf:ID="triple1">blah
The rdf:bagID
attribute can be used on a node element or empty property element with property attributes, to give an identifier for an rdf:Bag
that lists the reifications of the statements generated by the property elements or attributes. This allows statements to be made about that bag. The identifier is constructed as a relative RDF URI Reference of #
concatenated with the rdf:bagID
attribute value, resolved against the in-scope base URI to give anRDF URI Reference. So for example if rdf:bagID="bag"
, that would be equivalent to the RDF URI Reference formed from relative URI Reference #bag
against the base URI. Each (rdf:bagID
attribute value, base URI) has to be unique in the RDF/XML document and from the same set of names as rdf:ID
. See constraint-id.
Example 21 shows a rdf:Bag
with RDF URI Reference http://example.org/bags/#bag1
being made of the triples from inside the rdf:Description
node element.
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:ex="http://example.org/stuff/1.0/" xml:base="" title="undefined" rel="noopener noreferrer">http://example.org/bags/"> <rdf:Description rdf:about="http://example.org/" rdf:bagID="bag1"> ex:prop1blah <ex:prop2 rdf:resource="" title="undefined" rel="noopener noreferrer">http://example.org/elsewhere/"/>
2.18 More Information (Informative)
The RDF Core Working Group has developed anRDF Primer [RDF-PRIMER]that goes into detail introducing RDF and its applications.
For a longer introduction to the RDF/XML striped syntax with a historical perspective, see RDF: Understanding the Striped RDF/XML Syntax [STRIPEDRDF].
3 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 inRFC 2119 [KEYWORDS].
4 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.
**Registration Note:**The RDF Core Working Group will register this type with the IETF after this document has passed the Working Draft state, possibly afterRecommendation, using the application/rdf+xml Media Type RegistrationInternet Draft[RDF-MIMETYPE-ID]already published and maintained.
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).
5 Global Issues
5.1 The RDF Namespace
**Note:**The names aboutEach
and aboutEachPrefix
were removed from the language and the RDF namespace by the RDF Core Working Group. See the resolution of issuesrdfms-abouteach andrdfms-abouteachprefixfor further information.
**Note:**The names List
, first
,rest
and nil
were added for issuerdfms-seq-representation. The names XMLLiteral
and datatype
were added to support RDF datatyping. The name nodeID
was added for issuerdfms-syntax-incomplete. See theRDF Core Issues Listfor further information.
**Note:**The Working Group invites feedback from the community on the effects of the removals and additions of these terms 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).
TheRDF Namespace URI Reference ishttp://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 - not concepts
RDF Description ID about bagID parseType resource li nodeID datatype
Class names
Seq Bag Alt Statement Property XMLLiteral List
Property names
subject predicate object type value first rest _
n
where n is a decimal integer greater than zero with no leading zeros.
Resource names
nil
Any other names are not defined and SHOULD generate a warning when encountered, but should otherwise behave normally.
Within RDF/XML documents it is not permitted to use XML namespaces whose namespace URI is either:
- the �RDF Namespace URI Reference� concatenated with additional characters. or
- the XML Namespace URI reference concatenated with additional characters.
Throughout this document the terminology rdf:
_name_will be used to indicate name is from the RDF namespace and it has a RDF URI Reference of the concatenation of the�RDF Namespace URI Reference� and name. For example, rdf:type
has the RDF URI Reference http://www.w3.org/1999/02/22-rdf-syntax-ns#type
5.2 Identifiers
TheRDF Graph(RDF Concepts and Abstract Syntax Section 3) defines three types of nodes and one type of arc:
RDF URI Reference nodes and arcs
RDF URI References (RDF Concepts and Abstract Syntax Section 3.1) can be either given as XML attribute values interpreted as absolute RDF URI References, XML attribute values interpreted as relative URI References that are resolved with the in-scope base URI as described in section section 5.3to give absolute RDF URI References, transformed from XML Namespace-qualified element and attributes names (QNames) or transformed from rdf:ID
and rdf:bagID
attribute values.
Within RDF/XML, XML QNames are transformed intoRDF URI Referencesby appending the XML local name to the namespace URI. For example, if the XML Namespace prefix foo
has URIhttp://example.org/somewhere/
then the QNamefoo:bar
would correspond to the URIhttp://example.org/somewhere/bar
. Note that this restricts whichRDF URI References can be made and the same URI can be given in multiple ways.
The rdf:ID andrdf:bagID values are transformed into anRDF URI Referencesby appending the attribute value to the result of appending "#" to the in-scope base URI which is defined inSection 5.3 Resolving URIs
Literal nodes (always object nodes)
RDF Literals (RDF Concepts and Abstract Syntax 6.5) are eitherPlain Literals (ibid), orTyped Literals (ibid). The latter includes XML Literals (ibid section 5, XML Content within an RDF Graph).
Blank Node Identifiers
Blank Nodes have distinct identity in the RDF Graph. When the graph is written in a syntax such as RDF/XML, these blank nodes may need graph-local identifiers and a syntax in order to preserve this distinction. These local identifiers are calledBlank Node Identifiersand are used in RDF/XML as values of the rdf:nodeID
attribute with the syntax given in Production nodeIdAttr. Blank node identifiers in RDF/XML are scoped to the XML Information SetDocument Information Item.
These identifiers may also be generated as part of the mapping from the RDF/XML to the graph for new distinct blank nodes. Such generated blank node identifiers must not clash with any blank node identifiers from rdf:nodeID
attribute values. This can be implemented by any method that preserves the distinct identity of all the blank nodes in the graph. One method would be to add a constant prefix to all the rdf:nodeID
attribute values and ensure no generated blank node identifiers ever used that prefix.
5.3 Resolving URIs
RDF/XML supports XML Base [XML-BASE]which defines a�base-uri�accessor for each�root event� and�element event�. Relative URI References are resolved intoRDF URI Referencesaccording to the algorithm specified inXML Base [XML-BASE](and RFC 2396). These specifications do not specify an algorithm for resolving a fragment identifier alone, such as #foo
, or the empty string ""
into anRDF URI Reference. In RDF/XML, a fragment identifier is transformed into aRDF URI Referenceby appending the fragment identifier to the in-scope base URI. The empty string is transformed into anRDF URI Referenceby substituting the in-scope base URI.
An empty same document reference "" resolves against the URI part of the Base URI; any fragment part is ignored. SeeUniform Resource Identifiers (URI) [URIS] section 4.2
**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.
5.4 Constraints
constraint-id
Each application of productions idAttrand bagIdAttr match an attribute. The pair formed by the�string-value�accessor of the matched attribute and the�base-uri�accessor of the matched attribute is unique within a single RDF/XML document.
The syntax of the names must match therdf-id production
6 Syntax Data Model
This document specifies the syntax of RDF/XML as a grammar on an alphabet of symbols. The symbols are called Events in the style of the [XPATH] Information Set Mapping. A sequence of events is normally derived from an XML document, in which case they are in document order as defined below in Section 6.2 Information Set Mapping. This sequence of events formed are intended to be similar to the sequence of events produced by the [SAX2] XML API from the same XML document. Sequences of events may be checked against the grammar to determine whether they are or are not syntactically well formed RDF/XML.
The grammar productions may include actions which fire when the production is recognised. Taken together these actions define a transformation from any syntactically well formed RDF/XML sequence of events into an RDF Graph represented in theN-Tripleslanguage.
This model illustrates one way to create a representation of an RDF Graphfrom an RDF/XML document. It does not mandate any implementation method - any other method that results in a representation of the sameRDF Graphmay be used.
In particular:
- This specification does not require thatN-Triplesbe used to represent an RDF Graph.
- This specification does not require the use of[XPATH] or [SAX2]
- This specification places no constraints on the order in which software transforming RDF/XML into a representation of a graph, constructs the representation of the graph.
- Software transforming RDF/XML into a representation of a graph MAY eliminate duplicate arcs.
The syntax does not support non-well-formed XML documents, nor documents that otherwise do not have an XML Information Set; for example, that do not conform toXML Namespaces [XML-NS].
The Infoset requires support forXML Base [XML-BASE]. RDF/XML uses the information item property [base URI], discussed insection 5.3
This specification requires an XML Information Set[INFOSET]which supports at least the following information items and properties for RDF/XML:
[document element], [children], [base URI]
[local name], [namespace name], [children], [attributes], [parent], [base URI]
[local name], [namespace name], [normalized value]
[character code]
There is no mapping of the following items to data model events:
Processing Instruction Information Item
Unexpanded Entity Reference Information Item
Document Type Declaration Information Item
Unparsed Entity Information Item
Other information items and properties have no mapping to syntax data model events.
Information items contained inside XML elements matching theparseTypeLiteralPropertyEltproduction formXML Literalsand do not follow this mapping. SeeparseTypeLiteralPropertyEltfor further information.
This section is intended to satisfy the requirements forConformancein the [INFOSET] specification. It specifies the information items and properties that are needed to implement this specification.
6.1 Events
There are six types of event defined in the following subsections. Most events are constructed from an Infoset information item (except for Identifier,Plain Literal andTyped Literal). The effect of an event constructor is to create a new event with a unique identity, distinct from all other events. Events have accessor operations on them. and all have the string-value accessor that may be a static value or computed.
6.1.1 Root Event
Constructed from aDocument Information Itemand takes the following accessors and values.
document-element
Set to the value of document information item property document-element.
children
Set to the value of document information item property [children].
base-uri
Set to the value of document information item property [base URI].
language
Set to the empty string.
6.1.2 Element Event
Constructed from an Element Information Itemand takes the following accessors and values:
local-name
Set to the value of element information item property [local name].
namespace-name
Set to the value of element information item property [namespace name].
children
Set to the value of element information item property [children].
base-uri
Set to the value of element information item property [base URI].
attributes
Set to the value of element information item property [attributes].
If the value contains an attribute event 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"), it is removed from the list of attributes and the �language� accessor is set to the string-value of the attribute.
All other attributes beginning with xml
are then removed (that is, all attributes with �namespace-name� accessors values beginning with "http://www.w3.org/XML/1998/namespace"). Note: the base URI is computed before any xml:base
attribute is deleted.
URI
Set to the string value of the concatenation of the value of the namespace-name accessor and the value of the local-name accessor.
li-counter
Set to the integer value 1.
bag-li-counter
set to the integer value 1.
language
Set from the�attributes� as described above. If no value is given from the attributes, the value is set to the value of the language accessor on the parent event (either aRoot Event or anElement Event), which may be the empty string.
subject
Has no initial value. Takes a value that is anIdentifier event. This is used on elements that deal with one node in the RDF Graph, this generally being the subject of a statement.
6.1.3 End Element Event
Has no accessors. Marks the end of the containing element in the sequence.
6.1.4 Attribute Event
Constructed from an Attribute Information Itemand takes the following accessors and values:
local-name
Set to the value of attribute information item property [local name].
namespace-name
Set to the value of attribute information item property [namespace name].
string-value
set to the value of the attribute information item property [normalized value] as specified by[XML] (if an attribute whose normalized value is a zero-length string, then the string-value is also a zero-length string).
URI
If �namespace-name� is present, set to a string value of the concatenation of the value of the�namespace-name� accessor and the value of the�local-name� accessor. Otherwise if �local-name� isID
, bagID
, about
, resource
, parseType
or type
, set to a string value of the concatenation of the�RDF Namespace URI Reference� and the value of the �local-name� accessor. Other non-namespaced �local-name� accessor values are forbidden.
This support for a limited set of non-namespaced names is REQUIRED and intended to allow RDF/XML documents specified in[RDF-MS] to remain valid; new documents SHOULD NOT use these unqualified attributes and applications MAY choose to warn when the unqualified form is seen in a document.
The construction ofRDF URI References from XML attributes can generate the sameRDF URI References from different XML attributes. This can cause ambiguity in the grammar when matching attribute events (such as whenrdf:about
and about
XML attributes are both present). Documents that have this are illegal.
6.1.5 Text Event
Constructed from a sequence of one or more consecutiveCharacter Information Items. Has the single accessor:
string-value
Set to the value of the string made from concatenating the [character code] property of each of the character information items.
6.1.6 URI Reference Event
An event for aRDF URI Referenceswhich has the following accessors:
identifier
Takes a string value.
string-value
The value is the concatenation of "<", the value of the �identifier� accessor and ">"
These events are constructed by giving a value for the�identifier� accessor.
For further information on identifiers in the RDF Graph, seesection 5.2.
6.1.7 Blank Node Identifier Event
An event for aBlank Node Identifier which has the following accessors:
identifier
Takes a string value.
string-value
The value is the concatenation of "_:" and the value of the �identifier� accessor.
These events are constructed by giving a value for the�identifier� accessor.
For further information on identifiers in the RDF Graph, seesection 5.2.
6.1.8 Plain Literal Event
An event for a Plain Literal which can have the following accessors:
literal-value
Takes a string value.
literal-language
Takes a string value.
string-value
The value is calculated from the other accessors as follows.
If �literal-language� is the empty string then the value is the concatenation of """ (1 double quote), the value of the 2 �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-Triplesstring escapes for escaping certain characters such as ".
These events are constructed by giving values for the�literal-value� and�literal-language� accessors.
Note: Literals beginning with a Unicode combining character are allowed however they may cause interoperability problems. See [CHARMOD] for further information.
6.1.9 Typed Literal Event
An event for a Typed Literal which can have the following accessors:
literal-value
Takes a string value.
literal-language
Takes a string value.
literal-datatype
Takes a string value used as an absolute URI reference..
string-value
The value is calculated from the other accessors as follows.
If �literal-language� is the empty string 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.
Finally, if �literal-datatype� is not empty then append to the value calculated above "^^<" concatenated with the value of the�literal-datatype� accessor concatenated with ">".
Note that the double-quoted literal-value string must use the N-Triplesstring escapes for escaping certain characters such as ".
These events are constructed by giving values for the�literal-value�,�literal-language� and�literal-datatype� accessors.
Note: Literals beginning with a Unicode combining character are allowed however they may cause interoperability problems. See [CHARMOD] for further information.
6.2 Information Set Mapping
To transform the Infoset into the sequence of events in document order, each information item is transformed as described above to generate a tree of events with accessors and values. Each element event is then replaced as described below to turn the tree of events into a sequence in document order.
- The original element event
- The value of thechildrenaccessor recursively transformed, a possibly empty ordered list of events.
- An end element event
6.3 Grammar Notation
The following notation is used for matching the sequence of events generated as described in Section 6and describing the actions to perform for the matches. The RDF/XML grammar is defined here in terms of its data model events, using statements of the form:
number event-type event-content
where the event-content is an expression, which may refer to other event-types (as defined inSection 6.1), using constructs of the form given in the following table. The number is used for reference purposes. The action may include generating new triples to the graph, written inN-Triplesformat.
Notation for matching events and grammar actions.
General Notation | ||
---|---|---|
Notation | Meaning | |
event.accessor | The value of an event accessor. | |
rdf:X | A URI as defined in section 5.1. | |
"ABC" | A string of characters A, B, C in order. | |
Notation for Matching Events | ||
Notation | Meaning | |
A == B | A is equal to B. | |
A != B | A is not equal to B. | |
A | B | ... | The A, B, ... terms are alternatives. |
A - B | The term A but not the term B. | |
anyURI. | Any URI. | |
anyString. | Any string. | |
list(item1, item2, ...); list() | An ordered list of events. An empty list. | |
set(item1, item2, ...); set() | An unordered set of events. An empty set. | |
* | Zero or more of preceding term. | |
? | Zero or one of preceding term. | |
+ | One or more of preceding term. | |
root(acc1 == value1, acc2 == value2, ...) | Match a Root Event with accessors. | |
start-element(acc1 == value1, acc2 == value2, ...) _children_end-element() | Match a sequence ofElement Event with accessors, a possibly empty list of events as element content and anEnd Element Event. | |
attribute(acc1 == value1, acc2 == value2, ...) | Match an Attribute Eventwith accessors. | |
text() | Match a Text Event. | |
Notation for Grammar Actions | ||
Notation | Meaning | |
A := B | Assigns A the value B. | |
concat(A, B, ..) | A string created by concatenating the terms in order. | |
resolve(e, s) | A string created by interpreting s as a relative URI reference to the�base-uri� accessor of �Element Event� _e_as defined in Section 5.3 Resolving URIs. The resulting string represents anRDF URI Reference. | |
generated-blank-node-id() | A string value for a new distinct generatedBlank Node Identifieras defined in section 5.2 Identifiers. | |
event.accessor := value | Sets an event accessor to the given value. | |
uri(identifier := value) | Create a new URI Reference Event. | |
bnodeid(identifier := value) | Create a new Blank Node Identifier Event. | |
literal(literal-value := string, literal-language := language, ...) | Create a new Plain Literal Event. | |
typed-literal(literal-value := string, literal-language := language, ...) | Create a new Typed Literal Event. |
7 RDF/XML Grammar
7.1 Grammar summary
7.2 Grammar Productions
7.2.1 Grammar start
If the RDF/XML is a standalone XML document (known by having been given the RDF MIME Type) then the grammar starts with Root Event 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 Event 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 noRoot Event will be available. Note that if such embedding occurs, the grammar may be entered several times but no state is expected to be preserved.
7.2.2 Production coreSyntaxTerms
rdf:RDF
| rdf:ID
| rdf:about
| rdf:bagID
| rdf:parseType
| rdf:resource
| rdf:nodeID
| rdf:datatype
A subset of the syntax terms from the RDF Namespace insection 5.1which are used in RDF/XML.
7.2.3 Production syntaxTerms
coreSyntaxTerms | rdf:Description
| rdf:li
All the syntax terms from the RDF Namespace insection 5.1which are used in the RDF/XML.
7.2.4 Production oldTerms
rdf:aboutEach
| rdf:aboutEachPrefix
These are the names from the RDF Namespacethat have been withdrawn from the language. See the resolutions of therdfms-aboutEach-on-object andrdfms-abouteachprefixissues for further information.
**Note:**The Working Group invites feedback from the community on the effects of the removal of these terms 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).
7.2.5 Production nodeElementURIs
anyURI - ( coreSyntaxTerms | rdf:li
| oldTerms )
The RDF URI References that are allowed on node elements.
7.2.6 Production propertyElementURIs
anyURI - ( coreSyntaxTerms | rdf:Description
| oldTerms )
The URIs that are allowed on property elements.
7.2.7 Production propertyAttributeURIs
anyURI - ( coreSyntaxTerms | rdf:Description
| rdf:li
| oldTerms )
The RDF URI References that are allowed on property attributes.
7.2.8 Production doc
root(document-element == RDF,
children == list(RDF))
7.2.9 Production RDF
start-element(URI == rdf:RDF
,
attributes == set())
nodeElementList
end-element()
7.2.10 Production nodeElementList
7.2.11 Production nodeElement
start-element(URI == nodeElementURIs
attributes == set((idAttr | nodeIdAttr | aboutAttr�)?, bagIdAttr?, propertyAttr*))
propertyEltList
end-element()
For node element e, the processing of some of the attributes has to be done before other work such as dealing with children events or other attributes. These can be processed in any order:
- If there is an attribute a with_a_.URI ==
rdf:ID
, then_e_.subject := uri(identifier := resolve(e, concat("#", a.string-value))). - If there is an attribute a with_a_.URI ==
rdf:nodeID
, then_e_.subject := bnodeid(identifier:=a.string-value). - If there is an attribute a with_a_.URI ==
rdf:about
then_e_.subject := uri(identifier := resolve(e, a.string-value)).
If e.subject is empty, then e.subject := bnodeid(identifier := generated-blank-node-id()).
The following can then be performed in any order:
- S1 If e.URI !=
rdf:Description
then the following statement is added to the graph:_e_.[subject](#eventterm-element-subject).[string-value](#eventterm-identifier-string-value) <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <_e_.[URI](#eventterm-element-URI)> .
- S2 If there is an attribute a_in propertyAttr with_a.URI ==
rdf:type
then the following statement is added to the graph:_e_.[subject](#eventterm-element-subject).[string-value](#eventterm-identifier-string-value) <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <_a_.[string-value](#eventterm-attribute-string-value)> .
- S3 For each attribute a matchingpropertyAttr (and not
rdf:type
) then o := literal(literal-value := a.string-value, literal-language := e.language) and the following statement is added to the graph: - S4 Handle thepropertyEltList children events in document order.
If an attribute a with_a_.URI == rdf:bagID
is present,n := uri(identifier := resolve(e, concat("#", a.string-value))) then in any order:
- S5 Add the following statement to the graph:
_n_.[string-value](#eventterm-identifier-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
- S1
- Statements from S2 and S3 in any order
- Statements generated by the propertyEltList children by S4 in document order
If the statement was generated byS4 from apropertyElt and has an existing identifier e.subject then s := e.subject. Otherwise_s_ := bnodeid(identifier := generated-blank-node-id())
Then reify the statement with event s using the reification rules insection 7.3 and apply the bag expansion rules in section 7.5 on event n to give a URI u. Then the following statement is added to the graph:
7.2.12 Production ws
7.2.13 Production propertyEltList
7.2.14 Production propertyElt
If element e has_e_.URI =rdf:li
then apply the list expansion rules on element e.parent insection 7.4to give a new URI u and_e_.URI := u.
NOTE: The action of this production must be done before the actions of any sub-matches (resourcePropertyElt ... emptyPropertyElt). Alternatively the result must be equivalent to as if it this action was performed first, such as performing as the first action of all of the sub-matches.
7.2.15 Production resourcePropertyElt
start-element(URI == propertyElementURIs ),
attributes == set(idAttr?))
ws* nodeElement ws*
end-element()
For element e, and the single contained nodeElement _n_the following statement is added to the graph:
_e_.parent.[subject](#eventterm-element-subject).[string-value](#eventterm-identifier-string-value) <_e_.[URI](#eventterm-element-URI)> _n_.[subject](#eventterm-element-subject).[string-value](#eventterm-identifier-string-value) .
If the rdf:ID
attribute a is given, the above statement is reified with_i_ := uri(identifier := resolve(e, concat("#", a.string-value))) using the reification rules insection 7.3and e.subject := i
7.2.16 Production literalPropertyElt
start-element(URI == propertyElementURIs ),
attributes == set(idAttr?, datatypeAttr?))
text()
end-element()
**Note:**The empty literal case is defined in productionemptyPropertyElt
For element e, and the text event t. If the rdf:datatype
attribute d is given then o := typed-literal(literal-value := t.string-value, literal-language := e.language, literal-datatype := a.string-value) otherwise o := literal(literal-value := t.string-value, literal-language := e.language) and the following statement is added to the graph:
_e_.parent.[subject](#eventterm-element-subject).[string-value](#eventterm-identifier-string-value) <_e_.[URI](#eventterm-element-URI)> _o_.[string-value](#eventterm-literal-string-value) .
If the rdf:ID
attribute a is given, the above statement is reified with_i_ := uri(identifier := resolve(e, concat("#", a.string-value))) using the reification rules insection 7.3and e.subject := i.
7.2.17 Production parseTypeLiteralPropertyElt
start-element(URI == propertyElementURIs ),
attributes == set(idAttr?, parseLiteral))
literal
end-element()
For element e and the literal l, then o := typed-literal(literal-value := l.string-value, literal-language := e.language, literal-datatype := http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral
) and the following statement is added to the graph:
_e_.parent.[subject](#eventterm-element-subject).[string-value](#eventterm-identifier-string-value) <_e_.[URI](#eventterm-element-URI)> _o_.[string-value](#eventterm-typedliteral-string-value) .
If the rdf:ID
attribute a is given, the above statement is reified with_i_ := uri(identifier := resolve(e, concat("#", a.string-value))) using the reification rules insection 7.3and e.subject := i.
The result of a literal fromrdf:parseType="Literal"
content is anXML Literal.
This specification allows some freedom to choose exactly what string is used as the lexical form of an XML Literal. Whatever string is used, it MUST correspond to an XML document when enclosed within a start and end element tag, and its canonicalization (without comments, as defined inExclusive XML Canonicalization [XML-XC14N]) MUST be the same as the same canonicalization of the literal text l. It is often acceptable to use l without any changes but this is incorrect if, for example, l uses entity references or namespace prefixes defined in the outer XML document.
7.2.18 Production parseTypeResourcePropertyElt
start-element(URI == propertyElementURIs ),
attributes == set(idAttr?, parseResource))
propertyEltList
end-element()
For element e with possibly empty element content c.
n := bnodeid(identifier := generated-blank-node-id()).
Add the following statement to the graph:
_e_.parent.[subject](#eventterm-element-subject).[string-value](#eventterm-identifier-string-value) <_e_.[URI](#eventterm-element-URI)> _n_.[string-value](#eventterm-identifier-string-value) .
If the rdf:ID
attribute a is given, the statement above is reified with_i_ := uri(identifier := resolve(e, concat("#", a.string-value))) using the reification rules insection 7.3and e.subject := i.
If the element content c is not empty, then use event_n_ to create a new sequence of events as follows:
start-element(URI := rdf:Description
,
subject := n,
attributes := set())
c
end-element()
Then process the resulting sequence using productionnodeElement.
7.2.19 Production parseTypeCollectionPropertyElt
start-element(URI == propertyElementURIs ),
attributes == set(idAttr?, parseCollection))
nodeElementList
end-element()
For element event e with possibly emptynodeElementList l. Set_s_:=list().
For each element event f in l,n := bnodeid(identifier := generated-blank-node-id()) and append n to s to give a sequence of events.
If s is not empty, n is the first event identifier in_s_ and the following statement is added to the graph:
_e_.parent.[subject](#eventterm-element-subject).[string-value](#eventterm-identifier-string-value) <_e_.[URI](#eventterm-element-URI)> _n_.[string-value](#eventterm-identifier-string-value) .
otherwise the following statement is added to the graph:
_e_.parent.[subject](#eventterm-element-subject).[string-value](#eventterm-identifier-string-value) <_e_.[URI](#eventterm-element-URI)> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
If the rdf:ID
attribute a is given, the above statement is reified with_i_ := uri(identifier := resolve(e, concat("#", a.string-value))) using the reification rules insection 7.3.
If s is empty, no further work is performed.
For each event n in s, the following statement is added to the graph:
_n_.[string-value](#eventterm-identifier-string-value) <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#List> .
For each event n in s and the corresponding element event f in l, the following statement is added to the graph:
_n_.[string-value](#eventterm-identifier-string-value) <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> _f_.[string-value](#eventterm-identifier-string-value) .
For each consecutive, overlapping pairs of events (n, o) in s, the following statement is added to the graph:
_n_.[string-value](#eventterm-identifier-string-value) <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _o_.[string-value](#eventterm-identifier-string-value) .
If s is not empty, n is the last event identifier in s, the following statement is added to the graph:
_n_.[string-value](#eventterm-identifier-string-value) <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .
7.2.20 Production parseTypeOtherPropertyElt
start-element(URI == propertyElementURIs ),
attributes == set(idAttr?, parseOther))
propertyEltList
end-element()
All rdf:parseType
attribute values other than the strings "Resource", "Literal" or "Collection" are treated as if the value was "Literal". This production matches and acts as if productionparseTypeLiteralPropertyEltwas matched. No extra triples are generated for other rdf:parseType
values.
7.2.21 Production emptyPropertyElt
start-element(URI == propertyElementURIs ),
attributes == set(idAttr?, ( resourceAttr | nodeIdAttr )?, 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 graph:_e_.parent.[subject](#eventterm-element-subject).[string-value](#eventterm-identifier-string-value) <_e_.[URI](#eventterm-element-URI)> _o_.[string-value](#eventterm-literal-string-value) .
and then if i is given, the above statement is reified with uri(identifier := resolve(e, concat("#", i.string-value))) using the reification rules insection 7.3. - Otherwise
- If
rdf:resource
attribute i is present, then_r_ := uri(identifier := resolve(e, i.string-value)) - If
rdf:nodeID
attribute i is present, then_r_ := bnodeid(identifier := i.string-value) - If neither,r := bnodeid(identifier := generated-blank-node-id())
If optionalrdf:bagID
attribute b is given,n := uri(identifier := resolve(e, concat("#", b.string-value)))
The following are done in any order: - For all propertyAttrattributes a (in any order)
* If a.URI ==rdf:type
then the following statement is added to the graph:_r_.[string-value](#eventterm-identifier-string-value) <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <_a_.[string-value](#eventterm-attribute-string-value)> .
* Otherwise o := literal(literal-value := a.string-value, literal-language := e.language) and the following statement is added to the graph:
If event n was created, then for each statement above:s := bnodeid(identifier := generated-blank-node-id()), reify the statement with event s using the reification rules in section 7.3, apply the bag expansion rules in section 7.5 on event n to give URI u and add the following statement is added to the graph:
_n_.[string-value](#eventterm-identifier-string-value) <_u_> _s_.[string-value](#eventterm-identifier-string-value); .
- Add the following statement to the graph:
_e_.parent.[subject](#eventterm-element-subject).[string-value](#eventterm-identifier-string-value) <_e_.[URI](#eventterm-element-URI)> _r_.[string-value](#eventterm-identifier-string-value) .
and then ifrdf:ID
attribute i is given, the above statement is reified with uri(identifier := resolve(e, concat("#", i.string-value))) using the reification rules insection 7.3. - If event n was created, add the following statement to the graph:
_n_.[string-value](#eventterm-identifier-string-value) <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Bag> .
- If
7.2.22 Production idAttr
attribute(URI == rdf:ID
,
string-value == rdf-id)
Constraint:: constraint-idapplies to the values of rdf:ID
attributes
7.2.23 Production nodeIdAttr
attribute(URI == rdf:nodeID
,
string-value == rdf-id)
7.2.24 Production aboutAttr
attribute(URI == rdf:about
,
string-value == URI-reference)
7.2.25 Production bagIdAttr
attribute(URI == rdf:bagID
,
string-value == rdf-id)
Constraint:: constraint-idapplies to the values of rdf:bagID
attributes
7.2.26 Production propertyAttr
7.2.27 Production resourceAttr
attribute(URI == rdf:resource
,
string-value == URI-reference)
7.2.28 Production datatypeAttr
attribute(URI == rdf:datatype
,
string-value == URI-reference)
7.2.29 Production parseLiteral
attribute(URI == rdf:parseType
,
string-value == "Literal")
7.2.30 Production parseResource
attribute(URI == rdf:parseType
,
string-value == "Resource")
7.2.31 Production parseCollection
attribute(URI == rdf:parseType
,
string-value == "Collection")
7.2.32 Production parseOther
attribute(URI == rdf:parseType
,
string-value == anyString - ("Resource" | "Literal") )
7.2.33 Production URI-reference
7.2.34 Production literal
7.2.35 Production rdf-id
An attribute �string-value�matching any legal[XML-NS] tokenNCName
7.3 Reification Rules
For the given event r and the statement with terms s, p and _o_corresponding to the N-Triples:
add the following statements to the graph:
_r_.[string-value](#eventterm-identifier-string-value) <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> _s_ .
_r_.[string-value](#eventterm-identifier-string-value) <http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate> _p_ .
_r_.[string-value](#eventterm-identifier-string-value) <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> _o_ .
_r_.[string-value](#eventterm-identifier-string-value) <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/1999/02/22-rdf-syntax-ns#Statement> .
7.4 List Expansion Rules
For the given element e, create a new RDF URI Reference u := concat("http://www.w3.org/1999/02/22-rdf-syntax-ns#\_",_e_.[li-counter](#eventterm-element-liCounter)), increment the_e_.li-counterproperty by 1 and return u.
7.5 Bag Expansion Rules
For the given element e, create a new RDF URI Reference u := concat("http://www.w3.org/1999/02/22-rdf-syntax-ns#\_",_e_.[bag-li-counter](#eventterm-element-bag-li-counter)), increment the_e_.bag-li-counterproperty by 1 and return u.
8 Serializing an RDF Graph to RDF/XML
There are some RDF Graphsas defined in theRDF Concepts and Abstract Syntax Working Draft. that cannot be serialized in RDF/XML. These are those that:
Use property names that cannot be turned into XML namespace-qualified names.
An XML namespace-qualified name (QName) has restrictions on the legal characters such that not all property URIs can be expressed as these names. 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-NCName character, ensuring that the first character of the name is aLetter or '_'. If the URI ends in a non-NCName character then throw a "this graph cannot be serialized in RDF/XML" exception or error.
Use inappropriate reserved names as properties
For example, a property with the same URI as any of thesyntaxTerms production.
A more detailed discussion of the issues of serializing the RDF Graph to RDF/XML is given in [UNPARSING]. This describes using the original syntax without the subsequently added rdf:nodeID
attribute that now allows all graphs with blank nodes to be serialized.
9 Using RDF/XML with HTML and XHTML
If RDF/XML is embedded inside HTML or XHTML this can add many new elements and attributes, many of which will not be in the appropriate DTD. This causes validation against the DTD to fail. The obvious solution of changing or extending the DTD is not practical for most uses. This problem has been analyzed extensively by Sean B. Palmer inRDF in HTML: Approaches[RDF-IN-XHTML]and it concludes that there is no single embedding method that satisfies all applications and remains simple.
The recommended approach is to not embed RDF/XML in HTML/XHTML but rather to use <link>
element in the <head>
element of the HTML/HTML to point at a separate RDF/XML document. This has been used for several years by theDublin Core Metadata Initiative (DCMI)on its Web site.
To use this technique, the <link>
elementhref
should point at the URI of the RDF/XML content and the type
attribute should be used with the value of"application/rdf+xml"
, the proposed MIME Type for RDF/XML, see Section 4
The value of the rel
attribute may also be set to indicate the relationship; this is an application dependent value. The DCMI has used and recommended rel="meta"
when linking in RFC 2731 - Encoding Dublin Core Metadata in HTML[RFC-2731] howeverrel="alternative"
may also be appropriate. SeeHTML 4.01 link typesandXHTML Modularization - LinkTypesfor further information.
10 Acknowledgments (Informative)
The following people provided valuable contributions to the document:
- Dan Brickley, W3C/ILRT
- Jeremy Carroll, HP Labs Bristol
- Bijan Parsia, MIND Lab at University of Maryland at College Park
This document is a product of extended deliberations by the RDF Core working group, whose members have included: Art Barstow (W3C) Dave Beckett (ILRT), Dan Brickley (W3C/ILRT), Dan Connolly (W3C), Jeremy Carroll (Hewlett Packard), Ron Daniel (Interwoven Inc), Bill dehOra (InterX), Jos De Roo (AGFA), Jan Grant (ILRT), Graham Klyne (Clearswift and Nine by Nine), Frank Manola (MITRE Corporation), Brian McBride (Hewlett Packard), Eric Miller (W3C), Stephen Petschulat (IBM), Patrick Stickler (Nokia), Aaron Swartz (HWG), Mike Dean (BBN Technologies / Verizon), R. V. Guha (Alpiri Inc), Pat Hayes (IHMC), Sergey Melnik (Stanford University), Martyn Horner (Profium Ltd).
This specification also draws upon an earlier RDF Model and Syntax document edited by Ora Lassilla and Ralph Swick, and RDF Schema edited by Dan Brickley and R. V. Guha. RDF and RDF Schema Working group members who contributed to this earlier work are: Nick Arnett (Verity), Tim Berners-Lee (W3C), Tim Bray (Textuality), Dan Brickley (ILRT / University of Bristol), Walter Chang (Adobe), Sailesh Chutani (Oracle), Dan Connolly (W3C), Ron Daniel (DATAFUSION), Charles Frankston (Microsoft), Patrick Gannon (CommerceNet), RV Guha (Epinions, previously of Netscape Communications), Tom Hill (Apple Computer), Arthur van Hoff (Marimba), Renato Iannella (DSTC), Sandeep Jain (Oracle), Kevin Jones, (InterMind), Emiko Kezuka (Digital Vision Laboratories), Joe Lapp (webMethods Inc.), Ora Lassila (Nokia Research Center), Andrew Layman (Microsoft), Ralph LeVan (OCLC), John McCarthy (Lawrence Berkeley National Laboratory), Chris McConnell (Microsoft), Murray Maloney (Grif), Michael Mealling (Network Solutions), Norbert Mikula (DataChannel), Eric Miller (OCLC), Jim Miller (W3C, emeritus), Frank Olken (Lawrence Berkeley National Laboratory), Jean Paoli (Microsoft), Sri Raghavan (Digital/Compaq), Lisa Rein (webMethods Inc.), Paul Resnick (University of Michigan), Bill Roberts (KnowledgeCite), Tsuyoshi Sakata (Digital Vision Laboratories), Bob Schloss (IBM), Leon Shklar (Pencom Web Works), David Singer (IBM), Wei (William) Song (SISU), Neel Sundaresan (IBM), Ralph Swick (W3C), Naohiko Uramoto (IBM), Charles Wicksteed (Reuters Ltd.), Misha Wolf (Reuters Ltd.), Lauren Wood (SoftQuad).
11 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-CONCEPTS]
Resource Description Framework (RDF): Concepts and Abstract Syntax, G. Klyne, J. Carroll, Editors, World Wide Web Consortium Last Call Working Draft, work in progress, 23 January 2003. This version of the RDF Concepts and Abstract Syntax is http://www.w3.org/TR/2003/WD-rdf-concepts-20030123/. The latest version of the RDF Concepts and Abstract Syntax is at http://www.w3.org/TR/rdf-concepts/.
[RDF-TESTS]
RDF Test Cases, J. Grant and D. Beckett, Editors, World Wide Web Consortium Last Call Working Draft, work in progress, 23 January 2003. This version of the RDF Test Cases is http://www.w3.org/TR/2003/WD-rdf-testcases-20030123/. 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.
[RDF-MIMETYPE-ID]
application/rdf+xml Media Type Registration, Internet-Draft draft-w3c-rdfcore-rdfxml-mediatype-01, A. Swartz, 23 August 2002.
[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.
[XML-XC14N]
Exclusive XML Canonicalization Version 1.0, J. Boyer, D.E. Eastlake 3rd, J. Reagle, Authors/Editors. W3C Recommendation. World Wide Web Consortium, 18 July 2002. This version of Exclusive XML Canonicalization is http://www.w3.org/TR/2002/REC-xml-exc-c14n-20020718\. The latest version of Canonical XML is at http://www.w3.org/TR/xml-exc-c14n.
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-SEMANTICS]
RDF Semantics, P. Hayes, Editor. World Wide Web Consortium Last Call Working Draft, work in progress, 23 January 2003. This version of the RDF Semantics is http://www.w3.org/TR/2003/WD-rdf-mt-20030123\. The latest version of the RDF Semantics is at http://www.w3.org/TR/rdf-mt.
[RDF-PRIMER]
RDF Primer, F. Manola, E. Miller, Editors, World Wide Web Consortium last Call Working Draft, work in progress, 23 January 2003. This version of the RDF Primer is http://www.w3.org/TR/2003/WD-rdf-primer-20030123\. The latest version of the RDF Primer is at http://www.w3.org/TR/rdf-primer.
[RDF-VOCABULARY]
RDF Vocabulary Description Language 1.0: RDF Schema, D. Brickley, R.V. Guha, Editors, World Wide Web Consortium Last Call Working Draft, work in progress, 23 January 2003. This version of the RDF Vocabulary Description Language is http://www.w3.org/TR/2003/WD-rdf-schema-20030123\. The latest version of the RDF Vocabulary Description Language is at http://www.w3.org/TR/rdf-schema.
[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/.
[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 Committee Specification, 3 December 2001. This version of RELAX NG is http://www.oasis-open.org/committees/relax-ng/spec-20011203.html. The latest version of the RELAX NG Specification is at http://www.oasis-open.org/committees/relax-ng/spec.html.
[RELAXNG-COMPACT]
RELAX NG Compact Syntax, James Clark, Editor. OASIS Committee Specification, 21 November 2002. This document is http://www.oasis-open.org/committees/relax-ng/compact-20021121.html.
[RDF-IN-XHTML]
RDF in HTML: Approaches, Sean B. Palmer, 2002
[RFC-2731]
RFC 2731 - Encoding Dublin Core Metadata in HTML, John Kunze, DCMI, December 1999.
A Syntax Schemas (Informative)
This appendix contains XML schemas for validating RDF/XML forms. These are example schemas for information only and are not part of this specification.
A.1 RELAX NG Compact Schema (Informative)
This is an example schema in RELAX NG Compact (for ease of reading) for RDF/XML. Applications can also use theRELAX NG XML version. These formats are described inRELAX NG ([RELAXNG]) and RELAX NG Compact ([RELAXNG-COMPACT]).
**Note:**The RNGC schema has been updated to attempt to match the grammar but this has not been checked or used to validate RDF/XML.
RELAX NG Compact Schema 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
I cannot seem to do this in RNGC so they are expanded in-line
coreSyntaxTerms = rdf:RDF | rdf:ID | rdf:about | rdf:bagID | rdf:parseType | rdf:resource | rdf:nodeID | rdf:datatype
syntaxTerms = coreSyntaxTerms | rdf:Description | rdf:li
oldTerms = rdf:aboutEach | rdf:aboutEachPrefix
nodeElementURIs = * - ( coreSyntaxTerms | rdf:li | oldTerms )
propertyElementURIs = * - ( coreSyntaxTerms | rdf:Description | oldTerms )
propertyAttributeURIs = * - ( coreSyntaxTerms | rdf:Description | rdf:li | oldTerms )
Also needed to allow rdf:li on all property element productions
since we can't capture the rdf:li rewriting to rdf_ in relaxng
Need to add these explicitly
xmllang = attribute xml:lang { text } xmlbase = attribute xml:base { text }
and to forbid every other xml:* attribute, element
doc = RDF
RDF = element rdf:RDF { xmllang?, xmlbase?, nodeElementList }
nodeElementList = nodeElement*
Should be something like:
ws* , ( nodeElement , ws* )*
but RELAXNG does this by default, ignoring whitespace separating tags.
nodeElement = element * - ( rdf:RDF | rdf:ID | rdf:about | rdf:bagID | rdf:parseType | rdf:resource | rdf:nodeID | rdf:datatype | rdf:li | rdf:aboutEach | rdf:aboutEachPrefix | xml:* ) { (idAttr | nodeIdAttr | aboutAttr )?, bagIdAttr?, xmllang?, xmlbase?, 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 | parseTypeCollectionPropertyElt | parseTypeOtherPropertyElt | emptyPropertyElt
resourcePropertyElt = element * - ( rdf:RDF | rdf:ID | rdf:about | rdf:bagID | rdf:parseType | rdf:resource | rdf:nodeID | rdf:datatype | rdf:Description | rdf:aboutEach | rdf:aboutEachPrefix | xml:* ) { idAttr?, xmllang?, xmlbase?, nodeElement }
literalPropertyElt = element * - ( rdf:RDF | rdf:ID | rdf:about | rdf:bagID | rdf:parseType | rdf:resource | rdf:nodeID | rdf:datatype | rdf:Description | rdf:aboutEach | rdf:aboutEachPrefix | xml:* ) { (idAttr | datatypeAttr )?, xmllang?, xmlbase?, text }
parseTypeLiteralPropertyElt = element * - ( rdf:RDF | rdf:ID | rdf:about | rdf:bagID | rdf:parseType | rdf:resource | rdf:nodeID | rdf:datatype | rdf:Description | rdf:aboutEach | rdf:aboutEachPrefix | xml:* ) { idAttr?, parseLiteral, xmllang?, xmlbase?, literal }
parseTypeResourcePropertyElt = element * - ( rdf:RDF | rdf:ID | rdf:about | rdf:bagID | rdf:parseType | rdf:resource | rdf:nodeID | rdf:datatype | rdf:Description | rdf:aboutEach | rdf:aboutEachPrefix | xml:* ) { idAttr?, parseResource, xmllang?, xmlbase?, propertyEltList }
parseTypeCollectionPropertyElt = element * - ( rdf:RDF | rdf:ID | rdf:about | rdf:bagID | rdf:parseType | rdf:resource | rdf:nodeID | rdf:datatype | rdf:Description | rdf:aboutEach | rdf:aboutEachPrefix ) { idAttr?, xmllang?, xmlbase?, parseCollection, nodeElementList }
parseTypeOtherPropertyElt = element * - ( rdf:RDF | rdf:ID | rdf:about | rdf:bagID | rdf:parseType | rdf:resource | rdf:nodeID | rdf:datatype | rdf:Description | rdf:aboutEach | rdf:aboutEachPrefix | xml:* ) { idAttr?, xmllang?, xmlbase?, parseOther, any }
emptyPropertyElt = element * - ( rdf:RDF | rdf:ID | rdf:about | rdf:bagID | rdf:parseType | rdf:resource | rdf:nodeID | rdf:datatype | rdf:Description | rdf:aboutEach | rdf:aboutEachPrefix | xml:* ) { idAttr?, (resourceAttr | nodeIdAttr)?, bagIdAttr?, xmllang?, xmlbase?, propertyAttr* }
idAttr = attribute rdf:ID { IDsymbol }
nodeIdAttr = attribute rdf:nodeID { IDsymbol }
aboutAttr = attribute rdf:about { URI-reference }
bagIdAttr = attribute rdf:bagID { IDsymbol }
propertyAttr = attribute * - ( rdf:RDF | rdf:ID | rdf:about | rdf:bagID | rdf:parseType | rdf:resource | rdf:nodeID | rdf:datatype | rdf:li | rdf:Description | rdf:aboutEach | rdf:aboutEachPrefix | xml:* ) { string }
resourceAttr = attribute rdf:resource { URI-reference }
datatypeAttr = attribute rdf:datatype { URI-reference }
parseLiteral = attribute rdf:parseType { "Literal" }
parseResource = attribute rdf:parseType { "Resource" }
parseCollection = attribute rdf:parseType { "Collection" }
parseOther = attribute rdf:parseType { text }
URI-reference = string
literal = any
IDsymbol = xsd:NMTOKEN
any = mixed { element * { attribute * { text }, any } }
B Changes (Informative)
Changes since the 8 November 2002 working draft
(Newest at top)
- 5.1 RDF Namespace Correct the rdf:_ n phrasing to forbid rdf:_0 and anything with leading zeros.
- 5.1 RDF Namespace Forbid XML namespaces with a namespace URI that is a prefix of the RDF or XML namespace URI references.
- 5.2 IdentifiersBlank nodeIDs in RDF/XML are scoped to the infoset document infoitem.
- Section 2 Added links to the N-Triples answers for all the complex examples
- Updated References
- 7.2.1 parseTypeLiteralPropertyEltRemoved reference to RDF Concepts canonicalization and added new paragraph describing the freedom on the lexical forms of XML Literal.
Added Exclusive XML Canonicalization [XML-XC14N] to normative references. - Updated links to match RDF Concepts new definitions
- Status, abstract, notes: Updated
- Appendix C (now Appendix B). Removed older changes to leave only those since the last working draft. (Appendix C in 8 November 2002 draft)
- Appendix B Other Syntax Schemas (Informative). Deleted. (Appendix B in 8 November 2002 draft)
- Appendix A Issues. Deleted. (Appendix A in 8 November 2002 draft)
- 6.1.6 Identifier Event. Split this intoURI Reference Event (6.1.6)andBlank Node Identifier event (6.1.7).
6.3 Grammar Notationsplit notation identifier() with uri() and bnodeid(). Updated the grammar to use these. - Added generated-blank-node-id() grammar notation to explictly show when such things are generated
- 5.2 Identifiers expanded Blank Node Identifiers description including
rdf:nodeID
values and generated ones - 5.3 Base URIs retitled_Resolving URIs_
- 6.3 Grammar NotationAdded resolve() grammar action notation to explicitly note when URI resolving is done as RDF URI References are built from string content and in-scope base URIs.
- 6.1.8 XML Literal Event. Replaced withTyped Literal Event.
6.3 Grammar Notation. Replaced grammar action notation xml() with typed-literal()
This matches the terms in RDF Concepts. - Replaced
rdfs:XMLLiteral
withrdf:XMLLiteral
in5.1 RDF Namespace, 7.2.1 parseTypeLiteralPropertyElt.
Previous changes are listed in thechanges sectionof the previous8 November 2002 working draft.