W3C home > Mailing lists > Public > whatwg@whatwg.org > May 2011

[whatwg] Proposed simplification to Microdata

From: Tab Atkins Jr. <jackalmage@gmail.com>
Date: Thu, 26 May 2011 18:15:46 -0700
Message-ID: <BANLkTikttPJzszzGYdiwEXK+d1wyPeZy0A@mail.gmail.com>
On Thu, May 26, 2011 at 12:02 PM, Guha <guha at google.com> wrote:
> We are trying to simplify statement of a fairly common thing that crops up
> with microdata
>
> E.g.,
>
> Consider the block:
> 1) <div itemscope itemtype=?http://schema.org/Book?>
> ? ? ?<span itemprop=?name?>The Catcher in the Rye</span> -
> ? ? by <span itemprop=?hasAuthor?>J.D. Salinger</span>
> ? </div>
>
> Now, the site wants to use the wikipedia (or freebase) entry for Salinger,
> just to be clear and wants the value of the ?hasAuthor property to be an
> item with that ID.
> I believe the following says that:
>
> 2) <div itemscope itemtype=?http://schema.org/Book?>
> ? ? ?<span itemprop=?name?>The Catcher in the Rye</span> -
> ? by <a href="http://en.wikipedia.org/wiki/J._D._Salinger"
> itemprop=?hasAuthor?>J.D.
> Salinger</a>
> ? </div>
>
> Often, the site does not want to link out to the wikipedia (or other
> canonical url) page, but only specify
> it in the microdata. This can be done by:
>
> 3) <div itemscope itemtype=?http://schema.org/Book?>
> ? ? <span itemprop=?name?>The Catcher in the Rye</span> -
> ? by <span itemscope
> itemid="http://en.wikipedia.org/wiki/J._D._Salinger"
> itemprop=?hasAuthor?>J.D.
> Salinger</span>
> ?</div>

No, that's invalid:
"The itemid attribute must not be specified on elements that do not
have both an itemscope attribute and an itemtype attribute specified,
and must not be specified on elements with an itemscope attribute
whose itemtype attribute specifies a vocabulary that does not support
global identifiers for items, as defined by that vocabulary's
specification."

The correct way to solve this case is with markup like this:

<div itemscope itemtype="http://scheme.org/Book">
  <span itemprop="name">The Catcher in the Rye</span> -
  by J.D. Salinger
  <link itemprop="hasAuthor" href="http://en.wikipedia.org/wiki/J._D._Salinger">
</div>

<link> and <meta> are defined to be allowed in the <body> specifically
to carry non-visible Microdata information.

~TJ
Received on Thursday, 26 May 2011 18:15:46 UTC

This archive was generated by hypermail 2.4.0 : Wednesday, 22 January 2020 16:59:33 UTC