timothy falconer's semantic weblog
Big Fractal Tangle


RDF
 
RDF intro, part 2

In my last post, we learned that RDF is all about describing resources, and that resources are referenced with URIs. So how does it describe them? Let’s start by looking at the source of this very page (View / Page Source). There’s two snippets of RDF embedded in the HTML. The first helps tools like Movable Type create what are called “trackbacks”, links to this post from other people’s posts. Here’s the RDF:


<!--

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"

xmlns:dc="http://purl.org/dc/elements/1.1/">

<rdf:Description

rdf:about="http://bigfractaltangle.com/archive/2003/12/26.jsp"

trackback:ping="http://immuexa.com/cgi-bin/mtype/mt-tb.cgi/80"

dc:title="RDF intro, part 2"

dc:identifier="http://bigfractaltangle.com/archive/2003/12/26.jsp"

dc:subject="Tangle Yarns"

dc:description="In my last post, we learned..."

dc:creator="timothy"

dc:date="2003-12-26T21:49:46-08:00" />

</rdf:RDF>

-->

First, notice that the entire snippet is surrounded by HTML comments. This practice hides the code from older browsers. It also helps the page validate as official HTML. Next, look at the surrounding <rdf:RDF> tags, which define the snippet as RDF. They also define the namespaces we’re using.

What’s a namespace? Well, a big problem with computers is that people often use the same terms for slightly different things. When I say “subject,” I may mean “email subject.” When you say it, you may mean “category.” If we tried to mix our data together, your subjects would clash with my subjects, and it’d be a big mess. Namespaces let people say, “These words have my meaning.” They’re kind of like our own private dictionaries. We indicate a word is from a particular namespace by putting a special prefix in front, such as “dc:subject.” This lets the computer know we’re talking about a “subject” as understood in the “dc” namespace (or dictionary), as opposed to “mail:subject”, which uses the “mail” namespace. A big part of RDF is defining these separate vocabularies so we can put labels on things without stepping on each other’s toes.

To indicate that you want to use a particular namespace, use an “xmlns” attribute, followed by an equals sign, followed by the URI of the official namespace definition, or “schema”. In this snippet, we’re using three namespaces: 1) the RDF namespace, rdf, 2) the trackback namespace, trackback, and 3) the Dublin Core namespace, dc.

So we’ve got three namespaces, but what does the damned thing do? Well, RDF is the Resource Description Framework, so it must be describing a resource. Which resource? For a clue, look at the <rdf:Description> tag. What’s it “about”?   Ah ha… there’s one of them URI things (http://bigfractaltangle.com/archive/2003/12/26.jsp). Looks like we’re describing this very page by specifying several of its properties: its creator (dc:creator), its date (dc:date), its title (dc:title), etc. Movable Type uses this information to reference this page from other websites.

So, RDF describes a resource in the <Description> tag. The resource is identified in the “about” attribute. The remaining attributes in the tag make up the actual description, which is essentially a collection of properties about the resource. Properties are specified using namespace qualified names, such as “dc:title”. As you would expect with XML, properties can also be written out as tags instead of attributes. This snippet is the same:


<!--

<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"

xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/"

xmlns:dc="http://purl.org/dc/elements/1.1/">

<rdf:Description

rdf:about="http://bigfractaltangle.com/archive/2003/12/26.jsp" >

<trackback:ping> http://.../mt-tb.cgi/80 </trackback:ping>

<dc:title> RDF intro, part 2 </dc:title>

<dc:identifier> http://.../2003/12/26.jsp </dc:identifier>

<dc:subject> Tangle Yarns </dc:subject>

<dc:description> In my last post, we learned... </dc:description>

<dc:creator> timothy </dc:creator>

<dc:date> 2003-12-26T21:49:46-08:00 </dc:date>

</rdf:Description>

</rdf:RDF>

-->

“Wait a minute,” you may say. “All this fuss is about specifying properties? Can’t we do this with a dozen other ‘description frameworks’, like say SQL or UML or JavaBeans?”

Yep. Nothing’s new under the sun. From one perspective, RDF’s simply another way to describe your average “record” in just about every computer language you’ve ever heard of. Properties and values, applied to some thing, which this time we’re calling a resource.

So why bother with RDF? For that, tune in next time…

Comments are closed.