[html5] r4610 - [acgiowt] (0) Change how itemref='' is processed to prevent infinite loops in th [...]

whatwg at whatwg.org whatwg at whatwg.org
Mon Jan 18 04:55:35 PST 2010


Author: ianh
Date: 2010-01-18 04:55:33 -0800 (Mon, 18 Jan 2010)
New Revision: 4610

Modified:
   complete.html
   index
   source
Log:
[acgiowt] (0) Change how itemref='' is processed to prevent infinite loops in the algorithms that handle microdata. (Mark II)

Modified: complete.html
===================================================================
--- complete.html	2010-01-18 11:08:58 UTC (rev 4609)
+++ complete.html	2010-01-18 12:55:33 UTC (rev 4610)
@@ -621,27 +621,28 @@
      <li><a href=#items><span class=secno>5.2.2 </span>Items</a></li>
      <li><a href=#names:-the-itemprop-attribute><span class=secno>5.2.3 </span>Names: the <code>itemprop</code> attribute</a></li>
      <li><a href=#values><span class=secno>5.2.4 </span>Values</a></li>
-     <li><a href=#associating-names-with-items><span class=secno>5.2.5 </span>Associating names with items</a></li>
-     <li><a href=#examples-1><span class=secno>5.2.6 </span>Examples</a></ol></li>
+     <li><a href=#associating-names-with-items><span class=secno>5.2.5 </span>Associating names with items</a></ol></li>
    <li><a href=#microdata-dom-api><span class=secno>5.3 </span>Microdata DOM API</a></li>
    <li><a href=#mdvocabs><span class=secno>5.4 </span>Microdata vocabularies</a>
     <ol>
      <li><a href=#vcard><span class=secno>5.4.1 </span>vCard</a>
       <ol>
        <li><a href=#conversion-to-vcard><span class=secno>5.4.1.1 </span>Conversion to vCard</a></li>
-       <li><a href=#examples-2><span class=secno>5.4.1.2 </span>Examples</a></ol></li>
+       <li><a href=#examples-1><span class=secno>5.4.1.2 </span>Examples</a></ol></li>
      <li><a href=#vevent><span class=secno>5.4.2 </span>vEvent</a>
       <ol>
        <li><a href=#conversion-to-icalendar><span class=secno>5.4.2.1 </span>Conversion to iCalendar</a></li>
-       <li><a href=#examples-3><span class=secno>5.4.2.2 </span>Examples</a></ol></li>
+       <li><a href=#examples-2><span class=secno>5.4.2.2 </span>Examples</a></ol></li>
      <li><a href=#licensing-works><span class=secno>5.4.3 </span>Licensing works</a>
       <ol>
        <li><a href=#conversion-to-rdf><span class=secno>5.4.3.1 </span>Conversion to RDF</a></li>
-       <li><a href=#examples-4><span class=secno>5.4.3.2 </span>Examples</a></ol></ol></li>
+       <li><a href=#examples-3><span class=secno>5.4.3.2 </span>Examples</a></ol></ol></li>
    <li><a href=#converting-html-to-other-formats><span class=secno>5.5 </span>Converting HTML to other formats</a>
     <ol>
      <li><a href=#json><span class=secno>5.5.1 </span>JSON</a></li>
-     <li><a href=#rdf><span class=secno>5.5.2 </span>RDF</a></li>
+     <li><a href=#rdf><span class=secno>5.5.2 </span>RDF</a>
+      <ol>
+       <li><a href=#examples-4><span class=secno>5.5.2.1 </span>Examples</a></ol></li>
      <li><a href=#atom><span class=secno>5.5.3 </span>Atom</a></ol></ol></li>
  <li><a href=#browsers><span class=secno>6 </span>Web browsers</a>
   <ol>
@@ -45473,9 +45474,8 @@
 
   <p>The <code title=attr-itemref><a href=#attr-itemref>itemref</a></code> attribute, if
   specified, must have a value that is an <a href=#unordered-set-of-unique-space-separated-tokens>unordered set of
-  unique space-separated tokens</a> consisting of <a href=#concept-id title=concept-ID>IDs</a> of elements in the same document; for
-  each one, the element's nearest ancestor element with an <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute specified, if any,
-  must not be the element with the referencing <code title=attr-itemref><a href=#attr-itemref>itemref</a></code> attribute specified.</p>
+  unique space-separated tokens</a> consisting of <a href=#concept-id title=concept-ID>IDs</a> of elements in the same <a href=#home-subtree>home
+  subtree</a>.</p>
 
   <p>The <code title=attr-itemref><a href=#attr-itemref>itemref</a></code> attribute must not
   be specified on elements that do not have an <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute specified.</p>
@@ -45661,126 +45661,175 @@
 
   <h4 id=associating-names-with-items><span class=secno>5.2.5 </span>Associating names with items</h4>
 
-  <p>To find <dfn id=the-properties-of-an-item>the properties of an item</dfn>, the user agent must
-  run the following steps:</p>
+  <p>To find <dfn id=the-properties-of-an-item>the properties of an item</dfn> defined by the
+  element <var title="">root</var>, the user agent must try to
+  <a href=#crawl-the-properties>crawl the properties</a> of the element <var title="">root</var>, with an empty list as the value of <var title="">memory</var>: if this fails, then <a href=#the-properties-of-an-item title="the
+  properties of an item">the properties of the item</a> defined by
+  the element <var title="">root</var> is an empty list; otherwise, it
+  is the returned list.</p>
 
-  <ol><li><p>Let <var title="">root</var> be the element with the <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute.</li>
+  <p>To <dfn id=crawl-the-properties>crawl the properties</dfn> of an element <var title="">root</var> with a list <var title="">memory</var>, the user
+  agent must run the following steps:</p>
 
-   <li><p>Let <var title="">pending</var> be a stack of elements
-   initially containing the child elements of <var title="">root</var>, if any. This list will be the one that holds
-   the elements that still need to be crawled.</li>
+  <ol><li><p>If <var title="">root</var> is in <var title="">memory</var>, then the algorithm fails; abort these
+   steps.</li>
 
-   <li><p>Let <var title="">properties</var> be an empty list of
-   elements. This list will be the result of the algorithm: a list of
-   elements with properties that apply to <var title="">root</var>.</li>
+   <li><p><a href=#collect-all-the-elements-in-the-item>Collect all the elements in the item</a> <var title="">root</var>, and let <var title="">results</var> be the
+   result.</li>
 
-   <li><p>If <var title="">root</var> has an <code title=attr-itemref><a href=#attr-itemref>itemref</a></code> attribute, <a href=#split-a-string-on-spaces title="split a
-   string on spaces">split the value of that <code title=attr-itemref>itemref</code> attribute on spaces</a>. For
-   each resulting token, <var title="">ID</var>, if there is an
-   element in the document with the <a href=#concept-id title=concept-ID>ID</a>
-   <var title="">ID</var>, then push the first such element onto <var title="">pending</var>.</li>
+   <li><p>If <var title="">root</var> is in <var title="">results</var>, then the algorithm fails; abort these
+   steps.</li>
 
-   <li>
+   <li><p>If any elements are listed in <var title="">results</var>
+   more than once, then the algorithm fails; abort these
+   steps.</li>
 
-    <p>For each element <var title="">candidate</var> in <var title="">pending</var>, run the following substeps:</p>
+   <li><p>Remove any elements from <var title="">results</var> that do
+   not have an <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute
+   specified.</li>
 
-    <ol><li><p>Let <var title="">scope</var> be <var title="">candidate</var>'s nearest ancestor element with an <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute specified, if
-     any, or null otherwise.</li>
+   <li><p>Let <var title="">new memory</var> be a new list consisting
+   of the old list <var title="">memory</var> with the addition of
+   <var title="">root</var>.</li>
 
-     <li><p>If one of the other elements in <var title="">pending</var>
-     is also <var title="">candidate</var>, then remove <var title="">candidate</var> from <var title="">pending</var>
-     (i.e. remove duplicates).</li>
+   <li><p>For each element in <var title="">results</var> that has an
+   <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute specified,
+   <a href=#crawl-the-properties>crawl the properties</a> of the element, with <var title="">new memory</var> as the memory. If this fails, then this
+   instance of the algorithm fails as well; abort these steps. (If it
+   succeeds, the return value is discarded.)</li>
 
-     <li><p>Otherwise, if one of the other elements in <var title="">pending</var> is an ancestor element of <var title="">candidate</var>, and that element is <var title="">scope</var>, then remove <var title="">candidate</var>
-     from <var title="">pending</var> (since <var title="">candidate</var> will be reached anyway as part of
-     processing <var title="">scope</var>).</li>
+   <li><p>Sort <var title="">results</var> in <a href=#tree-order>tree
+   order</a>.</li>
 
-     <li><p>Otherwise, if one of the other elements in <var title="">pending</var> is an ancestor element of <var title="">candidate</var>, and either <var title="">scope</var> is
-     null or that element also has <var title="">scope</var> as its
-     nearest ancestor element with an <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute specified, then
-     remove <var title="">candidate</var> from <var title="">pending</var> (since <var title="">candidate</var> will
-     be reached anyway as part of processing <var title="">scope</var>).</li>
+   <li><p>Return <var title="">results</var>.</li>
 
-    </ol></li>
+  </ol><p>To <dfn id=collect-all-the-elements-in-the-item>collect all the elements in the item</dfn> <var title="">root</var>, the user agent must run these steps:</p>
 
-   <li><p>Sort <var title="">pending</var> in <a href=#tree-order>tree
-   order</a>.</li>
+  <ol><li><p>Let <var title="">results</var> and <var title="">pending</var> be empty lists of elements.</li>
 
-   <li><p><i>Loop</i>: Pop the top element from <var title="">pending</var> and let <var title="">current</var> be that
+   <li><p>Add all the children elements of <var title="">root</var> to
+   <var title="">pending</var>.</li>
+
+   <li><p>If <var title="">root</var> has an <code title=attr-itemref><a href=#attr-itemref>itemref</a></code> attribute, <a href=#split-a-string-on-spaces title="split a
+   string on spaces">split the value of that <code title=attr-itemref>itemref</code> attribute on spaces</a>. For
+   each resulting token <var title="">ID</var>, if there is an element
+   in the <a href=#home-subtree>home subtree</a> of <var title="">root</var> with
+   the <a href=#concept-id title=concept-ID>ID</a> <var title="">ID</var>, then
+   add the first such element to <var title="">pending</var>.</li>
+
+   <li><p><i>Loop</i>: Remove an element from <var title="">pending</var> and let <var title="">current</var> be that
    element.</li>
 
-   <li><p>If <var title="">current</var> has an <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute, then append <var title="">current</var> to <var title="">properties</var>.</li>
+   <li><p>Add <var title="">current</var> to <var title="">results</var>.</li>
 
-   <li><p>If <var title="">current</var> does not have an <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute, and <var title="">current</var> is an element with child elements, then:
-   push all the child elements of <var title="">current</var> onto
-   <var title="">pending</var>, in <a href=#tree-order>tree order</a> (so the first
-   child of <var title="">current</var> will be the next element to be
-   popped from <var title="">pending</var>).</li>
+   <li><p>If <var title="">current</var> does not have an <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute, then: add all
+   the child elements of <var title="">current</var> to <var title="">pending</var>.</li>
 
    <li><p><i>End of loop</i>: If <var title="">pending</var> is not
    empty, return to the step marked <i>loop</i>.</li>
 
-   <li><p>Return <var title="">properties</var>. That is the list of
-   <a href=#the-properties-of-an-item title="the properties of an item">properties of the
-   item</a> <var title="">root</var>. By definition, this list is
-   in <a href=#tree-order>tree order</a>.</li>
+   <li><p>Return <var title="">results</var>.</li>
 
-  </ol><p>A document must not contain any elements that have an <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute that would not be
+  </ol><p>An <a href=#concept-item title=concept-item>item</a> is a <dfn id=top-level-microdata-items title="top-level microdata items">top-level microdata item</dfn> if
+  its element does not have an <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute.</p>
+
+  <p>An <a href=#concept-item title=concept-item>item</a> is a <dfn id=used-microdata-items title="used
+  microdata items">used microdata item</dfn> if it is a <a href=#top-level-microdata-items title="top-level microdata items">top-level microdata item</a>,
+  or if it has an <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code>
+  attribute and would be <a href=#the-properties-of-an-item title="the properties of an item">found
+  to be the property</a> of an <a href=#concept-item title=concept-item>item</a> that is itself a <a href=#used-microdata-items title="used
+  microdata items">used microdata item</a>.</p>
+
+  <p>A document must not contain any <a href=#concept-item title=concept-item>items</a> that are not <a href=#used-microdata-items>used microdata
+  items</a>.</p>
+
+  <p>A document must not contain any elements that have an <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute that would not be
   found to be a property of any of the <a href=#concept-item title=concept-item>items</a> in that document were their <a href=#the-properties-of-an-item title="the properties of an item">properties</a> all to be
   determined.</p>
 
-  <p>An <a href=#concept-item title=concept-item>item</a> is a <dfn id=top-level-microdata-items title="top-level microdata items">top-level microdata item</dfn> if
-  its element does not have an <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute.</p>
+  <p>A document must not contain any <a href=#concept-item title=concept-item>items</a> for which <a href=#crawl-the-properties title="crawl the
+  properties">crawling the properties</a> of the element, with an
+  empty list as the value of <var title="">memory</var>, fails.</p>
 
+  <p class=note>The algorithms in this section are especially
+  inefficient, in the interests of keeping them easy to
+  understand. Implementors are strongly encouraged to refactor and
+  optimise them in their user agents.</p>
 
-  <h4 id=examples-1><span class=secno>5.2.6 </span>Examples</h4>
+  <div class=example>
 
-  <p>Here is an example of some HTML using Microdata to express RDF
-  statements:</p>
+   <p>In this example, a single license statement is applied to two
+   works, using <code title=attr-itemref><a href=#attr-itemref>itemref</a></code> from the
+   items representing the works:</p>
 
-  <pre><dl itemscope
-    itemtype="http://purl.org/vocab/frbr/core#Work"
-    itemid="http://purl.oreilly.com/works/45U8QJGZSQKDH8N">
- <dt>Title</dt>
- <dd><cite itemprop="http://purl.org/dc/terms/title">Just a Geek</cite></dd>
- <dt>By</dt>
- <dd><span itemprop="http://purl.org/dc/terms/creator">Wil Wheaton</span></dd>
- <dt>Format</dt>
- <dd itemprop="http://purl.org/vocab/frbr/core#realization"
-     itemscope
-     itemtype="http://purl.org/vocab/frbr/core#Expression"
-     itemid="http://purl.oreilly.com/products/9780596007683.BOOK">
-  <link itemprop="http://purl.org/dc/terms/type" href="http://purl.oreilly.com/product-types/BOOK">
-  Print
- </dd>
- <dd itemprop="http://purl.org/vocab/frbr/core#realization"
-     itemscope
-     itemtype="http://purl.org/vocab/frbr/core#Expression"
-     itemid="http://purl.oreilly.com/products/9780596802189.EBOOK">
-  <link itemprop="http://purl.org/dc/terms/type" href="http://purl.oreilly.com/product-types/EBOOK">
-  Ebook
- </dd>
-</dl></pre>
+   <pre><!DOCTYPE HTML>
+<html>
+ <head>
+  <title>Photo gallery</title>
+ </head>
+ <body>
+  <h1>My photos</h1>
+  <figure itemscope itemtype="http://n.whatwg.org/work" itemref="licenses">
+   <img itemprop="work" src="images/house.jpeg" alt="A white house, boarded up, sits in a forest.">
+   <figcaption itemprop="title">The house I found.</figcaption>
+  </figure>
+  <figure itemscope itemtype="http://n.whatwg.org/work" itemref="licenses">
+   <img itemprop="work" src="images/mailbox.jpeg" alt="Outside the house is a mailbox. It has a leaflet inside.">
+   <figcaption itemprop="title">The mailbox.</figcaption>
+  </figure>
+  <footer>
+   <p id="licenses">All images licensed under the <a itemprop="license"
+   href="http://www.opensource.org/licenses/mit-license.php">MIT
+   license</a>.</p>
+  </footer>
+ </body>
+</html></pre>
 
-  <p>This is equivalent to the following Turtle:</p>
+   <p>The above results in two items with the type "<code title="">http://n.whatwg.org/work</code>", one with:</p>
 
-  <pre>@prefix dc: <http://purl.org/dc/terms/> .
- at prefix frbr: <http://purl.org/vocab/frbr/core#> .
+   <dl class=brief><dt>work
+    <dd><code title="">images/house.jpeg</code>
+    <dt>title
+    <dd>The house I found.
+    <dt>license
+    <dd><code title="">http://www.opensource.org/licenses/mit-license.php</code>
+   </dl><p>...and one with:</p>
 
-<http://purl.oreilly.com/works/45U8QJGZSQKDH8N> a frbr:Work ;
-     dc:creator "Wil Wheaton"@en ;
-     dc:title "Just a Geek"@en ;
-     frbr:realization <http://purl.oreilly.com/products/9780596007683.BOOK>,
-         <http://purl.oreilly.com/products/9780596802189.EBOOK> . 
+   <dl class=brief><dt>work
+    <dd><code title="">images/mailbox.jpeg</code>
+    <dt>title
+    <dd>The mailbox.
+    <dt>license
+    <dd><code title="">http://www.opensource.org/licenses/mit-license.php</code>
+   </dl></div>
 
-<http://purl.oreilly.com/products/9780596007683.BOOK> a frbr:Expression ;
-     dc:type <http://purl.oreilly.com/product-types/BOOK> . 
+  <div class=example>
 
-<http://purl.oreilly.com/products/9780596802189.EBOOK> a frbr:Expression ;
-     dc:type <http://purl.oreilly.com/product-types/EBOOK> .</pre>
+   <p>In the following invalid example, the items are all empty,
+   because the <code title=attr-itemref><a href=#attr-itemref>itemref</a></code> attribute on
+   the inner nested item indirectly references the same element twice
+   in the same item:</p>
 
+   <pre class=bad><!-- invalid example - do not copy -->
+<div itemscope>
+ <span itemprop="example">This is <em>not</em> a property of the
+ <code>div</code> element.</span>
+ <p itemprop="demo" itemscope itemref="test thing"> <!-- "thing" is a descendant
+                   of "test", which leads to it being included twice, which is invalid -->
+  <span itemprop="sample">This isn't part of anything either.</span>
+ </p>
+</div>
+<p id="test">
+ <span id="thing">(this element is referenced twice by the
+ <code>p</code> above, causing all the items that involve that
+ <code>itemref=""</code> attribute to act as if they had no
+ properties.)</span>
+</p></pre>
 
+  </div>
 
+
+
   <h3 id=microdata-dom-api><span class=secno>5.3 </span>Microdata DOM API</h3>
 
 
@@ -47590,7 +47639,7 @@
 
 
 
-  <h5 id=examples-2><span class=secno>5.4.1.2 </span>Examples</h5>
+  <h5 id=examples-1><span class=secno>5.4.1.2 </span>Examples</h5>
 
   <div class=example>
 
@@ -48401,7 +48450,7 @@
 
 
 
-  <h5 id=examples-3><span class=secno>5.4.2.2 </span>Examples</h5>
+  <h5 id=examples-2><span class=secno>5.4.2.2 </span>Examples</h5>
 
 <!-- get more from http://www.ietf.org/rfc/rfc2445.txt -->
 
@@ -48584,7 +48633,7 @@
 
 
 
-  <h5 id=examples-4><span class=secno>5.4.3.2 </span>Examples</h5>
+  <h5 id=examples-3><span class=secno>5.4.3.2 </span>Examples</h5>
 
   <div class=example>
 
@@ -48927,8 +48976,58 @@
 
    <li><p>Return <var title="">subject</var>.</li>
 
-  </ol><h4 id=atom><span class=secno>5.5.3 </span>Atom</h4>
+  </ol><h5 id=examples-4><span class=secno>5.5.2.1 </span>Examples</h5>
 
+  <p>Here is an example of some HTML using Microdata to express RDF
+  statements:</p>
+
+  <pre><dl itemscope
+    itemtype="http://purl.org/vocab/frbr/core#Work"
+    itemid="http://purl.oreilly.com/works/45U8QJGZSQKDH8N">
+ <dt>Title</dt>
+ <dd><cite itemprop="http://purl.org/dc/terms/title">Just a Geek</cite></dd>
+ <dt>By</dt>
+ <dd><span itemprop="http://purl.org/dc/terms/creator">Wil Wheaton</span></dd>
+ <dt>Format</dt>
+ <dd itemprop="http://purl.org/vocab/frbr/core#realization"
+     itemscope
+     itemtype="http://purl.org/vocab/frbr/core#Expression"
+     itemid="http://purl.oreilly.com/products/9780596007683.BOOK">
+  <link itemprop="http://purl.org/dc/terms/type" href="http://purl.oreilly.com/product-types/BOOK">
+  Print
+ </dd>
+ <dd itemprop="http://purl.org/vocab/frbr/core#realization"
+     itemscope
+     itemtype="http://purl.org/vocab/frbr/core#Expression"
+     itemid="http://purl.oreilly.com/products/9780596802189.EBOOK">
+  <link itemprop="http://purl.org/dc/terms/type" href="http://purl.oreilly.com/product-types/EBOOK">
+  Ebook
+ </dd>
+</dl></pre>
+
+  <p>This is equivalent to the following Turtle:</p>
+
+  <pre>@prefix dc: <http://purl.org/dc/terms/> .
+ at prefix frbr: <http://purl.org/vocab/frbr/core#> .
+
+<http://purl.oreilly.com/works/45U8QJGZSQKDH8N> a frbr:Work ;
+     dc:creator "Wil Wheaton"@en ;
+     dc:title "Just a Geek"@en ;
+     frbr:realization <http://purl.oreilly.com/products/9780596007683.BOOK>,
+         <http://purl.oreilly.com/products/9780596802189.EBOOK> . 
+
+<http://purl.oreilly.com/products/9780596007683.BOOK> a frbr:Expression ;
+     dc:type <http://purl.oreilly.com/product-types/BOOK> . 
+
+<http://purl.oreilly.com/products/9780596802189.EBOOK> a frbr:Expression ;
+     dc:type <http://purl.oreilly.com/product-types/EBOOK> .</pre>
+
+
+
+
+
+  <h4 id=atom><span class=secno>5.5.3 </span>Atom</h4>
+
   <p>Given a <code>Document</code> <var title="">source</var>, a user
   agent may run the following algorithm to <dfn id=extracting-atom title="extracting
   Atom">extract an Atom feed</dfn>. This is not the only algorithm

Modified: index
===================================================================
--- index	2010-01-18 11:08:58 UTC (rev 4609)
+++ index	2010-01-18 12:55:33 UTC (rev 4610)
@@ -628,27 +628,28 @@
      <li><a href=#items><span class=secno>5.2.2 </span>Items</a></li>
      <li><a href=#names:-the-itemprop-attribute><span class=secno>5.2.3 </span>Names: the <code>itemprop</code> attribute</a></li>
      <li><a href=#values><span class=secno>5.2.4 </span>Values</a></li>
-     <li><a href=#associating-names-with-items><span class=secno>5.2.5 </span>Associating names with items</a></li>
-     <li><a href=#examples-1><span class=secno>5.2.6 </span>Examples</a></ol></li>
+     <li><a href=#associating-names-with-items><span class=secno>5.2.5 </span>Associating names with items</a></ol></li>
    <li><a href=#microdata-dom-api><span class=secno>5.3 </span>Microdata DOM API</a></li>
    <li><a href=#mdvocabs><span class=secno>5.4 </span>Microdata vocabularies</a>
     <ol>
      <li><a href=#vcard><span class=secno>5.4.1 </span>vCard</a>
       <ol>
        <li><a href=#conversion-to-vcard><span class=secno>5.4.1.1 </span>Conversion to vCard</a></li>
-       <li><a href=#examples-2><span class=secno>5.4.1.2 </span>Examples</a></ol></li>
+       <li><a href=#examples-1><span class=secno>5.4.1.2 </span>Examples</a></ol></li>
      <li><a href=#vevent><span class=secno>5.4.2 </span>vEvent</a>
       <ol>
        <li><a href=#conversion-to-icalendar><span class=secno>5.4.2.1 </span>Conversion to iCalendar</a></li>
-       <li><a href=#examples-3><span class=secno>5.4.2.2 </span>Examples</a></ol></li>
+       <li><a href=#examples-2><span class=secno>5.4.2.2 </span>Examples</a></ol></li>
      <li><a href=#licensing-works><span class=secno>5.4.3 </span>Licensing works</a>
       <ol>
        <li><a href=#conversion-to-rdf><span class=secno>5.4.3.1 </span>Conversion to RDF</a></li>
-       <li><a href=#examples-4><span class=secno>5.4.3.2 </span>Examples</a></ol></ol></li>
+       <li><a href=#examples-3><span class=secno>5.4.3.2 </span>Examples</a></ol></ol></li>
    <li><a href=#converting-html-to-other-formats><span class=secno>5.5 </span>Converting HTML to other formats</a>
     <ol>
      <li><a href=#json><span class=secno>5.5.1 </span>JSON</a></li>
-     <li><a href=#rdf><span class=secno>5.5.2 </span>RDF</a></li>
+     <li><a href=#rdf><span class=secno>5.5.2 </span>RDF</a>
+      <ol>
+       <li><a href=#examples-4><span class=secno>5.5.2.1 </span>Examples</a></ol></li>
      <li><a href=#atom><span class=secno>5.5.3 </span>Atom</a></ol></ol></li>
  <li><a href=#browsers><span class=secno>6 </span>Web browsers</a>
   <ol>
@@ -45373,9 +45374,8 @@
 
   <p>The <code title=attr-itemref><a href=#attr-itemref>itemref</a></code> attribute, if
   specified, must have a value that is an <a href=#unordered-set-of-unique-space-separated-tokens>unordered set of
-  unique space-separated tokens</a> consisting of <a href=#concept-id title=concept-ID>IDs</a> of elements in the same document; for
-  each one, the element's nearest ancestor element with an <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute specified, if any,
-  must not be the element with the referencing <code title=attr-itemref><a href=#attr-itemref>itemref</a></code> attribute specified.</p>
+  unique space-separated tokens</a> consisting of <a href=#concept-id title=concept-ID>IDs</a> of elements in the same <a href=#home-subtree>home
+  subtree</a>.</p>
 
   <p>The <code title=attr-itemref><a href=#attr-itemref>itemref</a></code> attribute must not
   be specified on elements that do not have an <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute specified.</p>
@@ -45561,126 +45561,175 @@
 
   <h4 id=associating-names-with-items><span class=secno>5.2.5 </span>Associating names with items</h4>
 
-  <p>To find <dfn id=the-properties-of-an-item>the properties of an item</dfn>, the user agent must
-  run the following steps:</p>
+  <p>To find <dfn id=the-properties-of-an-item>the properties of an item</dfn> defined by the
+  element <var title="">root</var>, the user agent must try to
+  <a href=#crawl-the-properties>crawl the properties</a> of the element <var title="">root</var>, with an empty list as the value of <var title="">memory</var>: if this fails, then <a href=#the-properties-of-an-item title="the
+  properties of an item">the properties of the item</a> defined by
+  the element <var title="">root</var> is an empty list; otherwise, it
+  is the returned list.</p>
 
-  <ol><li><p>Let <var title="">root</var> be the element with the <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute.</li>
+  <p>To <dfn id=crawl-the-properties>crawl the properties</dfn> of an element <var title="">root</var> with a list <var title="">memory</var>, the user
+  agent must run the following steps:</p>
 
-   <li><p>Let <var title="">pending</var> be a stack of elements
-   initially containing the child elements of <var title="">root</var>, if any. This list will be the one that holds
-   the elements that still need to be crawled.</li>
+  <ol><li><p>If <var title="">root</var> is in <var title="">memory</var>, then the algorithm fails; abort these
+   steps.</li>
 
-   <li><p>Let <var title="">properties</var> be an empty list of
-   elements. This list will be the result of the algorithm: a list of
-   elements with properties that apply to <var title="">root</var>.</li>
+   <li><p><a href=#collect-all-the-elements-in-the-item>Collect all the elements in the item</a> <var title="">root</var>, and let <var title="">results</var> be the
+   result.</li>
 
-   <li><p>If <var title="">root</var> has an <code title=attr-itemref><a href=#attr-itemref>itemref</a></code> attribute, <a href=#split-a-string-on-spaces title="split a
-   string on spaces">split the value of that <code title=attr-itemref>itemref</code> attribute on spaces</a>. For
-   each resulting token, <var title="">ID</var>, if there is an
-   element in the document with the <a href=#concept-id title=concept-ID>ID</a>
-   <var title="">ID</var>, then push the first such element onto <var title="">pending</var>.</li>
+   <li><p>If <var title="">root</var> is in <var title="">results</var>, then the algorithm fails; abort these
+   steps.</li>
 
-   <li>
+   <li><p>If any elements are listed in <var title="">results</var>
+   more than once, then the algorithm fails; abort these
+   steps.</li>
 
-    <p>For each element <var title="">candidate</var> in <var title="">pending</var>, run the following substeps:</p>
+   <li><p>Remove any elements from <var title="">results</var> that do
+   not have an <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute
+   specified.</li>
 
-    <ol><li><p>Let <var title="">scope</var> be <var title="">candidate</var>'s nearest ancestor element with an <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute specified, if
-     any, or null otherwise.</li>
+   <li><p>Let <var title="">new memory</var> be a new list consisting
+   of the old list <var title="">memory</var> with the addition of
+   <var title="">root</var>.</li>
 
-     <li><p>If one of the other elements in <var title="">pending</var>
-     is also <var title="">candidate</var>, then remove <var title="">candidate</var> from <var title="">pending</var>
-     (i.e. remove duplicates).</li>
+   <li><p>For each element in <var title="">results</var> that has an
+   <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute specified,
+   <a href=#crawl-the-properties>crawl the properties</a> of the element, with <var title="">new memory</var> as the memory. If this fails, then this
+   instance of the algorithm fails as well; abort these steps. (If it
+   succeeds, the return value is discarded.)</li>
 
-     <li><p>Otherwise, if one of the other elements in <var title="">pending</var> is an ancestor element of <var title="">candidate</var>, and that element is <var title="">scope</var>, then remove <var title="">candidate</var>
-     from <var title="">pending</var> (since <var title="">candidate</var> will be reached anyway as part of
-     processing <var title="">scope</var>).</li>
+   <li><p>Sort <var title="">results</var> in <a href=#tree-order>tree
+   order</a>.</li>
 
-     <li><p>Otherwise, if one of the other elements in <var title="">pending</var> is an ancestor element of <var title="">candidate</var>, and either <var title="">scope</var> is
-     null or that element also has <var title="">scope</var> as its
-     nearest ancestor element with an <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute specified, then
-     remove <var title="">candidate</var> from <var title="">pending</var> (since <var title="">candidate</var> will
-     be reached anyway as part of processing <var title="">scope</var>).</li>
+   <li><p>Return <var title="">results</var>.</li>
 
-    </ol></li>
+  </ol><p>To <dfn id=collect-all-the-elements-in-the-item>collect all the elements in the item</dfn> <var title="">root</var>, the user agent must run these steps:</p>
 
-   <li><p>Sort <var title="">pending</var> in <a href=#tree-order>tree
-   order</a>.</li>
+  <ol><li><p>Let <var title="">results</var> and <var title="">pending</var> be empty lists of elements.</li>
 
-   <li><p><i>Loop</i>: Pop the top element from <var title="">pending</var> and let <var title="">current</var> be that
+   <li><p>Add all the children elements of <var title="">root</var> to
+   <var title="">pending</var>.</li>
+
+   <li><p>If <var title="">root</var> has an <code title=attr-itemref><a href=#attr-itemref>itemref</a></code> attribute, <a href=#split-a-string-on-spaces title="split a
+   string on spaces">split the value of that <code title=attr-itemref>itemref</code> attribute on spaces</a>. For
+   each resulting token <var title="">ID</var>, if there is an element
+   in the <a href=#home-subtree>home subtree</a> of <var title="">root</var> with
+   the <a href=#concept-id title=concept-ID>ID</a> <var title="">ID</var>, then
+   add the first such element to <var title="">pending</var>.</li>
+
+   <li><p><i>Loop</i>: Remove an element from <var title="">pending</var> and let <var title="">current</var> be that
    element.</li>
 
-   <li><p>If <var title="">current</var> has an <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute, then append <var title="">current</var> to <var title="">properties</var>.</li>
+   <li><p>Add <var title="">current</var> to <var title="">results</var>.</li>
 
-   <li><p>If <var title="">current</var> does not have an <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute, and <var title="">current</var> is an element with child elements, then:
-   push all the child elements of <var title="">current</var> onto
-   <var title="">pending</var>, in <a href=#tree-order>tree order</a> (so the first
-   child of <var title="">current</var> will be the next element to be
-   popped from <var title="">pending</var>).</li>
+   <li><p>If <var title="">current</var> does not have an <code title=attr-itemscope><a href=#attr-itemscope>itemscope</a></code> attribute, then: add all
+   the child elements of <var title="">current</var> to <var title="">pending</var>.</li>
 
    <li><p><i>End of loop</i>: If <var title="">pending</var> is not
    empty, return to the step marked <i>loop</i>.</li>
 
-   <li><p>Return <var title="">properties</var>. That is the list of
-   <a href=#the-properties-of-an-item title="the properties of an item">properties of the
-   item</a> <var title="">root</var>. By definition, this list is
-   in <a href=#tree-order>tree order</a>.</li>
+   <li><p>Return <var title="">results</var>.</li>
 
-  </ol><p>A document must not contain any elements that have an <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute that would not be
+  </ol><p>An <a href=#concept-item title=concept-item>item</a> is a <dfn id=top-level-microdata-items title="top-level microdata items">top-level microdata item</dfn> if
+  its element does not have an <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute.</p>
+
+  <p>An <a href=#concept-item title=concept-item>item</a> is a <dfn id=used-microdata-items title="used
+  microdata items">used microdata item</dfn> if it is a <a href=#top-level-microdata-items title="top-level microdata items">top-level microdata item</a>,
+  or if it has an <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code>
+  attribute and would be <a href=#the-properties-of-an-item title="the properties of an item">found
+  to be the property</a> of an <a href=#concept-item title=concept-item>item</a> that is itself a <a href=#used-microdata-items title="used
+  microdata items">used microdata item</a>.</p>
+
+  <p>A document must not contain any <a href=#concept-item title=concept-item>items</a> that are not <a href=#used-microdata-items>used microdata
+  items</a>.</p>
+
+  <p>A document must not contain any elements that have an <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute that would not be
   found to be a property of any of the <a href=#concept-item title=concept-item>items</a> in that document were their <a href=#the-properties-of-an-item title="the properties of an item">properties</a> all to be
   determined.</p>
 
-  <p>An <a href=#concept-item title=concept-item>item</a> is a <dfn id=top-level-microdata-items title="top-level microdata items">top-level microdata item</dfn> if
-  its element does not have an <code title=attr-itemprop><a href=#names:-the-itemprop-attribute>itemprop</a></code> attribute.</p>
+  <p>A document must not contain any <a href=#concept-item title=concept-item>items</a> for which <a href=#crawl-the-properties title="crawl the
+  properties">crawling the properties</a> of the element, with an
+  empty list as the value of <var title="">memory</var>, fails.</p>
 
+  <p class=note>The algorithms in this section are especially
+  inefficient, in the interests of keeping them easy to
+  understand. Implementors are strongly encouraged to refactor and
+  optimise them in their user agents.</p>
 
-  <h4 id=examples-1><span class=secno>5.2.6 </span>Examples</h4>
+  <div class=example>
 
-  <p>Here is an example of some HTML using Microdata to express RDF
-  statements:</p>
+   <p>In this example, a single license statement is applied to two
+   works, using <code title=attr-itemref><a href=#attr-itemref>itemref</a></code> from the
+   items representing the works:</p>
 
-  <pre><dl itemscope
-    itemtype="http://purl.org/vocab/frbr/core#Work"
-    itemid="http://purl.oreilly.com/works/45U8QJGZSQKDH8N">
- <dt>Title</dt>
- <dd><cite itemprop="http://purl.org/dc/terms/title">Just a Geek</cite></dd>
- <dt>By</dt>
- <dd><span itemprop="http://purl.org/dc/terms/creator">Wil Wheaton</span></dd>
- <dt>Format</dt>
- <dd itemprop="http://purl.org/vocab/frbr/core#realization"
-     itemscope
-     itemtype="http://purl.org/vocab/frbr/core#Expression"
-     itemid="http://purl.oreilly.com/products/9780596007683.BOOK">
-  <link itemprop="http://purl.org/dc/terms/type" href="http://purl.oreilly.com/product-types/BOOK">
-  Print
- </dd>
- <dd itemprop="http://purl.org/vocab/frbr/core#realization"
-     itemscope
-     itemtype="http://purl.org/vocab/frbr/core#Expression"
-     itemid="http://purl.oreilly.com/products/9780596802189.EBOOK">
-  <link itemprop="http://purl.org/dc/terms/type" href="http://purl.oreilly.com/product-types/EBOOK">
-  Ebook
- </dd>
-</dl></pre>
+   <pre><!DOCTYPE HTML>
+<html>
+ <head>
+  <title>Photo gallery</title>
+ </head>
+ <body>
+  <h1>My photos</h1>
+  <figure itemscope itemtype="http://n.whatwg.org/work" itemref="licenses">
+   <img itemprop="work" src="images/house.jpeg" alt="A white house, boarded up, sits in a forest.">
+   <figcaption itemprop="title">The house I found.</figcaption>
+  </figure>
+  <figure itemscope itemtype="http://n.whatwg.org/work" itemref="licenses">
+   <img itemprop="work" src="images/mailbox.jpeg" alt="Outside the house is a mailbox. It has a leaflet inside.">
+   <figcaption itemprop="title">The mailbox.</figcaption>
+  </figure>
+  <footer>
+   <p id="licenses">All images licensed under the <a itemprop="license"
+   href="http://www.opensource.org/licenses/mit-license.php">MIT
+   license</a>.</p>
+  </footer>
+ </body>
+</html></pre>
 
-  <p>This is equivalent to the following Turtle:</p>
+   <p>The above results in two items with the type "<code title="">http://n.whatwg.org/work</code>", one with:</p>
 
-  <pre>@prefix dc: <http://purl.org/dc/terms/> .
- at prefix frbr: <http://purl.org/vocab/frbr/core#> .
+   <dl class=brief><dt>work
+    <dd><code title="">images/house.jpeg</code>
+    <dt>title
+    <dd>The house I found.
+    <dt>license
+    <dd><code title="">http://www.opensource.org/licenses/mit-license.php</code>
+   </dl><p>...and one with:</p>
 
-<http://purl.oreilly.com/works/45U8QJGZSQKDH8N> a frbr:Work ;
-     dc:creator "Wil Wheaton"@en ;
-     dc:title "Just a Geek"@en ;
-     frbr:realization <http://purl.oreilly.com/products/9780596007683.BOOK>,
-         <http://purl.oreilly.com/products/9780596802189.EBOOK> . 
+   <dl class=brief><dt>work
+    <dd><code title="">images/mailbox.jpeg</code>
+    <dt>title
+    <dd>The mailbox.
+    <dt>license
+    <dd><code title="">http://www.opensource.org/licenses/mit-license.php</code>
+   </dl></div>
 
-<http://purl.oreilly.com/products/9780596007683.BOOK> a frbr:Expression ;
-     dc:type <http://purl.oreilly.com/product-types/BOOK> . 
+  <div class=example>
 
-<http://purl.oreilly.com/products/9780596802189.EBOOK> a frbr:Expression ;
-     dc:type <http://purl.oreilly.com/product-types/EBOOK> .</pre>
+   <p>In the following invalid example, the items are all empty,
+   because the <code title=attr-itemref><a href=#attr-itemref>itemref</a></code> attribute on
+   the inner nested item indirectly references the same element twice
+   in the same item:</p>
 
+   <pre class=bad><!-- invalid example - do not copy -->
+<div itemscope>
+ <span itemprop="example">This is <em>not</em> a property of the
+ <code>div</code> element.</span>
+ <p itemprop="demo" itemscope itemref="test thing"> <!-- "thing" is a descendant
+                   of "test", which leads to it being included twice, which is invalid -->
+  <span itemprop="sample">This isn't part of anything either.</span>
+ </p>
+</div>
+<p id="test">
+ <span id="thing">(this element is referenced twice by the
+ <code>p</code> above, causing all the items that involve that
+ <code>itemref=""</code> attribute to act as if they had no
+ properties.)</span>
+</p></pre>
 
+  </div>
 
+
+
   <h3 id=microdata-dom-api><span class=secno>5.3 </span>Microdata DOM API</h3>
 
 
@@ -47490,7 +47539,7 @@
 
 
 
-  <h5 id=examples-2><span class=secno>5.4.1.2 </span>Examples</h5>
+  <h5 id=examples-1><span class=secno>5.4.1.2 </span>Examples</h5>
 
   <div class=example>
 
@@ -48301,7 +48350,7 @@
 
 
 
-  <h5 id=examples-3><span class=secno>5.4.2.2 </span>Examples</h5>
+  <h5 id=examples-2><span class=secno>5.4.2.2 </span>Examples</h5>
 
 <!-- get more from http://www.ietf.org/rfc/rfc2445.txt -->
 
@@ -48484,7 +48533,7 @@
 
 
 
-  <h5 id=examples-4><span class=secno>5.4.3.2 </span>Examples</h5>
+  <h5 id=examples-3><span class=secno>5.4.3.2 </span>Examples</h5>
 
   <div class=example>
 
@@ -48827,8 +48876,58 @@
 
    <li><p>Return <var title="">subject</var>.</li>
 
-  </ol><h4 id=atom><span class=secno>5.5.3 </span>Atom</h4>
+  </ol><h5 id=examples-4><span class=secno>5.5.2.1 </span>Examples</h5>
 
+  <p>Here is an example of some HTML using Microdata to express RDF
+  statements:</p>
+
+  <pre><dl itemscope
+    itemtype="http://purl.org/vocab/frbr/core#Work"
+    itemid="http://purl.oreilly.com/works/45U8QJGZSQKDH8N">
+ <dt>Title</dt>
+ <dd><cite itemprop="http://purl.org/dc/terms/title">Just a Geek</cite></dd>
+ <dt>By</dt>
+ <dd><span itemprop="http://purl.org/dc/terms/creator">Wil Wheaton</span></dd>
+ <dt>Format</dt>
+ <dd itemprop="http://purl.org/vocab/frbr/core#realization"
+     itemscope
+     itemtype="http://purl.org/vocab/frbr/core#Expression"
+     itemid="http://purl.oreilly.com/products/9780596007683.BOOK">
+  <link itemprop="http://purl.org/dc/terms/type" href="http://purl.oreilly.com/product-types/BOOK">
+  Print
+ </dd>
+ <dd itemprop="http://purl.org/vocab/frbr/core#realization"
+     itemscope
+     itemtype="http://purl.org/vocab/frbr/core#Expression"
+     itemid="http://purl.oreilly.com/products/9780596802189.EBOOK">
+  <link itemprop="http://purl.org/dc/terms/type" href="http://purl.oreilly.com/product-types/EBOOK">
+  Ebook
+ </dd>
+</dl></pre>
+
+  <p>This is equivalent to the following Turtle:</p>
+
+  <pre>@prefix dc: <http://purl.org/dc/terms/> .
+ at prefix frbr: <http://purl.org/vocab/frbr/core#> .
+
+<http://purl.oreilly.com/works/45U8QJGZSQKDH8N> a frbr:Work ;
+     dc:creator "Wil Wheaton"@en ;
+     dc:title "Just a Geek"@en ;
+     frbr:realization <http://purl.oreilly.com/products/9780596007683.BOOK>,
+         <http://purl.oreilly.com/products/9780596802189.EBOOK> . 
+
+<http://purl.oreilly.com/products/9780596007683.BOOK> a frbr:Expression ;
+     dc:type <http://purl.oreilly.com/product-types/BOOK> . 
+
+<http://purl.oreilly.com/products/9780596802189.EBOOK> a frbr:Expression ;
+     dc:type <http://purl.oreilly.com/product-types/EBOOK> .</pre>
+
+
+
+
+
+  <h4 id=atom><span class=secno>5.5.3 </span>Atom</h4>
+
   <p>Given a <code>Document</code> <var title="">source</var>, a user
   agent may run the following algorithm to <dfn id=extracting-atom title="extracting
   Atom">extract an Atom feed</dfn>. This is not the only algorithm

Modified: source
===================================================================
--- source	2010-01-18 11:08:58 UTC (rev 4609)
+++ source	2010-01-18 12:55:33 UTC (rev 4610)
@@ -50661,11 +50661,8 @@
   <p>The <code title="attr-itemref">itemref</code> attribute, if
   specified, must have a value that is an <span>unordered set of
   unique space-separated tokens</span> consisting of <span
-  title="concept-ID">IDs</span> of elements in the same document; for
-  each one, the element's nearest ancestor element with an <code
-  title="attr-itemscope">itemscope</code> attribute specified, if any,
-  must not be the element with the referencing <code
-  title="attr-itemref">itemref</code> attribute specified.</p>
+  title="concept-ID">IDs</span> of elements in the same <span>home
+  subtree</span>.</p>
 
   <p>The <code title="attr-itemref">itemref</code> attribute must not
   be specified on elements that do not have an <code
@@ -50872,102 +50869,116 @@
 
   <h4>Associating names with items</h4>
 
-  <p>To find <dfn>the properties of an item</dfn>, the user agent must
-  run the following steps:</p>
+  <p>To find <dfn>the properties of an item</dfn> defined by the
+  element <var title="">root</var>, the user agent must try to
+  <span>crawl the properties</span> of the element <var
+  title="">root</var>, with an empty list as the value of <var
+  title="">memory</var>: if this fails, then <span title="the
+  properties of an item">the properties of the item</span> defined by
+  the element <var title="">root</var> is an empty list; otherwise, it
+  is the returned list.</p>
 
+  <p>To <dfn>crawl the properties</dfn> of an element <var
+  title="">root</var> with a list <var title="">memory</var>, the user
+  agent must run the following steps:</p>
+
   <ol>
 
-   <li><p>Let <var title="">root</var> be the element with the <code
-   title="attr-itemscope">itemscope</code> attribute.</p></li>
+   <li><p>If <var title="">root</var> is in <var
+   title="">memory</var>, then the algorithm fails; abort these
+   steps.</p></li>
 
-   <li><p>Let <var title="">pending</var> be a stack of elements
-   initially containing the child elements of <var
-   title="">root</var>, if any. This list will be the one that holds
-   the elements that still need to be crawled.</p></li>
+   <li><p><span>Collect all the elements in the item</span> <var
+   title="">root</var>, and let <var title="">results</var> be the
+   result.</p></li>
 
-   <li><p>Let <var title="">properties</var> be an empty list of
-   elements. This list will be the result of the algorithm: a list of
-   elements with properties that apply to <var
-   title="">root</var>.</p></li>
+   <li><p>If <var title="">root</var> is in <var
+   title="">results</var>, then the algorithm fails; abort these
+   steps.</p></li>
 
-   <li><p>If <var title="">root</var> has an <code
-   title="attr-itemref">itemref</code> attribute, <span title="split a
-   string on spaces">split the value of that <code
-   title="attr-itemref">itemref</code> attribute on spaces</span>. For
-   each resulting token, <var title="">ID</var>, if there is an
-   element in the document with the <span title="concept-ID">ID</span>
-   <var title="">ID</var>, then push the first such element onto <var
-   title="">pending</var>.</p></li>
+   <li><p>If any elements are listed in <var title="">results</var>
+   more than once, then the algorithm fails; abort these
+   steps.</p></li>
 
-   <li>
+   <li><p>Remove any elements from <var title="">results</var> that do
+   not have an <code title="attr-itemprop">itemprop</code> attribute
+   specified.</p></li>
 
-    <p>For each element <var title="">candidate</var> in <var
-    title="">pending</var>, run the following substeps:</p>
+   <li><p>Let <var title="">new memory</var> be a new list consisting
+   of the old list <var title="">memory</var> with the addition of
+   <var title="">root</var>.</p></li>
 
-    <ol>
+   <li><p>For each element in <var title="">results</var> that has an
+   <code title="attr-itemscope">itemscope</code> attribute specified,
+   <span>crawl the properties</span> of the element, with <var
+   title="">new memory</var> as the memory. If this fails, then this
+   instance of the algorithm fails as well; abort these steps. (If it
+   succeeds, the return value is discarded.)</p></li>
 
-     <li><p>Let <var title="">scope</var> be <var
-     title="">candidate</var>'s nearest ancestor element with an <code
-     title="attr-itemscope">itemscope</code> attribute specified, if
-     any, or null otherwise.</p></li>
+   <li><p>Sort <var title="">results</var> in <span>tree
+   order</span>.</p></li>
 
-     <li><p>If one of the other elements in <var title="">pending</var>
-     is also <var title="">candidate</var>, then remove <var
-     title="">candidate</var> from <var title="">pending</var>
-     (i.e. remove duplicates).</p></li>
+   <li><p>Return <var title="">results</var>.</p></li>
 
-     <li><p>Otherwise, if one of the other elements in <var
-     title="">pending</var> is an ancestor element of <var
-     title="">candidate</var>, and that element is <var
-     title="">scope</var>, then remove <var title="">candidate</var>
-     from <var title="">pending</var> (since <var
-     title="">candidate</var> will be reached anyway as part of
-     processing <var title="">scope</var>).</p></li>
+  </ol>
 
-     <li><p>Otherwise, if one of the other elements in <var
-     title="">pending</var> is an ancestor element of <var
-     title="">candidate</var>, and either <var title="">scope</var> is
-     null or that element also has <var title="">scope</var> as its
-     nearest ancestor element with an <code
-     title="attr-itemscope">itemscope</code> attribute specified, then
-     remove <var title="">candidate</var> from <var
-     title="">pending</var> (since <var title="">candidate</var> will
-     be reached anyway as part of processing <var
-     title="">scope</var>).</p></li>
+  <p>To <dfn>collect all the elements in the item</dfn> <var
+  title="">root</var>, the user agent must run these steps:</p>
 
-    </ol>
+  <ol>
 
-   </li>
+   <li><p>Let <var title="">results</var> and <var
+   title="">pending</var> be empty lists of elements.</p></li>
 
-   <li><p>Sort <var title="">pending</var> in <span>tree
-   order</span>.</p></li>
+   <li><p>Add all the children elements of <var title="">root</var> to
+   <var title="">pending</var>.</p></li>
 
-   <li><p><i>Loop</i>: Pop the top element from <var
+   <li><p>If <var title="">root</var> has an <code
+   title="attr-itemref">itemref</code> attribute, <span title="split a
+   string on spaces">split the value of that <code
+   title="attr-itemref">itemref</code> attribute on spaces</span>. For
+   each resulting token <var title="">ID</var>, if there is an element
+   in the <span>home subtree</span> of <var title="">root</var> with
+   the <span title="concept-ID">ID</span> <var title="">ID</var>, then
+   add the first such element to <var title="">pending</var>.</p></li>
+
+   <li><p><i>Loop</i>: Remove an element from <var
    title="">pending</var> and let <var title="">current</var> be that
    element.</p></li>
 
-   <li><p>If <var title="">current</var> has an <code
-   title="attr-itemprop">itemprop</code> attribute, then append <var
-   title="">current</var> to <var title="">properties</var>.</p></li>
+   <li><p>Add <var title="">current</var> to <var
+   title="">results</var>.</p></li>
 
    <li><p>If <var title="">current</var> does not have an <code
-   title="attr-itemscope">itemscope</code> attribute, and <var
-   title="">current</var> is an element with child elements, then:
-   push all the child elements of <var title="">current</var> onto
-   <var title="">pending</var>, in <span>tree order</span> (so the first
-   child of <var title="">current</var> will be the next element to be
-   popped from <var title="">pending</var>).</p></li>
+   title="attr-itemscope">itemscope</code> attribute, then: add all
+   the child elements of <var title="">current</var> to <var
+   title="">pending</var>.</p></li>
 
    <li><p><i>End of loop</i>: If <var title="">pending</var> is not
    empty, return to the step marked <i>loop</i>.</p></li>
 
-   <li><p>Return <var title="">properties</var>. That is the list of
-   <span title="the properties of an item">properties of the
-   item</span> <var title="">root</var>. By definition, this list is
-   in <span>tree order</span>.</p></li>
+   <li><p>Return <var title="">results</var>.</p></li>
 
   </ol>
 
+  <p>An <span title="concept-item">item</span> is a <dfn
+  title="top-level microdata items">top-level microdata item</dfn> if
+  its element does not have an <code
+  title="attr-itemprop">itemprop</code> attribute.</p>
+
+  <p>An <span title="concept-item">item</span> is a <dfn title="used
+  microdata items">used microdata item</dfn> if it is a <span
+  title="top-level microdata items">top-level microdata item</span>,
+  or if it has an <code title="attr-itemprop">itemprop</code>
+  attribute and would be <span title="the properties of an item">found
+  to be the property</span> of an <span
+  title="concept-item">item</span> that is itself a <span title="used
+  microdata items">used microdata item</span>.</p>
+
+  <p>A document must not contain any <span
+  title="concept-item">items</span> that are not <span>used microdata
+  items</span>.</p>
+
   <p>A document must not contain any elements that have an <code
   title="attr-itemprop">itemprop</code> attribute that would not be
   found to be a property of any of the <span
@@ -50975,60 +50986,97 @@
   title="the properties of an item">properties</span> all to be
   determined.</p>
 
-  <p>An <span title="concept-item">item</span> is a <dfn
-  title="top-level microdata items">top-level microdata item</dfn> if
-  its element does not have an <code
-  title="attr-itemprop">itemprop</code> attribute.</p>
+  <p>A document must not contain any <span
+  title="concept-item">items</span> for which <span title="crawl the
+  properties">crawling the properties</span> of the element, with an
+  empty list as the value of <var title="">memory</var>, fails.</p>
 
+  <p class="note">The algorithms in this section are especially
+  inefficient, in the interests of keeping them easy to
+  understand. Implementors are strongly encouraged to refactor and
+  optimise them in their user agents.</p>
 
-  <h4>Examples</h4>
+  <div class="example">
 
-  <p>Here is an example of some HTML using Microdata to express RDF
-  statements:</p>
+   <p>In this example, a single license statement is applied to two
+   works, using <code title="attr-itemref">itemref</code> from the
+   items representing the works:</p>
 
-  <pre><dl itemscope
-    itemtype="http://purl.org/vocab/frbr/core#Work"
-    itemid="http://purl.oreilly.com/works/45U8QJGZSQKDH8N">
- <dt>Title</dt>
- <dd><cite itemprop="http://purl.org/dc/terms/title">Just a Geek</cite></dd>
- <dt>By</dt>
- <dd><span itemprop="http://purl.org/dc/terms/creator">Wil Wheaton</span></dd>
- <dt>Format</dt>
- <dd itemprop="http://purl.org/vocab/frbr/core#realization"
-     itemscope
-     itemtype="http://purl.org/vocab/frbr/core#Expression"
-     itemid="http://purl.oreilly.com/products/9780596007683.BOOK">
-  <link itemprop="http://purl.org/dc/terms/type" href="http://purl.oreilly.com/product-types/BOOK">
-  Print
- </dd>
- <dd itemprop="http://purl.org/vocab/frbr/core#realization"
-     itemscope
-     itemtype="http://purl.org/vocab/frbr/core#Expression"
-     itemid="http://purl.oreilly.com/products/9780596802189.EBOOK">
-  <link itemprop="http://purl.org/dc/terms/type" href="http://purl.oreilly.com/product-types/EBOOK">
-  Ebook
- </dd>
-</dl></pre>
+   <pre><!DOCTYPE HTML>
+<html>
+ <head>
+  <title>Photo gallery</title>
+ </head>
+ <body>
+  <h1>My photos</h1>
+  <figure itemscope itemtype="http://n.whatwg.org/work" itemref="licenses">
+   <img itemprop="work" src="images/house.jpeg" alt="A white house, boarded up, sits in a forest.">
+   <figcaption itemprop="title">The house I found.</figcaption>
+  </figure>
+  <figure itemscope itemtype="http://n.whatwg.org/work" itemref="licenses">
+   <img itemprop="work" src="images/mailbox.jpeg" alt="Outside the house is a mailbox. It has a leaflet inside.">
+   <figcaption itemprop="title">The mailbox.</figcaption>
+  </figure>
+  <footer>
+   <p id="licenses">All images licensed under the <a itemprop="license"
+   href="http://www.opensource.org/licenses/mit-license.php">MIT
+   license</a>.</p>
+  </footer>
+ </body>
+</html></pre>
 
-  <p>This is equivalent to the following Turtle:</p>
+   <p>The above results in two items with the type "<code
+   title="">http://n.whatwg.org/work</code>", one with:</p>
 
-  <pre>@prefix dc: <http://purl.org/dc/terms/> .
- at prefix frbr: <http://purl.org/vocab/frbr/core#> .
+   <dl class="brief">
+    <dt>work
+    <dd><code title="">images/house.jpeg</code>
+    <dt>title
+    <dd>The house I found.
+    <dt>license
+    <dd><code title="">http://www.opensource.org/licenses/mit-license.php</code>
+   </dl>
 
-<http://purl.oreilly.com/works/45U8QJGZSQKDH8N> a frbr:Work ;
-     dc:creator "Wil Wheaton"@en ;
-     dc:title "Just a Geek"@en ;
-     frbr:realization <http://purl.oreilly.com/products/9780596007683.BOOK>,
-         <http://purl.oreilly.com/products/9780596802189.EBOOK> . 
+   <p>...and one with:</p>
 
-<http://purl.oreilly.com/products/9780596007683.BOOK> a frbr:Expression ;
-     dc:type <http://purl.oreilly.com/product-types/BOOK> . 
+   <dl class="brief">
+    <dt>work
+    <dd><code title="">images/mailbox.jpeg</code>
+    <dt>title
+    <dd>The mailbox.
+    <dt>license
+    <dd><code title="">http://www.opensource.org/licenses/mit-license.php</code>
+   </dl>
 
-<http://purl.oreilly.com/products/9780596802189.EBOOK> a frbr:Expression ;
-     dc:type <http://purl.oreilly.com/product-types/EBOOK> .</pre>
+  </div>
 
+  <div class="example">
 
+   <p>In the following invalid example, the items are all empty,
+   because the <code title="attr-itemref">itemref</code> attribute on
+   the inner nested item indirectly references the same element twice
+   in the same item:</p>
 
+   <pre class="bad"><!-- invalid example - do not copy -->
+<div itemscope>
+ <span itemprop="example">This is <em>not</em> a property of the
+ <code>div</code> element.</span>
+ <p itemprop="demo" itemscope itemref="test thing"> <!-- "thing" is a descendant
+                   of "test", which leads to it being included twice, which is invalid -->
+  <span itemprop="sample">This isn't part of anything either.</span>
+ </p>
+</div>
+<p id="test">
+ <span id="thing">(this element is referenced twice by the
+ <code>p</code> above, causing all the items that involve that
+ <code>itemref=""</code> attribute to act as if they had no
+ properties.)</span>
+</p></pre>
+
+  </div>
+
+
+
   <h3>Microdata DOM API</h3>
 
 <!--END html--><!--END complete-->
@@ -55047,8 +55095,57 @@
 
   </ol>
 
+
+  <h5>Examples</h5>
+
+  <p>Here is an example of some HTML using Microdata to express RDF
+  statements:</p>
+
+  <pre><dl itemscope
+    itemtype="http://purl.org/vocab/frbr/core#Work"
+    itemid="http://purl.oreilly.com/works/45U8QJGZSQKDH8N">
+ <dt>Title</dt>
+ <dd><cite itemprop="http://purl.org/dc/terms/title">Just a Geek</cite></dd>
+ <dt>By</dt>
+ <dd><span itemprop="http://purl.org/dc/terms/creator">Wil Wheaton</span></dd>
+ <dt>Format</dt>
+ <dd itemprop="http://purl.org/vocab/frbr/core#realization"
+     itemscope
+     itemtype="http://purl.org/vocab/frbr/core#Expression"
+     itemid="http://purl.oreilly.com/products/9780596007683.BOOK">
+  <link itemprop="http://purl.org/dc/terms/type" href="http://purl.oreilly.com/product-types/BOOK">
+  Print
+ </dd>
+ <dd itemprop="http://purl.org/vocab/frbr/core#realization"
+     itemscope
+     itemtype="http://purl.org/vocab/frbr/core#Expression"
+     itemid="http://purl.oreilly.com/products/9780596802189.EBOOK">
+  <link itemprop="http://purl.org/dc/terms/type" href="http://purl.oreilly.com/product-types/EBOOK">
+  Ebook
+ </dd>
+</dl></pre>
+
+  <p>This is equivalent to the following Turtle:</p>
+
+  <pre>@prefix dc: <http://purl.org/dc/terms/> .
+ at prefix frbr: <http://purl.org/vocab/frbr/core#> .
+
+<http://purl.oreilly.com/works/45U8QJGZSQKDH8N> a frbr:Work ;
+     dc:creator "Wil Wheaton"@en ;
+     dc:title "Just a Geek"@en ;
+     frbr:realization <http://purl.oreilly.com/products/9780596007683.BOOK>,
+         <http://purl.oreilly.com/products/9780596802189.EBOOK> . 
+
+<http://purl.oreilly.com/products/9780596007683.BOOK> a frbr:Expression ;
+     dc:type <http://purl.oreilly.com/product-types/BOOK> . 
+
+<http://purl.oreilly.com/products/9780596802189.EBOOK> a frbr:Expression ;
+     dc:type <http://purl.oreilly.com/product-types/EBOOK> .</pre>
+
 <!--END microdata--><!--START w3c-html-->
 
+
+
   <h4>Atom</h4>
 
   <p>Given a <code>Document</code> <var title="">source</var>, a user




More information about the Commit-Watchers mailing list