- From: Jeni Tennison <jeni@jenitennison.com>
- Date: Wed, 16 Nov 2011 22:49:56 +0000
- To: Niklas Lindström <lindstream@gmail.com>, public-rdfa-wg <public-rdfa-wg@w3.org>
- Cc: HTML Data Task Force WG <public-html-data-tf@w3.org>, Dan Brickley <danbri@danbri.org>
On 16 Nov 2011, at 21:19, Niklas Lindström wrote: > Have we considered whether @resource would be preferable over @about > in RDFa Lite? It's funny because I was just running into some issues that made me wish for @resource rather than @about. @danbri set me the challenge of creating a stylesheet to map microdata into RDFa 1.1 Lite in part to easily generate some RDFa 1.1 Lite examples using schema.org markup. The first document that I tried was http://www.imdb.com/title/tt0813715/. This contains the markup (much simplified here): <div itemscope itemtype="http://schema.org/TVSeries"> <div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating"> Ratings: <strong><span itemprop="ratingValue">7.2</span></strong> <span class="mellow">/<span itemprop="bestRating">10</span></span> from <a href="ratings" title="23,201 IMDb users have given an average vote of 7.2/10"> <span itemprop="ratingCount">23,201</span> users</a> </div> </div> which if you were to convert to RDF using the microdata/RDF mapping that Gregg's been working on, would generate something like: <> md:item [ a schema:TVSeries; schema:aggregateRating [ a schema:AggregateRating; schema:bestRating "10"; schema:ratingCount "23,201"; schema:ratingValue "7.2" ] ] . A simplistic mapping into RDFa 1.1 gives: <div vocab="http://schema.org/" typeof="TVSeries"> <div property="aggregateRating" vocab="http://schema.org/" typeof="AggregateRating"> Ratings: <strong><span property="ratingValue">7.2</span></strong> <span class="mellow">/<span property="bestRating">10</span></span> from <a href="ratings" title="23,201 IMDb users have given an average vote of 7.2/10"> <span property="ratingCount">23,201</span> users</a> </div> </div> If you run that through a RDFa parser, you get: [ a schema:TVSeries; schema:aggregateRating [ a schema:AggregateRating; schema:bestRating "10"; schema:ratingValue "7.2" ] ] . <ratings> schema:ratingCount "23,201" . What's happened? The ratingCount property is nested within a link, and the @href of the link is creating a new scope for the statements within that link, so instead of belonging to the AggregateRating, the ratingCount is a property of <ratings> (the URI of the link). I can get around that in this case by adding a property="" to the link. However, if it had a @rel on it already, like this: <div vocab="http://schema.org/" typeof="TVSeries"> <div property="aggregateRating" vocab="http://schema.org/" typeof="AggregateRating"> Ratings: <strong><span property="ratingValue">7.2</span></strong> <span class="mellow">/<span property="bestRating">10</span></span> from <a href="ratings" rel="prefetch" title="23,201 IMDb users have given an average vote of 7.2/10"> <span property="ratingCount">23,201</span> users</a> </div> </div> then that wouldn't work. In that case, I need to make sure that the subject of the ratingCount property is the aggregate rating, rather than <ratings>. I could do that in two ways. One would be to add an @about attribute on both elements pointing to the same blank node, but in that case I'd need to create another nested <div> because if I put an @about attribute on the element with property="aggregateRating" then the subject of the triple generated by that property would be the @about. But then the property="aggregateRating" doesn't chain, so I'd have to use @rel: <div vocab="http://schema.org/" typeof="TVSeries"> <div rel="aggregateRating"> <div about="_:rating" vocab="http://schema.org/" typeof="AggregateRating"> Ratings: <strong><span property="ratingValue">7.2</span></strong> <span class="mellow">/<span property="bestRating">10</span></span> from <a href="ratings" rel="prefetch" title="23,201 IMDb users have given an average vote of 7.2/10"> <span about="_:rating" property="ratingCount">23,201</span> users</a> </div> </div> </div> Or as Nicklas suggested I could use the @resource attribute. That works out a lot neater: <div vocab="http://schema.org/" typeof="TVSeries"> <div property="aggregateRating" resource="_:rating" vocab="http://schema.org/" typeof="AggregateRating"> Ratings: <strong><span property="ratingValue">7.2</span></strong> <span class="mellow">/<span property="bestRating">10</span></span> from <a href="ratings" rel="prefetch" resource="_:rating" title="23,201 IMDb users have given an average vote of 7.2/10"> <span property="ratingCount">23,201</span> users</a> </div> </div> Note that in neither case does the xhv:prefetch relationship make any sense whatsoever. Hopefully processors will ignore the bogus xhv:* properties. @resource also gives a lot better mapping for @itemid. Say the microdata had an @itemid on the inner <div> like this: <div itemscope itemtype="http://schema.org/TVSeries"> <div itemprop="aggregateRating" itemscope itemtype="http://schema.org/AggregateRating" itemid="ratings"> Ratings: <strong><span itemprop="ratingValue">7.2</span></strong> <span class="mellow">/<span itemprop="bestRating">10</span></span> from <a href="ratings" title="23,201 IMDb users have given an average vote of 7.2/10"> <span itemprop="ratingCount">23,201</span> users</a> </div> </div> If @resource were allowed in RDFa 1.1 Lite then I could just map the @itemid to @resource really easily: <div vocab="http://schema.org/" typeof="TVSeries"> <div property="aggregateRating" vocab="http://schema.org/" typeof="AggregateRating" resource="ratings"> Ratings: <strong><span property="ratingValue">7.2</span></strong> <span class="mellow">/<span property="bestRating">10</span></span> from <a href="ratings" title="23,201 IMDb users have given an average vote of 7.2/10"> <span property="ratingCount">23,201</span> users</a> </div> </div> So I strongly support Niklas' suggestion of using @resource rather than @about in RDFa 1.1 Lite. Cheers, Jeni -- Jeni Tennison http://www.jenitennison.com
Received on Wednesday, 16 November 2011 22:50:33 UTC