diff --git a/index.html b/index.html index 0873c33..fb99d66 100644 --- a/index.html +++ b/index.html @@ -1238,6 +1238,192 @@
Given a list of nodes nodes in a Document
, a user agent must
+ run the following algorithm to extract the Microdata from those nodes into a JSON-LD:
Let result be an empty object.
Let items be an empty array.
For each node in nodes, check if the element is a + top-level Microdata item, and if it is then get the object for that element and add it to items.
Add an entry to result called "items
" whose
+ value is the array items.
Add an entry to result called "@context
" whose value is the following object:
{ "@vocab" : "" }
Return the result of serializing result to JSON. [[JSON]]
This algorithm returns an object with a single property that is an array, instead + of just returning an array, so that it is possible to extend the algorithm in the future if + necessary.
+ +When the user agent is to get the object for an item item, + potentially together with a list of elements memory, it must run the following + substeps:
+ +Let result be an empty object.
If no memory was passed to the algorithm, let memory be an empty list.
Add item to memory.
If the item has any item types, add an entry to result
+ called "@type
" whose value is an array listing the
+ item types of item, in the order they were specified on the
+ itemtype
attribute.
If the item has a global identifier, add an entry to
+ result called "@id
" whose value is the global
+ identifier of item.
Let properties be an empty object.
For each element element that has one or more property names + and is one of the properties of the item + item, in the order those elements are given by the algorithm that returns + the properties of an item, run the following substeps:
+ +Let value be the + property value of element.
If value is an item, then:
+ If value is in memory, then let value be
+ the string "ERROR
". Otherwise, get the object for
+ value, passing a copy of memory, and then replace value
+ with the object returned from those steps.
For each name name in element's + property names, run the following substeps:
+ +If there is no entry named name in result, + then add an entry named name to result whose + value is an empty array.
Append value to the entry named name in result.
Return result.
For example, take this markup:
+ +<!DOCTYPE HTML> +<title>My Blog</title> +<article itemscope itemtype="https://schema.org/BlogPosting"> + <header> + <h1 itemprop="headline">Progress report</h1> + <p><time itemprop="datePublished" datetime="2013-08-29">today</time></p> + <link itemprop="url" href="?comments=0"> + </header> + <p>All in all, he's doing well with his swim lessons. The biggest thing was he had trouble + putting his head in, but we got it down.</p> + <section> + <h1>Comments</h1> + <article itemprop="comment" itemscope itemtype="https://schema.org/Comment" id="c1"> + <link itemprop="url" href="#c1"> + <footer> + <p>Posted by: <span itemprop="creator" itemscope itemtype="https://schema.org/Person"> + <span itemprop="name">Greg</span> + </span></p> + <p><time itemprop="dateCreated" datetime="2013-08-29">15 minutes ago</time></p> + </footer> + <p>Ha!</p> + </article> + <article itemprop="comment" itemscope itemtype="https://schema.org/Comment" id="c2"> + <link itemprop="url" href="#c2"> + <footer> + <p>Posted by: <span itemprop="creator" itemscope itemtype="https://schema.org/Person"> + <span itemprop="name">Charlotte</span> + </span></p> + <p><time itemprop="dateCreated" datetime="2013-08-29">5 minutes ago</time></p> + </footer> + <p>When you say "we got it down"...</p> + </article> + </section> +</article>+ +
It would be turned into the following JSON by the algorithm above (supposing that the page's
+ URL was http://blog.example.com/progress-report
):
{ + "items": [ + { + "type": [ "https://schema.org/BlogPosting" ], + "properties": { + "headline": [ "Progress report" ], + "datePublished": [ "2013-08-29" ], + "url": [ "http://blog.example.com/progress-report?comments=0" ], + "comment": [ + { + "type": [ "https://schema.org/Comment" ], + "properties": { + "url": [ "http://blog.example.com/progress-report#c1" ], + "creator": [ + { + "type": [ "https://schema.org/Person" ], + "properties": { + "name": [ "Greg" ] + } + } + ], + "dateCreated": [ "2013-08-29" ] + } + }, + { + "type": [ "https://schema.org/Comment" ], + "properties": { + "url": [ "http://blog.example.com/progress-report#c2" ], + "creator": [ + { + "type": [ "https://schema.org/Person" ], + "properties": { + "name": [ "Charlotte" ] + } + } + ], + "dateCreated": [ "2013-08-29" ] + } + } + ] + } + } + ] +}+ +