Add JSON-LD in HTML section, per resolution in issue #231
authorGregg Kellogg <gregg@kellogg-assoc.com>
Tue, 19 Mar 2013 12:29:00 -0700
changeset 1453 a6b19439b5c6
parent 1452 4b8ba03510f9
child 1454 1683f2d770a6
Add JSON-LD in HTML section, per resolution in issue #231
spec/latest/json-ld-syntax/index.html
--- a/spec/latest/json-ld-syntax/index.html	Thu Mar 14 18:24:28 2013 +0100
+++ b/spec/latest/json-ld-syntax/index.html	Tue Mar 19 12:29:00 2013 -0700
@@ -585,7 +585,7 @@
     <code>http://example.com/about/</code>, the <tref>relative IRI</tref>
     <code>../</code> would expand to <code>http://example.com/</code> (for more
     information on where  <tref title="relative IRI">relative IRIs</tref> can be
-    used, please refer to appendix <a href="#json-ld-grammar"></a>).
+    used, please refer to appendix <a href="#json-ld-grammar"></a>).</p>
 
   <pre class="example" data-transform="updateExample"
        title="IRIs can be relative">
@@ -854,7 +854,7 @@
     the vocabulary <tref>IRI</tref>, a <tref>term</tref> can be explicitly set
     to <tref>null</tref> in the <tref>context</tref>. For instance, in the
     example below the <code>databaseId</code> member would not expand to an
-    <tref>IRI</tref>.</p></p>
+    <tref>IRI</tref>.</p>
 
   <pre class="example" data-transform="updateExample"
        title="Using the null keyword to ignore data">
@@ -1055,11 +1055,11 @@
 {
 ...
   "@id": "http://example.org/posts#TripToWestVirginia",
-  ****"@type": "http://schema.org/BlogPosting"****,   <--- This is a node type
+  ****"@type": "http://schema.org/BlogPosting"****,   <- This is a node type
   "modified":
   {
     "@value": "2010-05-29T14:17:39+02:00",
-    ****"@type": "http://www.w3.org/2001/XMLSchema#dateTime"**** <--- This is a value type
+    ****"@type": "http://www.w3.org/2001/XMLSchema#dateTime"**** <- This is a value type
   }
 ...
 }
@@ -1125,7 +1125,7 @@
   <tref title="active context">active context's</tref> vocabulary mapping, if present, or by interpreting it
   as <tref>relative IRI</tref>. Values coerced to <code>@id</code> in contrast are expanded as
   <tref>compact IRI</tref> or <tref>absolute IRI</tref> if a colon is present; otherwise, they are interpreted
-  as <tref>relative IRI</tref>.
+  as <tref>relative IRI</tref>.</p>
 
 <p><tref title="term">Terms</tref> or <tref title="compact iri">compact IRIs</tref> used as the value of a
   <code>@type</code> key may be defined within the same context. This means that one may specify a
@@ -1133,7 +1133,7 @@
   context definition.</p>
 
 <p>The example below demonstrates how a JSON-LD author can coerce values to
-<tref title="typed value">typed values</tref> and <tref="IRI">IRIs</tref>.</p>
+<tref title="typed value">typed values</tref> and <tref title="IRI">IRIs</tref>.</p>
 
 <pre class="example" data-transform="updateExample"
      title="Expanded term definition with types">
@@ -1459,6 +1459,57 @@
 </section>
 
 <section>
+  <h2>Embedding JSON-LD in HTML Documents</h2>
+  <p>HTML script tags can be used to embed blocks of data in documents.
+    JSON-LD can be easily embedded in HTML this way.</p>
+
+  <pre class="example" data-transform="updateExample"
+       title="Embedding JSON-LD in HTML">
+  <!--
+  <script type="application/ld+json">
+  {
+    "@context": {
+      "@vocab": "http://purl.org/vocab/frbr/core#",
+      "@language": "en",
+      "dc": "http://purl.org/dc/terms/",
+    },
+    "@id": "http://books.example.com/works/45U8QJGZSQKDH8N",
+    "@type": "Work",
+    "dc:creator": "Wil Wheaton",
+    "dc:title": "Just a Geek",
+    "realization": [{
+      "@id": "http://books.example.com/products/9780596007683.BOOK",
+      "@type": "Expression";
+      "dc:type": "http://books.example.com/product-types/BOOK"
+    }, {
+      "@id": "http://books.example.com/products/9780596802189.EBOOK"
+      "dc:type": "http://books.example.com/product-types/EBOOK"
+    }]
+  }
+  </script>
+  -->
+  </pre>
+
+  <p>JSON-LD content should be placed in a script element with the <code>@type</code>
+    attribute set to <code>application/ld+json</code>. For <code>text/html</code>,
+    text inside of the script tags does not need to be escaped. The
+    character encoding of the embedded JSON-LD fragment will match the HTML
+    documents encoding.</p>
+
+  <p>If a processor extracts the JSON-LD content into RDF, it should expand the
+    JSON-LD fragment into an RDF dataset using the algorithm defined in
+    <cite><a href="../json-ld-api/#convert-to-rdf-algorithm">
+      JSON-LD-API Convert to RDF Algorithm
+    </a></cite>
+    [[JSON-LD-API]]. If the HTML
+    file contains multiple JSON-LD <code>script</code> tags, or other RDF statements are
+    extracted, the result is the RDF merge of the datasets.</p>
+
+  <p>Other processors implementing this mechanism may choose to
+    return the expanded JSON-LD output.</p>
+</section>
+
+<section>
   <h2>String Internationalization</h2>
 
   <p>At times, it is important to annotate a <tref>string</tref>
@@ -2673,7 +2724,7 @@
     is being processed. This means, e.g., that properties which are not mapped to an
     <tref>IRI</tref> or <tref>blank node</tref> will be ignored.</p>
 
-  <p style="text-align: center"><img src="linked-data-graph.png" title="An illustration of JSON-LD's data model"></p>
+  <p style="text-align: center"><img src="linked-data-graph.png" title="An illustration of JSON-LD's data model"/></p>
   <p style="text-align: center">Figure&nbsp;1: An illustration of JSON-LD's data model.</p>
 </section>
 
@@ -2736,7 +2787,7 @@
         or <code>@set</code> keywords, and</li>
       <li>it is not the top-most <tref>JSON object</tref> in the JSON-LD document
         consisting of no other members than <code>@graph</code> and
-        <code>@context</code>.
+        <code>@context</code>.</li>
     </ul>
 
     <p>The <tref title="property">properties</tref> of a <tref>node</tref> in
@@ -2961,7 +3012,7 @@
     keys MUST either be <tref title="term">terms</tref>,
     <tref title="compact IRI">compact IRIs</tref>, <tref title="absolute IRI">absolute IRIs</tref>,
     or the <tref title="keyword">keywords</tref> <code>@language</code>, <code>@base</code>,
-    and <code>@vocab</code>.
+    and <code>@vocab</code>.</p>
 
   <p>If the <tref>context definition</tref> has a <code>@language</code> key,
     its value MUST have the lexical form described in [[!BCP47]] or be <tref>null</tref>.</p>