RDFa 1.1 with a rich snippet example
With RDFa 1.1
making its way out of last call, I looked at the examples from
Google’s Webmaster Central to see what RDFa 1.1 brings to those. A
typical example is the one on reviews;
here s where it starts out in RDF 1.0:
<div xmlns:v="http://rdf.data-vocabulary.org/#" typeof="v:Review"> <span property="v:itemreviewed">L’Amourita Pizza</span> Reviewed by <span property="v:reviewer">Ulysses Grant</span> on <span property="v:dtreviewed" content="2009-01-06">Jan 6</span>. <span property="v:summary">Delicious, tasty pizza on Eastlake!</span> <span property="v:description">L'Amourita serves up traditional wood-fired Neapolitan-style pizza, brought to your table promptly and without fuss. An ideal neighborhood pizza joint.</span> Rating: <span property="v:rating">4.5</span> </div>
The most important change is that RDFa 1.1 has moved away from
using XML namespaces as a syntax for identifying vocabularies. In
the simplest case, the @vocab
attribute can be used to identify a vocabulary as follows:
<div vocab="http://rdf.data-vocabulary.org/#" typeof="Review"> <span property="itemreviewed">L’Amourita Pizza</span> Reviewed by <span property="reviewer">Ulysses Grant</span> on <span property="dtreviewed" content="2009-01-06">Jan 6</span>. <span property="summary">Delicious, tasty pizza on Eastlake!</span> <span property="description">L'Amourita serves up traditional wood-fired Neapolitan-style pizza, brought to your table promptly and without fuss. An ideal neighborhood pizza joint.</span> Rating: <span property="rating">4.5</span> </div>
The change looks small, but it means that the author has less
complexity to worry about. Of course, the @vocab
attribute may be placed somewhere up in the hierarchy, e.g., on
the body
element; this may become interesting if the
same page reviews not only a pizza but, say, cannelloni, too.
It is also interesting to compare the last code extract with the microdata example provided by Google for the same case:
<div itemscope itemtype="http://data-vocabulary.org/Review"> <span itemprop="itemreviewed">L’Amourita Pizza</span> Reviewed by
<span itemprop="reviewer">Ulysses Grant</span> on <time itemprop="dtreviewed" datetime="2009-01-06">Jan 6</time>. <span itemprop="summary">Delicious, tasty pizza in Eastlake!</span> <span itemprop="description">L'Amourita serves up traditional wood-fired
Neapolitan-style pizza, brought to your table promptly and without fuss.
An ideal neighborhood pizza joint.</span> Rating:
<span itemprop="rating">4.5</span> </div>
Almost identical in terms of simplicity (or complexity, if you
prefer); there is no real difference between the two. Which is,
actually, to be expected: indeed, the example concentrates on what
one could call a “single-vocabulary” case (whereby I mean that the
structured data uses terms from within the same vocabulary). One
of the main design goals of RDFa 1.1 (compared to
the previous
RDFa version) was to simplify such simple cases.
However, the same structured data in HTML may be used for other
purposes, in which case one would possibly prefer to add additional
terms. As a simple example, one might want to add the address of the
restaurant using the vcard vocabulary;
this is the case where prefixes do
come handy. Indeed, one could add a few lines:
<div vocab="http://rdf.data-vocabulary.org/#" typeof="Review"> <span property="itemreviewed">L’Amourita Pizza</span> Reviewed by <span property="reviewer">Ulysses Grant</span> on <span property="dtreviewed" content="2009-01-06">Jan 6</span>. <span property="summary">Delicious, tasty pizza on Eastlake!</span> <span property="description">L'Amourita serves up traditional wood-fired Neapolitan-style pizza, brought to your table promptly and without fuss. An ideal neighborhood pizza joint.</span> Rating: <span property="rating">4.5</span>; Address: <span property="vcard:street-address">111 Lake Drive</span>, <span property="vcard:locality">WonderCity</span>, <span property="vcard:postal-code">5555</span>, <span property="vcard:country-name">Australia</span>.
</div>
which is just marginally more complicated than the previous case
with the additional vcard
properties. One could have
sprinkled the code with other vocabulary elements, using Dublin
Core or other review vocabularies, etc.
At first glance, this code does not look valid in RDFa 1.1,
because there is no prefix declaration for vcard
.
This is correct, and should be added using the @prefix
attribute. Except that… the profile mechanism of RDFa might become
handy here: one could imagine Google (or the site hosting the
review) defining a snippet profile including all the terms that
Google recognizes directly but which could also contain prefixes
for a number of well known other vocabularies (whether Google uses
it in the search pages or not). If so, the only change to the code
could be:
<div profile="http://google.profile.example.org" typeof="Review"> <span property="itemreviewed">L’Amourita Pizza</span> Reviewed by <span property="reviewer">Ulysses Grant</span> on <span property="dtreviewed" content="2009-01-06">Jan 6</span>. <span property="summary">Delicious, tasty pizza on Eastlake!</span> <span property="description">L'Amourita serves up traditional wood-fired Neapolitan-style pizza, brought to your table promptly and without fuss. An ideal neighborhood pizza joint.</span> Rating: <span property="rating">4.5</span>; Address: <span property="vcard:street-address">111 Lake Drive</span>, <span property="vcard:locality">WonderCity</span>, <span property="vcard:postal-code">5555</span>, <span property="vcard:country-name">Australia</span>. </div>
Actually… the vcard
case, specifically, may be even
easier. Indeed, RDFa 1.1 has the notion of a default
profile, i.e., a small set of vocabulary prefixes that are
“predefined”. Although the exact list of those prefixes is not yet
fixed, we can expect that vcard
will be one of
those, being one of the most widely used vocabularies around.
I.e., the code may be valid RDFa 1.1 after all…
The key point here: RDFa 1.1 brings in an open architecture that scales to authors adding structured data mixing in with ease whatever vocabulary their application needs. Scaling, the possibility to use several vocabularies with ease is RDFa’s real strength, though this is often forgotten. And that openness matters. Take, for example, the BestBuy case. They started with the simple snippet case (yielding real benefit from it, thanks to Google or Yahoo!) but then they added new features with new vocabularies, and extended the functionality for other uses (e.g., to identify shops where a specific item is to available). As so often, openness counts in the long term, also for structured data…
so if vcard is implemented in rdfa, whats the point in having hcard in microformats? so the author has the option to choose which one they prefer to implement?
i can see this getting very confusing.
can they compatible with each other? i'm going to assume not, but i thought i'd ask considering how similar the classes/attributes are.
It would be useful for the WG to justify why they have deprecated XML Namespaces?
It does not seem to be a sound architectural decision imho.
R
Renato,
That was a long discussion and controversial issue. One of the main issues is that the namespace syntax created way too much problems in DOM implementation and is also incompatible with non-XML syntaxed HTML like HTML5.
I'm just curious how HTML5 intends to resolve the various Internet marketing spam issues plaguing the web. Will there be an offical endorsement of nofollow for instance? Some other way to recogniez commercial interests? This isn't the 80's anymore, and I would be keen to see development in HTMl5 from a social networking perspective.
i want To thank to whole management body for the work so far. Please thanks and keep it on
Cool stuff.Can RDF become an universal exchange language between applications or there is any way of distinguishing between vocabularies? I mean, I’d love to see the contribution to OpenGraph in that rdfa bar. ;)
It still pains me a bit to see the uf’s so low, though. Might mean SEO/Social is more important than UX.
Best regards Michael Durcel