Simplify "Embedding JSON-LD in HTML Documents"
authorMarkus Lanthaler <mark_lanthaler@gmx.net>
Wed, 20 Mar 2013 13:21:04 +0100
changeset 1457 78975e50f155
parent 1456 86c2999dd94a
child 1458 a30424df0a18
Simplify "Embedding JSON-LD in HTML Documents"

@gkellogg, was there a reason why you choose such a complex example? If not, I think this is much simpler and illustrates the mechanisms just as well.

I've also removed the part which says "For text/html, text inside of the script tags does not need to be escaped." Which is wrong, see http://www.w3.org/TR/html5/scripting-1.html#restrictions-for-contents-of-script-elements

This addresses #231.
spec/latest/json-ld-syntax/index.html
--- a/spec/latest/json-ld-syntax/index.html	Wed Mar 20 12:10:52 2013 +0100
+++ b/spec/latest/json-ld-syntax/index.html	Wed Mar 20 13:21:04 2013 +0100
@@ -1461,40 +1461,27 @@
 <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>
+    This way, JSON-LD content can be easily embedded in HTML by placing
+    it in a script element with the <code>type</code> attribute set to
+    <code>application/ld+json</code>.</p>
 
   <pre class="example" data-transform="updateExample"
        title="Embedding JSON-LD in HTML">
   <!--
-  <script type="application/ld+json">
+  ****<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"
-    }]
+    "@context": "http://json-ld.org/contexts/person.jsonld",
+    "@id": "http://dbpedia.org/resource/John_Lennon",
+    "name": "John Lennon",
+    "born": "1940-10-09",
+    "spouse": "http://dbpedia.org/resource/Cynthia_Lennon"
   }
-  </script>
+  ****</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>Depending on how the HTML document is served, certain strings may need
+    to be escaped.</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