We're now ready to look at how RDFa solves this problem. First we'll look at a simple way that RDFa can be used to unambiguously mark-up our metadata, before looking at using nested statements to make the mark-up more compact, and inline metadata to allow the document's content to be reused.
Let's return to our simple example from an earlier section:
<head>
<meta name="author" content="Mark Birbeck" />
<meta name="geo.position" content="43.95;4.833333" />
</head>
Recall that we said that with 'implicit knowledge' we could interpret this as the following set of triples:
<http://internet-apps.blogspot.com> dc:creator
[
foaf:name "Mark Birbeck";
geo:lat "43.95";
geo:long "4.833333"
] .
(Remember that I mapped the properties to existing vocabularies that seemed appropriate.)
Our next step is to look at how we can mark this up unambiguously; i.e., in such a way that we can dispense with the 'implicit' knowledge.
The RDFa mark-up for this actually mirrors the N3 quite closely (assuming that this is in a document stored at http://internet-apps.blogspot.com):
<head>
<link rel="dc:creator" href="#about" />
<meta about="#author" property="foaf:name" content="Mark Birbeck" />
<meta about="#author" property="geo:lat" content="43.95" />
<meta about="#author" property="geo:long" content="4.833333" />
</head>
This is a generic solution because statements in the head section that follow the layout of the first statement, i.e.:
<meta property="p" content="o" />
are always statements about the document itself, whilst statements with an about attribute, i.e., this pattern:
<meta about="s" property="p" content="o" />
always relate to the item designated by the URI in the about attribute.
Our mark-up has two sets of statements; the first concerns the document itself and is a reference to the 'thing' that created it:
<link rel="dc:creator" href="#about" />
The second lot of statements describe this 'thing' that created the document, and tell us its name and where it is:
<meta about="#author" property="foaf:name" content="Mark Birbeck" /> <meta about="#author" property="geo:lat" content="43.95" /> <meta about="#author" property="geo:long" content="4.833333" />
This separation of the two lots of statements means that even when we don't know anything about what the data 'means' we can still tell which of our resource pairs its about; we can tell if it's about the web-page or the web-page's author, the web-page or the conference, the web-page or the conference session, the web-page or the car, the web-page or the planet, the web-page or the Zanussi washing-machine, and so on.
In RDFa meta elements can be nested. The normal purpose of this is to make statements about the statement that contains them, such as indicating that the category 'fishing' was added by Jane or that the 4 star rating was given by John:
<head>
<meta property="category" content="fishing">
<meta property="dc:creator" content="Jane Doe" />
</meta>
<meta property="rating" content="4">
<meta property="dc:creator" content="John Doe" />
</meta>
</head>
But another use of nested statements is to make a lot of statements about the same resource, and this is achieved by adding an about attribute to the top-level statement. Our mark-up could now look like this:
<head>
<link rel="dc:creator" href="#about" />
<meta about="#author">
<meta property="foaf:name" content="Mark Birbeck" />
<meta property="geo:lat" content="43.95" />
<meta property="geo:long" content="4.833333" />
</meta>
</head>
In this small example there's not a lot to choose between this and the first syntax where the about attribute was repeated on each statement. But in a larger example the nested approach is probably easier to manage, as we can see here, where information about the author has been extended to include much of what might be in a person's FoaF file:
<html
xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
>
<head>
<link rel="dc:creator" href="#about" />
<meta about="#author">
<link rel="rdf:type" href="[foaf:Person]" />
<meta property="foaf:name" content="Mark Birbeck" />
<meta property="foaf:givenname" content="Mark" />
<meta property="foaf:family_name" content="Birbeck" />
<meta property="foaf:mbox_sha1sum"
content="b8b2922a0d39cd7c7db0b4f65124b4dd2a79fa24" />
<link rel="foaf:homepage" href="" />
<link rel="foaf:workplaceHomepage" href="http://www.formsPlayer.com/" />
<meta property="geo:long" content="4.833333" />
<meta property="geo:lat" content="43.95" />
</meta>
</head>
.
.
.
</html>
Software development is built on 're-use', but writing web-pages is one place that we've generally not had the benefit of re-use mechanisms. However, RDFa allows all of the metadata that we just saw in the FoaF example to be obtained from features that would normally be found in a web-page anyway.
For example, if my blog already has a link to my work web-site:
<body>
I am currently working on an XForms processor called
<a href="http://www.formsPlayer.com/">formsPlayer</a>.
</body>
I could re-use this information and so replace the mark-up for foaf:workplaceHomepage in the head of the document with this:
<body about="#author">
I am currently working on an XForms processor called
<a rel="foaf:workplaceHomepage"
href="http://www.formsPlayer.com/">formsPlayer</a>.
</body>
A full example that uses all of these techniques might look like this:
<html
xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
xmlns:foaf="http://xmlns.com/foaf/0.1/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
>
<head>
<link rel="dc:creator" href="#about" />
<meta about="#author">
<link rel="rdf:type" href="[foaf:Person]" />
<meta property="foaf:givenname" content="Mark" />
<meta property="foaf:family_name" content="Birbeck" />
<meta property="foaf:mbox_sha1sum"
content="b8b2922a0d39cd7c7db0b4f65124b4dd2a79fa24" />
<link rel="foaf:homepage" href="" />
<meta property="geo:long" content="4.833333" />
<meta property="geo:lat" content="43.95" />
</meta>
</head>
<body about="#author">
Hi, my name is Mark Birbeck,
and I am currently working on an XForms processor called
<a rel="foaf:workplaceHomepage"
href="http://www.formsPlayer.com/">formsPlayer</a>.
Don't bother emailing me though, because I'm on holiday
in Avignon. (I wish...)
</body>
</html>