XML technologies / RSS & Atom / RSS 1.0 and RSS 1.1 / Basic structure of an RSS 1.0 document / Document structure as a consequence of the RDF model

(Excerpt from "Newsfeeds with RSS and Atom" by Heinz Wittenbrink, published by Galileo Press, 2005)

The document element rdf:RDF has no counterpart in the graph an RDF parser builds from an RSS document. It supplies information needed to extract RDF triples from its contents, including that the document is RDF and which namespaces its descendants belong to. The element rdf:RDF also contains several "top-level" elements, direct children in the document hierarchy. An RDF parser interprets the descendants of rdf:RDF as statements about resources. In the example (see the code example "Simple RSS 1.0 document" on the page Basic structure of an RSS 1.0 document), the parser builds the RDF graph from three statements about three resources.

rdf:RDF, like all elements from the RDF namespace, also occurs outside RSS 1.0. Most RDF documents use rdf:RDF as the document element, but other document elements are possible. RSS 1.1, proposed as RSS 1.0’s successor, uses this option.

The element rdf:RDF in the example has three children: one element of type channel and two of type item. All three share the attribute rdf:about, required for all RSS 1.0 top-level elements. The URI supplied as the value of rdf:about identifies a resource that is the subject of RDF statements. Descendants of the top-level elements—in the example, channel and two item —follow the rules of Striped Syntax already introduced: their children represent properties. A property’s URI is formed from the element name and the URI of the namespaces to which the name belongs.

To understand how the parser builds triples from the example, you need some additional rules of RDF and RDF/XML syntax. I will introduce them using the example document.

The first rule concerns RDF/XML syntax:

The other two rules concern the RDF data model:

The first rule explains how the parser processes the constructs <channel rdf:about="..."/> and <item rdf:about="..."/>. It interprets the URI supplied as the value of rdf:about as the subject of a statement whose predicate belongs to the RDF/XML namespace and is named rdf:type. The subject is therefore an instance of a class identified by the statement’s object. The value of the property rdf:type is itself a resource: that class. The parser derives its URI from the element name and namespace URI. The example’s top-level elements thus yield these triples:

Subject

Predicate

Object

1

"http://www.celawi.eu/webtrends"

"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"

"http://purl.org/rss/1.0/channel"

2

"http://www.celawi.eu/webtrends/20040415_01"

"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"

"http://purl.org/rss/1.0/item"

3

"http://www.celawi.eu/webtrends/20040415_02"

"http://www.w3.org/1999/02/22-rdf-syntax-ns#type"

"http://purl.org/rss/1.0/item"

Namespace prefixes allow these triples to be abbreviated as follows:

Subject

Predicate

Object

1

"http://www.celawi.eu/webtrends"

rdf:type

rss:channel

2

"http://www.celawi.eu/webtrends/20040415_01"

rdf:type

rss:item

3

"http://www.celawi.eu/webtrends/20040415_02"

rdf:type

rss:item

RSS as knowledge representation

These first three triples already show the main difference between RSS 1.0 and RSS 2.0: an RDF parser extracts assertions about facts from an RSS 1.0 document. Here, the resource identified by the URI "http://www.celawi.eu/webtrends" is an RSS channel. RSS 1.0 thus represents knowledge in the broadest sense. Saying that a resource is an instance of the class channel is useful only if "is an instance of the class" is understood and further statements about the class channel are possible. RDF supports these statements through RDF schemas and ontologies. Statements derived from element names could, for example, build a database of RSS channel and entry properties.

More statements about those three subjects can be extracted using the other two rules. The first allows a literal (string), rather than a resource identifiable by URI, as a statement’s object. The first child of channel illustrates this: it is of type title. Under Striped Syntax, the element name title denotes a property because its parent represents a subject. Here, the property value is simply the element’s string content. The statement can be written as follows:

Subject

Predicate

Object

1

"http://www.celawi.eu/webtrends"

"http://purl.org/rss/1.0/title"

Webtrends

The contents of link and description are also strings. The resource represented by the element channel therefore has these four statements, written with namespace prefixes:

Subject

Predicate

Object

1

"http://www.celawi.eu/webtrends"

rdf:type

rss:channel

2

"http://www.celawi.eu/webtrends"

rss:title

Webtrends

3

"http://www.celawi.eu/webtrends"

rss:link

"http://www.celawi.eu/webtrends.html"

4

"http://www.celawi.eu/webtrends"

rss:description

Nachrichten über kommerzielle Websites und Online-Werbung

Graph of RDF statements about the example’s channel element

Figure: RDF statements about the example’s "channel" element
(This wording is imprecise: the subject is an instance of the class channel).

Relationships between channel, items and item

RDF containers are used to specify multiple resources as a subject or object in an RDF graph. There are three types: Bag (unordered sequences), Seq (for ordered sequences or collections) and Alt (for lists of alternatives).

In the example, a container is the object of the predicate items. This container is a collection and therefore an ordered sequence. Using a property such as item with a single resource as its value would not indicate whether the set of item objects is ordered. (Mark Pilgrim considers this semantic precision RDF’s main advantage, although he rejects RDF/XML syntax for Atom: Should Atom use RDF?.) The following figure shows the graph the RSS validator builds from the element items.

RDF graph visualisation for the RSS 1.0 items element

Figure: RDF graph for the RSS 1.0 "items" element

The collection is a resource without a URI here. An identifier for its node is constructed ad hoc using genid:ARP430402. No URI is needed because the resource is not accessed externally. A separate statement, shown by the left arc, says this resource has the property rdf:Seq. Each sequence member has a separate triple with a specific property: its position among the elements of the same kind.

In the RDF graph, the subject rdf:Seq thus has the properties rdf:_1, rdf:_2 and so on, whose values are resources. Later statements identify these as instances of the class item. The visualisation shows that the RDF/XML element rdf:li is merely shorthand for the properties rdf:_1, rdf:_2 and so on.

The sequence itself is a blank node. RDF always describes a subject’s structured information as separate resources referenced by further statements. The sequence is such a resource, used only as an intermediary to relate other resources. These intermediary resources are called blank nodes. The identifiers of blank nodes are not part of the RDF graph, but only a notation aid.

Blank nodes are one way RDF expresses relationships between one resource and several others as binary relations. The example has no relation between the resource channel and a set of resources of class item. Instead, a binary relation links channel to the sequence, and further binary relations link the sequence—the blank node —to each member. The RDF/XML element rdf:li is merely "syntactic sugar": in the graph it is replaced by predicates occurring only once each (rdf:_1, rdf:_2).

The following figure shows the complete example’s RDF graph. At bottom right are the statements about the item elements, or more precisely the resources of class item. They can be combined with statements about the channel into a single graph because they concern resources that are objects of the properties rdf:_1 and rdf_2.

Visualisation of the RDF graph of the document on the page Basic structure of an RSS 2.0 document Visualisation of the RDF graph of the document on the page Basic structure of an RSS 2.0 document

Figure: visualisation of the RDF graph of the document on the page Basic structure of an RSS 2.0 document

   

 

 

 

Creative Commons license
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.

back to top