XML technologies / RSS & Atom / RSS 1.0 and RSS 1.1 / RDF basics
(Excerpt from "Newsfeeds with RSS and Atom" by Heinz Wittenbrink, published by Galileo Press, 2005)
RSS 1.0 differs fundamentally from RSS 2.0 and Atom because it follows the rules of the Resource Description Framework from the World Wide Web Consortium. RDF aims to let machines automatically link information in RSS with other RDF-compliant documents and process it together. The machine thus behaves as if it understood the information and could draw conclusions. RDF belongs to the field of "artificial intelligence".
What might automatic linking of web information look like? One simple example combines RSS documents with Friend-of-a-Friend documents. Friend-of-a-Friend (FOAF) describes relationships between people. (This is only a simple vocabulary-combination example; the problem could be solved more easily.) A FOAF document might describe Lisa H., her friendships with Regina F. and Petra P., and her interest in Söhne Mannheims. Lisa posts it on her website and writes a weblog whose RSS 1.0 feed names her as author. A reader could use RDF-aware software to find her friends’ weblogs: the FOAF document identifies the people, and their feeds identify authors. If further RDF data identifies entries discussing Söhne Mannheims, these could form an aggregated feed. Variations suggest many other ways to combine web information.
Why are an ordinary RSS 2.0 document and an ordinary XML document describing personal relationships insufficient to connect their information? More precisely, when can machines combine them into an information pool? Answering this reveals RDF’s underlying concepts, designed to make information machine-readable and keep object identifiers unambiguous during processing.
Triples as an information model
Combining information requires not only the same objects but compatible structures. A natural-language sentence and database record can be processed together only by converting one to the other’s form or both to a common form. Lisa H.’s authorship of "Aus Lisas Welt" and friendship with Petra P. need a common machine-processable form. RDF uses triples: two resources (objects) and their relationship. The example’s triples are:
"Aus Lisas Welt" (resource) is written by (relationship) Lisa H. (resource).
Lisa H. (resource) is a friend of (relationship) Petra P. (resource).
RDF calls the first resource the "subject", the relationship the "predicate" and the second resource the "object", also described as subject, property and value. Their roles are:
The predicate assigns a property to the subject.
The object supplies that property’s value.
Identification by URIs
Combining documents requires certainty that they describe the same objects: Lisa H. in FOAF must be the same Lisa named as a weblog author in RSS 1.0. RDF uses the web’s identifiers, URIs. Whenever RDF references something outside itself, it uses URIs or URI references, which include an optional fragment identifier.
Predicates or properties also have URIs for unambiguous identification. Every RDF triple can thus be written as three URIs: subject, predicate and object.
The two statements become these URI triples:
"http://www.example.com/weblogs/lisa"
"http://purl.org/dc/elements/1.1/creator"
"http://www.example.com/persons/lisa"
"http://www.example.com/persons/lisa"
"http://xmlns.com/foaf/0.1/knows"
"http://www.example.com/persons/petra"
Anyone controlling a URI space, such as a registered domain, can assign URIs to people or other resources. In the example I used "http://www.example.com/" as the base for Lisa H. and Petra P. Relationship URIs come from RDF/XML vocabularies. The first triple uses the Dublin Core vocabulary, an important part of RSS 1.0. Here, creator is an element name; creator denotes a resource’s relationship to its creator. The namespace of Dublin Core has the URI "http://purl.org/dc/elements/1.1/". The predicate URI is formed by appending the element name to the namespace prefix. The second triple uses a FOAF predicate, whose namespace is identified by the URI "http://xmlns.com/foaf/0.1/". FOAF includes the element knows, describing the relationship between the two people in the second triple.
RDF models information as graphs
Triples combine easily by making one triple’s object another’s subject. Visualising these relationships gives the following graph:
Figure: graphical representation of two RDF triples
RDF data forms a "directed labelled graph" ( directed labeled graph). It consists of nodes (vertices) and directed, labelled edges (arcs), studied by the mathematical discipline of graph theory. RDF resources—Lisa H., Petra P. and Lisa’s weblog—appear as nodes, relationships as labelled (labeled) arcs. Arc labels are the URIs "http://purl.org/dc/elements/1.1/creator" and "http://xmlns.com/foaf/0.1/knows".
RDF notation in XML
The graph model is fundamental; notation, such as XML, is secondary. RDF statements can in principle be combined without limit. URI references uniquely identify their components, allowing machines to interpret relationships between statements.
RDF thus uses directed labelled graphs whose nodes represent URI-identified resources and whose arcs have URI labels. This conceptual model is independent of XML syntax. RDF data can nevertheless be described in XML, a notation called RDF/XML, specified in the RDF/XML Syntax Specification. RSS 1.0 follows this syntax.
RDF/XML includes RDF-specific elements, attributes and document-structure rules. We will examine the elements later in RSS 1.0. The rules also govern combining XML vocabularies. Crucially, the RDF graph maps unambiguously to the XML structure: simply put, some elements represent resources and others properties.
Two mechanisms tell the parser which elements represent resources and which properties:
elements and attributes in the RDF/XML namespace
the hierarchy of nested XML elements
The example’s RDF/XML version shows how both mechanisms work together:
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:foaf="http://xmlns.com/foaf/0.1/">
<rdf:Description rdf:about="http://www.example.com/weblogs/lisa">
<dc:creator>
<rdf:Description rdf:about="http://www.example.com/persons/lisa"/>
</dc:creator>
</rdf:Description>
<rdf:Description rdf:about="http://www.example.com/persons/lisa">
<foaf:knows>
<rdf:Description rdf:about="http://www.example.com/persons/petra"/>
</foaf:knows>
</rdf:Description>
</rdf:RDF>
Code example: a simple RDF document
The document element rdf:RDF does not build the RDF graph; it merely identifies the data as RDF/XML. The resources used as statement subjects and graph nodes are specified by the element rdf:description with the attribute rdf:about: "http://www.example.com/weblogs/lisa" in the first triple and "http://www.example.com/persons/lisa" in the second triple. Nested inside are the two elements representing predicates, the graph’s arcs: dc:creator and foaf:knows. In the XML tree, these are children of the subject elements. Their children represent graph nodes again: the two further elements rdf:Description. These merely wrap the URIs supplied as attribute values of rdf:about: "http://www.example.com/persons/lisa" and "http://www.example.com/persons/petra".
Mapping RDF graphs to XML trees
The RDF graph thus maps to the XML tree: one level represents nodes, the next arcs, then nodes again.
The figure shows the document tree and its mapping to graph nodes. The RDF parser merges its two branches because their URIs identify two nodes as the same resource.
Figure: tree structure of a simple RDF document
Alternating coloured backgrounds for node and arc levels produce a striped structure, as in this version:
<?xml version="1.0"?>
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:foaf="http://xmlns.com/foaf/0.1/">
<rdf:Description rdf:about="http://www.example.com/weblogs/lisa">
<dc:creator>
<rdf:Description rdf:about="http://www.example.com/persons/lisa"/>
</dc:creator>
</rdf:Description>
<rdf:Description rdf:about="http://www.example.com/persons/lisa">
<foaf:knows>
<rdf:Description rdf:about="http://www.example.com/persons/petra"/>
</foaf:knows>
</rdf:Description>
</rdf:RDF>
Code example: a simple RDF document with a "striped structure"
This is also called "striped RDF/XML syntax" (see Dan Brickley’s explanation: RDF: Understanding the Striped RDF/XML Syntax). Following these rules even permits RDF documents without any elements or attributes from the RDF/XML namespace.
The W3C RDF validator
The W3C offers an online validator that checks RDF/XML for errors and outputs its triples and, optionally, a graph visualisation. It produced the figure "Graphical representation of two RDF triples" above and the RSS visualisations used in later examples.
Preview: more complex RDF graphs
We have introduced RDF’s data model and RDF/XML’s role. Always keep the intended triple or graph structure in mind: the document’s syntax projects an RDF graph onto an XML tree.
The following RSS 1.0 pages introduce further RDF/XML features, including three RDF characteristics not yet discussed:
RDF statement objects may also be strings (Literals). RDF supports plain literals (plain literals) and typed literals (typed literals). Plain literals combine a string and an optional language tag; typed literals combine a string and a datatype URI.
RDF represents collections (collections) through specific resource types called sequence (ordered sequence), bag (unordered sequence) and alternative (alternative).
An RDF graph may also contain "anonymous" nodes, not externally identified by URI but potentially having an internal identifier.
These techniques model information as RSS graphs even when it cannot be translated directly into RDF triples. Without them, RDF would fail as a data format in almost every realistic scenario.

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