RDF in Drupal: Super-Simple Primer

If you've read the first couple of installments of this series, you should have a pretty good idea of what the "semantic web" is by now. By providing precise meaning to a site's content, applications can take advantage of these machine-readable hints to link data together across sites in a myraid of ways. Before you jump in the deep end of the semantic web pool, there's a few more things you should have a clear understanding of.

As I previously defined, RDF stands for Resource Description Framework. This is a family of standards for describing content on the web. The vast majority of current and future Drupal implementations of RDF are actually RDFa (Resource Description Framework in Attributes), a set of extensions to XHTML. RDF is normally implemented using XML; while this is possible with Drupal, RDFa allows Drupal to implement RDF as part of the standard content displays.

For example, RDF describing a person's nickname and one of their interests looks like this (using the Friend-of-a-Friend [FOAF] ontology):

<code><foaf:person rdf:about="#me"> <foaf:name>Michael Anello</foaf:name> <foaf:nick>Mike</foaf:nick></foaf:person></code>

<code><foaf:person rdf:about="#me"><foaf:nick></foaf:nick> <foaf:interest rdf:resource="http://yankees.com/" rdfs:label="New York Yankees"> </foaf:interest></foaf:person> </code> While the analogous RDFa would look like this:

My full name is Michael Anello, but most people just call me Mike. My favorite baseball team is the New York Yankees.

The second example clearly shows how RDFa is just a simple extension of XHTML. Now think about what happens when thousands of people are described with this same interest - suddenly all these people are linked in a way that can be utilized by semantic web applications.


In order for RDF to be effective, there has to be a standard way to define the various relationships between data. RDF itself does not provide this mechanism - it leaves it up to others to define and make public various ontologies. In laymen's terms, an "ontology" is a defined way to categorize things. For those familiar with Drupal, it is safe to think of ontologies the same way you think about taxonomy vocabularies. Each ontology is just a defined set of categories.

This will no doubt be a source of confusion in the future for Drupal users. Ontologies are also commonly known as RDF "vocabularies". Unfortunately, when the word "vocabulary" is used in a Drupal-related conversation, most people immediately think about the taxonomy module, not RDF. I'll use the word "ontology" when talking about RDF vocabularies from here on out. For example, the FOAF ontology allows you to specify attributes about people. Some of FOAFs attributes include:

The person's name
The person's email address
The person's home page
The person's nickname
An interest of the person
A method to indicate that the "person" knows another "person"

There are a myraid of public ontologies available for anyone to utilize. Specific industries and organizations will no doubt decide on a common ontoloty for their specific disciplines. Likewise, the Drupal community will decide which ontologies to support in Drupal 7 core. FOAF, Dublin Core, and Semantically-Interlinked Online Communities (SIOC) seem like obvious choices. SchemaWeb is a handy database of various RDF ontologies to describe all kinds of things including Airports, Beer, Gadgets, and even Kissing! RDF Triples Up to now, I've talked about what exactly RDF is and how ontologies are just one piece of the puzzle. It is time to start putting all the pieces together. All RDF relationships are comprised of three pieces of data, often called the "subject", "predicate", and "object" (shout out to all you English majors out there). Combined, these three pieces of data are called an "RDF triple". Regardless of how complex or arcane the data is, for it to be described with RDF, its relationships must be broken down into any number of RDF triples. Using the FOAF example from above:

subject predicate object
me has name Michael Anello
me has nickname Mike
me has interest http://yankees.com

To keep things as simple as possible, I've left out some of the details about this FOAF example. Mark Birbeck explains it all much better in his blog. Here's some other examples from other ontologies:

Dublin Core (widely used for describing digital content)
article::has title::Understanding RDFa article::has author::Michael Anello article::has subject::RDF article::has subject::RDFa article::has subject::semantic web
Description of a Project (DOAP, widely used for describing software projects)
project::has name::Drupal project::has home page::http://drupal.org project::has download-page::http://drupal.org/project/drupal project::has programming-language::PHP
Semantically-Interlinked Online Communities (SIOC, widely used for describing user generated content)
forum post::has topic::swimming forum post::has creator::Michael Phelps

Once you start thinking about describing your data in these easy-to-understand triples, implementing RDFa becomes much easier. In the next section, we'll look at some of the available modules to help you start implementing RDF in your Drupal 6 site. This is part 3 in a 5 part series about RDF and Drupal.

  1. RDF in Drupal: What is it and Why Should We Care?
  2. RDF in Drupal: Benefits to Casual Web Surfers
  3. RDF in Drupal: Super-Simple Primer
  4. RDF in Drupal: What can I do now? Drupal 6 and the Semantic Web
  5. RDF in Drupal: The Future - RDF in Drupal 7


Fantastic writeup, I really appreciate you publishing this information. When I first read about RDF and Drupal everything was a little overwhelming, but these articles really put my learning back on track.

Looking forward to the next articles.

Submitted by Glenn McLelland (not verified) on Thu, 06/18/2009 - 10:10

Sign up to receive email notifications of whenever we publish a new blog post or quicktip!