[whatwg] Microdata DOM API issues

Philip Jägenstedt philipj at opera.com
Sat Nov 14 01:32:58 PST 2009


On Sat, 14 Nov 2009 00:34:12 +0100, Tab Atkins Jr. <jackalmage at gmail.com>  
wrote:

> On Fri, Nov 13, 2009 at 5:14 PM, Philip Jägenstedt <philipj at opera.com>  
> wrote:
>> The itemref mechanism allows creating arbitrary graphs of items, rather  
>> than
>> the tree of items that is the intended microdata model (right?). Even  
>> though
>> my default reaction to graphs is "oh cool", for microdata when the  
>> domain
>> model is a graph you should probably just represent it with a level of
>> indirection (RDF).
>>
>> Options:
>> 1. patch the algorithms which can go into recursion
>> 2. patch
>> <http://www.whatwg.org/specs/web-apps/current-work/multipage/microdata.html#associating-names-with-items>
>> to first check if an itemref'd property creates a loop before adding it  
>> to
>> candidates
>> 3. ?
>>
>> I think I prefer 2.
>
> Looping in data-graphs is often useful, so I'm not sure I want to
> throw it out generally.  Your statement in the first paragraph I'm
> quoting, though, says that you'd rather leave loops to be defined in
> the vocabulary itself?  So loops would be done by, frex, itemprop'ing
> a link to the other element rather than itemref'ing the other element
> directly?

Yes, that's basically what I'm saying. One option is to simply use  
microdata such that the RDF you extract is the graph you want (it will  
probably look quite ugly though). Another is always referencing subitems  
by a mechanism other than refid. For example, in the MusicBrainz XML  
webservice when an artist contains a release which itself references  
artists (e.g. as the producer), a stub item is used with only artist name  
and id, rather than including all information recursively. In microdata I  
would do:

<section itemscope
  itemtype="http://musicbrainz.org/artist/"
  itemid="http://musicbrainz.org/artist/4d5447d7-c61c-4120-ba1b-d7f471d385b9">
  <h1 itemprop="name">John Lennon</h1>
  <section>
   <h1>Releases</h1>
   <section itemprop="release"
    itemscope
    itemtype="http://musicbrainz.org/release/"
    itemid="http://musicbrainz.org/release/f237e6a0-4b0e-4722-8172-66f4930198bc">
    <h1>Imagine</h1>
    Producer:
    <span itemprop="producer"
     itemscope
     itemtype="http://musicbrainz.org/artist/"
     itemid="http://musicbrainz.org/artist/e7b587f7-e678-47c1-81dd-e7bb7855b0f9"
     ><span itemprop="name">Phil Spector</span></span>
   </section>
  </section>
</section>

Even if John Lennon were the producer here, you don't get any looping in  
the microdata itself. If you want to know everything about the producer,  
you should just follow the itemid... I haven't looked that much at the RDF  
extraction algorithm yet, but I think this example might even create the  
proper graph with loops if the producer were John Lennon.

> That would probably be fine, and is compatible with a tree-based data
> model like JSON.  Vocabs should know when loops are
> permissible/desirable for themselves.

I agree, I don't see that we have a problem here.

-- 
Philip Jägenstedt
Opera Software


More information about the whatwg mailing list