W3C home > Mailing lists > Public > whatwg@whatwg.org > November 2009

[whatwg] Microdata DOM API issues

From: Philip Jägenstedt <philipj@opera.com>
Date: Sat, 14 Nov 2009 00:14:37 +0100
Message-ID: <op.u3cv6nfjsr6mfa@worf>
On Fri, 13 Nov 2009 19:27:39 +0100, Philip J?genstedt <philipj at opera.com>  

> On Thu, 12 Nov 2009 03:23:54 +0100, Philip J?genstedt  
> <philipj at opera.com> wrote:
>> Why are the algorithms for extracting RDF gone? All that's left is the  
>> book example with the equivalent Turtle, but it would be nice if it  
>> were actually defined how to extract RDF. The same for the JSON stuff,  
>> was that no good?
> D'oh! I've been reading the multipage version and missed that it's on  
> another page:
> http://www.whatwg.org/specs/web-apps/current-work/multipage/converting-html-to-other-formats.html
> I'll have to try implementing that and see if there are any more issues.


This was easy to implement, but the algorithm isn't guaranteed to  

<div itemscope>
   <div itemprop="foo" itemscope itemref="oops" id="oops"></div>

This simple input causes the algorithm to recurse as the item references  
itself. I went back to the vCard algorithm and found that it too will fail  
to terminate with this input:

<span itemscope itemtype="http://microformats.org/profile/hcard">
   <span itemprop="agent" itemscope id="oops" itemref="oops"

vEvent is safe as the algorithm never recurses, but the RDF conversion  
algorithm would hit the same problem.

It's certainly possible to create loops which are less easy to spot:

<div itemscope>
   <div itemprop="prop1" itemscope itemref="id2" id="id1"></div>
   <div itemprop="prop2" itemscope itemref="id3" id="id2"></div>
   <div itemprop="propn" itemscope itemref="id1" id="idn"></div>

Or this:

<div itemscope>
   <div itemprop="foo" itemscope id="a">
     <div itemprop="bar" itemscope itemref="a"></div>

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).

1. patch the algorithms which can go into recursion
2. patch  
to first check if an itemref'd property creates a loop before adding it to  
3. ?

I think I prefer 2.

Philip J?genstedt
Received on Friday, 13 November 2009 15:14:37 UTC

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