Confused Development

I develop software and I often get confused in the process. I usually find the answers after a while, but a month later I can't remember them. So from now on, I will write them down here.

Friday, November 10, 2006

RDFa

As reported over on semiBlog, I spent this week at ISWC2006 in Athens, GA and presented my blogging tool there during the poster session. I got to present it to a lot of people, among them Dean Allemang of TopQuadrant. He seemed to like it, but immediately gave me a lecture on how I should link the blog posts to the RDF metadata - use RDFa, use RDFa, use RDFa! In fact, he insisted that my life would turn into paradise straight away if I would start using RDFa in semiBlog, and that I would go to hell otherwise. That convinced me! :-)

Anyway, having the metadata embedded in the actual HTML code instead of linking to some file (as I do at the moment) would relieve me of some annoying problems I have with uploading rdf/xml file.

So, here are a few quick notes on how RDFa works. Generally speaking, RDFa encodes RDF triples as attributes to arbitrary XML elements (and is thus strictly speaking a method of embedding RDF in XHTML, not just any HTML).

Encoding Triples with Literal Objects:
  • The SUBJECT is referenced either by the id or the about attribute of an XML element. xml:base is respected.
  • The PREDICATE is referenced using the property attribute of an XML element.
  • The OBJECT is referenced using either the content attribute or the actual content. The content attribute takes precedence.
  • Objects can be typed as a specific datataype using the type attribute.
Example:
<span about="http://semiblog.semanticweb.org/rdfaexamples/posterSession"
   role="cal:Vevent"
   xmlns:cal="http://www.w3.org/2002/12/cal/ical#">
   <span property="cal:summary">Posters Reception</span>
   <span property="cal:dtstart" content="2006-11-08T00:00:00+0000" type="xsd:date"/>
   <span property="cal:dtend" content="2006-11-08T02:00:00+0000" type="xsd:date"/>
</span>
Encoding Triples with Resource Objects:
  • The SUBJECT is referenced either by the id or the about attribute of an XML element. xml:base is respected.
  • The PREDICATE is referenced using the rel attribute of an XML element. Using rev instead of rel inverts the relationship, and turns the subject into the object and vice versa (think of passivization in natural language).
  • The OBJECT is referenced using either the href attribute.

All this is explained in much more detail in the

(A sidenote: One aspect that I don't like about the RDFa solution in comparison to linking from the HTML to a SPARQL query is this: when I embed the RDF, it remains static. When I link to a query, I always get the latest, most up-to-date result. However, that's not really an issue at the moment, since I don't actually link to a SPARQL endpoint!)

3 Comments:

At 6:40 pm, Anonymous Anonymous said...

Cédric,

I don't think you can really look at the process of adding metadata to an HTML page as being comparable to an MVC architecture. In fact, you can't necessarily say that the web itself follows the MVC pattern, although it's certainly possible to see many aspects of it through such a prism.

However, the MVC pattern is definitely a useful way to look at things, and the way to make it 'fit' in this context is to see it as what I've tended to call 'recursive MVC'.

What I mean by this is that the view itself--the HTML page sent to the browser--is actually a kind of 'embedded' MVC of its own. I've tended to use this approach with our devlopment of a custom widget architecture (each widget has its own data, and therefore its own MVC) but it also applies with RDFa, since by adding metadata to the UI itself you are able to create a much richer user experience.

So, we're not really mixing the model and view when we do this--it's more that we're passing 'hints' from the model to the view, to help the view decide how to render the information in a better way.

Writing this comment gives me an idea for a simple example that might illustrate the point. I'm typing now into a little 'textarea' control with limited functionality. On my computer I have umpteen programmes that I could use to give me a better editing experience, as well as a spell-checker that I've taught some new words. But the way the web is structured at the moment, if the page authors (in this case Google) don't add a better editor, I'm stuffed.

However, let's say that we add some metadata to this 'textarea' so that the browser now knows that this control is to be used for entering a large comment, and should also provide support for some HTML. The browser could use this information to provide me with my preferred editing control, with all of the features I mentioned, such as my personalised spell-checker.

In my mind this metadata may be part of the 'main' model in our MVC architecture, but it is also part of the model that's inside the MVC that is contained in the view; something a bit like this: M-(MVC)-C.

I don't know if I've made it clearer or more difficult! But it's good to see these issues discussed, anyway.

Best regards,

Mark

Mark Birbeck
CEO, x-port.net Ltd.
w: http://www.formsPlayer.com/
b: http://internet-apps.blogspot.com/

 
At 4:58 pm, Blogger Knud Möller said...

Thanks for the interesting comment, Mark. I was thinking myself that, from one perspective, maybe the HTML code is the model and the rendering in the browser windows is the view? How does JavaScript fit into the picture? That would usually be part of the controller, so why is it in the view-code?

Anyway, I do agree with Cédric that it would be cleaner to move the content-related metadata (the RDFa) away from the view-related metadata (the HTML). However, in the case of semiBlog I see the whole MVC situation a little different:

In semiBlog, a user constructs a blog post from the post text they write and post annotations, which are made up from data objects from the desktop (calendar entries, ...). That's what the model is - the post text and the desktop objects. The controller then is the semiBlog application itself, which grabs and combines this data and does something with it. There could be any number of views: the rendering of the post in a web browser, some other visualization that also displays the RDF that is contained in the post, etc.

And what is the HTML? Well, to me it is really just some intermediate exchange format, containing all kinds of data, both view and content-related. Does that make sense?

 
At 6:01 pm, Blogger Knud Möller said...

Here is a nice post on Mark Birbeck's blog that compares RDFa and Microformats.

 

Post a Comment

<< Home