From 42f0364c5cc2a54efced8dfeb8b246363dda07d6 Mon Sep 17 00:00:00 2001
From: chaals Given a list of nodes nodes in a 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 " Add an entry to result called " 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 " If the item has a global identifier, add an entry to
+ result called " 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 " 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: It would be turned into the following JSON by the algorithm above (supposing that the page's
+ URL was Associating names with items
Converting Microdata to other formats
+JSON-LD
+
+ Document
, a user agent must
+ run the following algorithm to extract the Microdata from those nodes into a JSON-LD:
+
+
+
+ items
" whose
+ value is the array items.@context
" whose value is the following object:{ "@vocab" : "" }
+
+
+
+ @type
" whose value is an array listing the
+ item types of item, in the order they were specified on the
+ itemtype
attribute.@id
" whose value is the global
+ identifier of item.
+
+
+
+ ERROR
". Otherwise, get the object for
+ value, passing a copy of memory, and then replace value
+ with the object returned from those steps.
+
+
+
+ <!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>
+
+ 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" ]
+ }
+ }
+ ]
+ }
+ }
+ ]
+}
+
+ JSON
@@ -1653,6 +1839,7 @@ Changes
and the second Working Draft: