Resource Description Framework (RDF) and RDF/XML

(and a bit of Dublin Core)

What is RDF?

RDF is a data specification designed to allow for flexible and extensible exchange of metadata about resources, people, or other things, online or offline. RDF is part of a set of standards that comprise the "Semantic Web", one goal of which is to make web pages machine-readable and machine-interpretable.

One other thing: RDF is not XML!

What is RDF/XML?

RDF/XML is RDF expressed in XML!

What does RDF/XML look like?

RDF (in whatever form) consists of a list of unordered "triples", which are composed of:

A full set of triples is often called a "graph" or a "model".

A triple would look like

Subject

Predicate

Object

“My Life”

was authored by

Bill

“Designing for the Web”

was authored by

Robin

Looks like a spreadsheet, right?

Title

Author

“My Life”

Bill

“Designing for the Web”

Robin

RDF can be used to describe a spreadsheet, but with one big difference: RDF does not enforce that the same rows have the same fields ("predicates", that is)

Subject

Predicate

Object

“My Life”

was authored by

Bill

“Designing for the Web”

was authored by

Robin

the cat

has color

reddish-brown

Clearly, we can�t put this in a single spreadsheet anymore, yet it is ok to put it in a single RDF document!

What does RDF/XML look like?

Let's look at an example. This example uses Dublin Core, another metadata specification that is designed to provide a common set of fields for describing digital assets (video files, documents, etc.)

<rdf:RDF 
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:dc="http://purl.org/dc/elements/1.1/">
    <rdf:Description 
          rdf:about="http://www.colleges.org/~music/cello/index.html">
       <dc:creator>Patricia Gray</dc:creator>
       <dc:creator>Craig Hultgren</dc:creator>
       <dc:title>Contemporary Cello Techniques</dc:title>
       <dc:description>
          Describes techniques for playing the Cello
       </dc:description> 
       <dc:date>2005-05-20</dc:date>
    </rdf:Description> 
</rdf:RDF>

This RDF document starts by describing 2 namespaces:

xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/"

What this line means is that any elements starting with "rdf" refer to the RDF namespace, while any starting with "dc" refer to the Dublin Core namespace. So if you see "dc:title" what that means is "this is a Dublin Core title" (and not to be confused with other titles).

What's great about RDF is that it allows you to mix and match namespaces: you can use a single RDF document to describe many metadata schemes.

Wikipedia on namespaces

"Within a limited namespace designed for your family, you might be named as "Charlie." Within a larger namespace containing strangers as well, the name "Charlie" might not be unique, so you are instead "Charlie Brown, 17 Main Street." In (the namespace of) some other family, the name "Charlie" might refer to a different person than you."

from Wikipedia, http://en.wikipedia.org/wiki/Namespaces (2005-07-10)

Think about XML namespaces the same way: for the above example, think about the tag:

<dc:title>

...as meaning...

I'm the title for the Dublin Core family. Don't confuse me with some other "title", please.

The Many Faces of RDF

Just to complicate things, RDF/XML can be arranged many different ways!

<RDF xmlns="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
    xmlns:lib="http://www.zvon.org/library"> 
     <Description about="http://www.colleges.org/~music/cello/index.html"> 
          <dc:creator>Patricia Gray</dc:creator> 
     </Description>
</RDF>
...or...
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
    xmlns:dc="http://purl.org/dc/elements/1.1/"> 
     <rdf:Description 
		about="http://www.colleges.org/~music/cello/index.html" 
	dc:creator="Patricia Gray"  />
</rdf:RDF>

Annoying, right?

One way out of this confusion is to try to identify the triples�remember, that's all that RDF really is: a list of triples. You can use the RDF Validator (http://www.w3.org/RDF/Validator/) to provide a listing of them if the RDF looks convoluted or unclear.

RDF people are very picky!

Take this triple:

<rdf:RDF
    xmlns:rdf=http://www.w3.org/1999/02/22-rdf-syntax-ns#
	xmlns:dc="http://purl.org/dc/elements/1.1/">
  <rdf:Description about="http://someserver.org/somedoc.html">
    <dc:creator>Hank</dc:creator>
  </rdf:Description>
</rdf:RDF>

What this means literally is that the word "Hank" wrote the document at http://someserver.org/somedoc.html, which is clearly impossible. People make websites, not words. This is more exactly what is meant:

<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:dc="http://purl.org/dc/elements/1.1/">
  <rdf:Description about=" http://someserver.org/somedoc.html ">
    <dc:creator>
      <rdf:Description ID="http://www.hankswebsite.net">
        <foaf:name>Hank</foaf:name>
      </rdf:Description>
    </dc:creator>
  </rdf:Description>
</rdf:RDF>

What this RDF document does is create a new element for the creator and assign it an ID. Then it states what we know about that new element/entity: that it's "foaf" name is "Hank".

Example applications and tools

There are not many RDF-specific applications that are viewable online, outside of RSS.

Further reading

Explore

Create FOAF documents for ourselves and add friends to them. Validate them to see all the triples listed. Then upload them and explore using the FOAF Web explorer: http://xml.mfd-consult.dk/foaf/explorer/

Parse an RDF/RSS syndication link and look at the triples.