[whatwg] Possible bugs : Microdata Itemscope on <link/> and <meta/>

Philip Jägenstedt philipj at opera.com
Fri Nov 27 14:11:02 PST 2009


On Thu, 26 Nov 2009 22:30:41 +0100, Tim van Oostrom <tim at depulz.nl> wrote:

> Hi, I made a forumpost : http://forums.whatwg.org/viewtopic.php?t=4176,  
> concerning a possible "microdata specification bug" and a bug in the  
> james.html5.org microdata extractor.
>
> Comes down to <link/> and <meta/> elements possibly being unfit for use  
> with the itemscope attribute.
>
> I made an example in the forum post with some nice ubb formatting .
>

There are some other issues with <link> and <meta> you might want to  
review first: [1]

Your second example was:

<div itemtype="http://url.to/geoVocab#country" itemscope>
    <span itemprop="http://xmlns.com/foaf/spec/index.rdf#name"  
lang="cn">中華人民共和國</span>
    <span itemprop="http://xmlns.com/foaf/spec/index.rdf#name"  
lang="en">China</span>
    <link itemprop="http://url.to/city" href="http://url.to/shanghai"  
itemscope itemref="city-shanghai" />
    <div id="city-shanghai">
       <span  
itemprop="http://xmlns.com/foaf/spec/index.rdf#name">Shanghai</span>
       <span itemprop="http://url.to/demoVocab#population">14.61 million  
people</span>
       <span itemprop="http://url.to/physicsVocab#time"  
datetime="2009-11-26 11:43">11:43 pm (CT)</span>
    </div>
</div>

By using itemprop+itemscope, you're saying that the property is itself an  
item. Also specifying href="http://url.to/shanghai" does nothing.

<link>, <meta> and any other void elements are usually the wrong choice  
for itemprop+itemscope because they don't have child elements, so itemref  
is the only way to add properties. What you've accidentally done above is  
add the 3 properties of Shanghai to both the top-level item and the  
sub-item, see [2] for details. I would rewrite it to something like:

<div itemtype="http://url.to/geoVocab#country" itemscope>
    <span itemprop="http://xmlns.com/foaf/0.1/name"  
lang="zh-CN">中华人民共和国</span>
    <span itemprop="http://xmlns.com/foaf/0.1/name" lang="en">China</span>
    <div itemprop="http://url.to/whatShanghaiIsToChina" itemscope
         itemtype="http://url.to/geoVocab#city">
       <span itemprop="http://xmlns.com/foaf/0.1/name">Shanghai</span>
       <span hidden itemprop="http://url.to/demoVocab#population"  
content="14610000"></span>
       <time itemprop="http://url.to/physicsVocab#time"  
datetime="2009-11-26T11:43+08:00">11:43 pm (CT)</time>
    </div>
</div>

I don't know how you meant for <http://url.to/city> to be used, the  
vocabulary at <http://url.to/geoVocab#country> has to define what  
properties are valid and their semantics. The itemprop  
<http://url.to/whatShanghaiIsToChina> could be lots of things, what you  
want is maybe something that means "financial center of" or "largest  
city", I don't know. If <http://url.to/shanghai> is a global identifier  
for Shanghai you should use itemid.

I don't know what <http://url.to/physicsVocab#time> is, but note that an  
exact time isn't very useful without a timezone, so I added the PRC  
timezone for you. I'll also note that using traditional Chinese for the  
full name of the PRC is an odd choice, so I changed it to simplified  
Chinese above.

Marking up the population as "14.61 million people" isn't terribly helpful  
if you want a computer to be able to find the city with the biggest  
population among several cities, unless your vocabulary defines how to  
parse "14.61 million people" into a number, which would be strange. In any  
case this is hidden metadata unless you want 14610000 or some other easily  
machine-parsable representation to be visible in the page rendering.

Finally, I think <http://xmlns.com/foaf/spec/index.rdf#name> should be  
<http://xmlns.com/foaf/0.1/name>. If you're going to use existing  
vocabularies like FOAF and want your data to be play nice with the RDF  
world, make sure to check that the result of the RDF extraction algorithm  
[3] is what you intended. In particular, you probably want to use itemid  
where possible and make sure that all your URIs are exactly correct.  
Personally, though, unless I could reuse existing vocabularies for every  
single item and property, I would only use a full URI for itemtype and  
point that to a vocabulary that defines what simpler property names like  
"name" and "city" mean and how to convert the vocabulary to RDF.

[1]  
http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2009-November/024116.html
[2]  
http://www.whatwg.org/specs/web-apps/current-work/multipage/microdata.html#the-properties-of-an-item
[3]  
http://www.whatwg.org/specs/web-apps/current-work/multipage/converting-html-to-other-formats.html#rdf

-- 
Philip Jägenstedt
Core Developer
Opera Software



More information about the whatwg mailing list