Support documents with a +json media type
authorMarkus Lanthaler <mark_lanthaler@gmx.net>
Tue, 23 Jul 2013 21:26:50 +0200
changeset 1814 fe934fe8462f
parent 1813 7060454f4abf
child 1815 05e86726360c
Support documents with a +json media type

This addresses #261.
spec/latest/json-ld-api/index.html
spec/latest/json-ld/index.html
spec/latest/respec-w3c-extensions.js
--- a/spec/latest/json-ld-api/index.html	Tue Jul 23 21:17:06 2013 +0200
+++ b/spec/latest/json-ld-api/index.html	Tue Jul 23 21:26:50 2013 +0200
@@ -203,10 +203,12 @@
     <li>Clarify that blank node identifier are supported as value of <code>@vocab</code></li>
     <li>When generating RDF, exclude <tref title="rdf triple">triples</tref> containing a
       <tref>blank node</tref> <tref title="rdf predicate">predicate</tref>, unless the
-      <i>produce generalized RDF</i> flag is set.</li>
+      <i>produce generalized RDF</i> flag is set</li>
     <li>Update reference to DOM Promises (have been called DOM Futures)</li>
     <li>Fix bug in <a href="#convert-from-rdf-algorithm">Convert from RDF algorithm</a> to
-      handle lists correctly.</li>
+      handle lists correctly</li>
+    <li>Support processing of documents with a <code>+json</code> media type as defined in
+      [[RFC6839]]</li>
   </ul>
 </section>
 
@@ -3829,9 +3831,10 @@
             following steps are then executed asynchronously.</li>
           <li>If the passed <i>input</i> is a <span class="idlParamType">DOMString</span>
             representing the <tref>IRI</tref> of a remote document, dereference it.
-            If the retrieved document has a content type different than
-            <code>application/ld+json</code> or <code>application/json</code> or
-            if the document cannot be parsed as JSON, reject the <i>promise</i> passing an
+            If the retrieved document's content type is neither <code>application/json</code>,
+            nor <code>application/ld+json</code>, nor any other media type using a
+            <code>+json</code> suffix as defined in [[RFC6839]]
+            or if the document cannot be parsed as JSON, reject the <i>promise</i> passing an
             <code class="error"><a href="#idl-def-JsonLdErrorCode.loading-document-failed">loading document failed</a></code>
             error.</li>
           <li>Initialize a new empty <tref>active context</tref>. The <tref>base IRI</tref>
@@ -3845,12 +3848,14 @@
             <a href="#context-processing-algorithm">Context Processing algorithm</a>, passing the
             <code class="idlMemberName"><a href="#widl-JsonLdOptions-expandContext">expandContext</a></code>
             as <tref>local context</tref>.</li>
-          <li>If the <i>input</i> has been retrieved and the response has a content type
-            <code>application/json</code> and an HTTP Link Header [[!RFC5988]] using the
-            <code>http://www.w3.org/ns/json-ld#context</code> link relation, update the
-            <tref>active context</tref> using the
+          <li>If the <i>input</i> has been retrieved, the response has an HTTP Link Header [[!RFC5988]]
+            using the <code>http://www.w3.org/ns/json-ld#context</code> link relation
+            and a content type of <code>application/json</code> or any media type
+            with a <code>+json</code> suffix as defined in [[RFC6839]] except
+            <code>application/ld+json</code>, update the <tref>active context</tref> using the
             <a href="#context-processing-algorithm">Context Processing algorithm</a>, passing the
-            context referenced in the HTTP Link Header as <tref>local context</tref>.</li>
+            context referenced in the HTTP Link Header as <tref>local context</tref>. The
+            HTTP Link Header is ignored for documents served as <code>application/ld+json</code>.</li>
           <li>Set <i>expanded</i> to the result of using the
             <a href="#expansion-algorithm">Expansion algorithm</a>, passing the
             <tref>active context</tref> and <i>input</i> as <i>element</i>.</li>
@@ -3886,9 +3891,10 @@
           <li>Create a new <tref>Promise</tref> <i>promise</i> and return it. The
             following steps are then executed asynchronously.</li>
           <li>If the passed <i>input</i> is a <span class="idlParamType">DOMString</span>
-            representing the <tref>IRI</tref> of a remote document, dereference it. If the retrieved document has a content type
-            different than <code>application/ld+json</code> or <code>application/json</code> or
-            if the document cannot be parsed as JSON, reject the <i>promise</i> passing an
+            representing the <tref>IRI</tref> of a remote document, dereference it.
+            If the retrieved document's content type is neither <code>application/json</code>,
+            nor <code>application/ld+json</code>, nor any other media type using a
+            <code>+json</code> suffix as defined in [[RFC6839]], reject the <i>promise</i> passing an
             <code class="error"><a href="#idl-def-JsonLdErrorCode.loading-document-failed">loading document failed</a></code>
             error.</li>
           <li>Initialize a new empty <tref>active context</tref>. The <tref>base IRI</tref>
@@ -3902,12 +3908,14 @@
             <a href="#context-processing-algorithm">Context Processing algorithm</a>, passing the
             <code class="idlMemberName"><a href="#widl-JsonLdOptions-expandContext">expandContext</a></code>
             as <tref>local context</tref>.</li>
-          <li>If the <i>input</i> has been retrieved and the response has a content type
-            <code>application/json</code> and an HTTP Link Header [[!RFC5988]] using the
-            <code>http://www.w3.org/ns/json-ld#context</code> link relation, update the
-            <tref>active context</tref> using the
+          <li>If the <i>input</i> has been retrieved, the response has an HTTP Link Header [[!RFC5988]]
+            using the <code>http://www.w3.org/ns/json-ld#context</code> link relation
+            and a content type of <code>application/json</code> or any media type
+            with a <code>+json</code> suffix as defined in [[RFC6839]] except
+            <code>application/ld+json</code>, update the <tref>active context</tref> using the
             <a href="#context-processing-algorithm">Context Processing algorithm</a>, passing the
-            context referenced in the HTTP Link Header as <tref>local context</tref>.</li>
+            context referenced in the HTTP Link Header as <tref>local context</tref>. The
+            HTTP Link Header is ignored for documents served as <code>application/ld+json</code>.</li>
           <li>Set <i>expanded</i> to the result of using the
             <a href="#expansion-algorithm">Expansion algorithm</a>, passing the
             <tref>active context</tref> and <i>input</i> as <i>element</i>.</li>
@@ -3934,9 +3942,10 @@
           <li>Create a new <tref>Promise</tref> <i>promise</i> and return it. The
             following steps are then executed asynchronously.</li>
           <li>If the passed <i>input</i> is a <span class="idlParamType">DOMString</span>
-            representing the <tref>IRI</tref> of a remote document, dereference it. If the retrieved document has a content type
-            different than <code>application/ld+json</code> or <code>application/json</code> or
-            if the document cannot be parsed as JSON, reject the <i>promise</i> passing an
+            representing the <tref>IRI</tref> of a remote document, dereference it.
+            If the retrieved document's content type is neither <code>application/json</code>,
+            nor <code>application/ld+json</code>, nor any other media type using a
+            <code>+json</code> suffix as defined in [[RFC6839]], reject the <i>promise</i> passing an
             <code class="error"><a href="#idl-def-JsonLdErrorCode.loading-document-failed">loading document failed</a></code>
             error.</li>
           <li>Initialize a new empty <tref>active context</tref>. The <tref>base IRI</tref>
@@ -3950,12 +3959,14 @@
             <a href="#context-processing-algorithm">Context Processing algorithm</a>, passing the
             <code class="idlMemberName"><a href="#widl-JsonLdOptions-expandContext">expandContext</a></code>
             as <tref>local context</tref>.</li>
-          <li>If the <i>input</i> has been retrieved and the response has a content type
-            <code>application/json</code> and an HTTP Link Header [[!RFC5988]] using the
-            <code>http://www.w3.org/ns/json-ld#context</code> link relation, update the
-            <tref>active context</tref> using the
+          <li>If the <i>input</i> has been retrieved, the response has an HTTP Link Header [[!RFC5988]]
+            using the <code>http://www.w3.org/ns/json-ld#context</code> link relation
+            and a content type of <code>application/json</code> or any media type
+            with a <code>+json</code> suffix as defined in [[RFC6839]] except
+            <code>application/ld+json</code>, update the <tref>active context</tref> using the
             <a href="#context-processing-algorithm">Context Processing algorithm</a>, passing the
-            context referenced in the HTTP Link Header as <tref>local context</tref>.</li>
+            context referenced in the HTTP Link Header as <tref>local context</tref>. The
+            HTTP Link Header is ignored for documents served as <code>application/ld+json</code>.</li>
           <li>Set <i>expanded</i> to the result of using the
             <a href="#expansion-algorithm">Expansion algorithm</a>, passing the
             <tref>active context</tref> and <i>input</i> as <i>element</i>.</li>
--- a/spec/latest/json-ld/index.html	Tue Jul 23 21:17:06 2013 +0200
+++ b/spec/latest/json-ld/index.html	Tue Jul 23 21:26:50 2013 +0200
@@ -166,6 +166,8 @@
     <li>Update grammar to disallow blank nodes as data types</li>
     <li>Update grammar to allow blank node identifiers as value of <code>@vocab</code></li>
     <li>Align the JSON-LD Data Model with the RDF Data Model</li>
+    <li>Support processing of documents with a <code>+json</code> media type as defined in
+      [[RFC6839]]</li>
   </ul>
 </section>
 
@@ -242,14 +244,14 @@
 
     <p>To understand the basics in this specification you must first be familiar with
       JSON, which is detailed in [[!RFC4627]].</p>
-      
-    <p>This document almost exclusively uses the term IRI 
-    (<a href="http://www.w3.org/TR/ld-glossary/#internationalized-resource-identifier">Internationalized Resource Indicator</a>) 
-    when discussing hyperlinks. Many Web developers are more familiar with the 
-    URL (<a href="http://www.w3.org/TR/ld-glossary/#uniform-resource-locator">Uniform Resource Locator</a>) 
-    terminology. The document also uses, albeit rarely, the URI 
-    (<a href="http://www.w3.org/TR/ld-glossary/#uniform-resource-identifier">Uniform Resource Indicator</a>) 
-    terminology. While these terms are often used interchangeably among 
+
+    <p>This document almost exclusively uses the term IRI
+    (<a href="http://www.w3.org/TR/ld-glossary/#internationalized-resource-identifier">Internationalized Resource Indicator</a>)
+    when discussing hyperlinks. Many Web developers are more familiar with the
+    URL (<a href="http://www.w3.org/TR/ld-glossary/#uniform-resource-locator">Uniform Resource Locator</a>)
+    terminology. The document also uses, albeit rarely, the URI
+    (<a href="http://www.w3.org/TR/ld-glossary/#uniform-resource-identifier">Uniform Resource Indicator</a>)
+    terminology. While these terms are often used interchangeably among
     technical communities, they do have important distinctions from one
     another and the specification goes to great lengths to try and use the
     proper terminology at all times.
@@ -279,7 +281,7 @@
    <dd>The JSON-LD syntax is very terse and human readable, requiring as
     little effort as possible from the developer.</dd>
    <dt>Zero Edits, most of the time</dt>
-   <dd>JSON-LD ensures a smooth and simple transition from existing 
+   <dd>JSON-LD ensures a smooth and simple transition from existing
      JSON-based systems. In many cases,
      zero edits to the JSON document and the addition of one line to the HTTP response
      should suffice (see <a class="sectionRef" href="#interpreting-json-as-json-ld"></a>).
@@ -287,11 +289,11 @@
      already deployed large JSON-based infrastructure to use JSON-LD's features
      in a way that is not disruptive to their day-to-day operations and is
      transparent to their current customers. However, there are times where
-     mapping JSON to a graph representation is a complex undertaking. 
-     In these instances, rather than extending JSON-LD to support 
-     esoteric use cases, we chose not to support the use case. While Zero 
-     Edits is a design goal, it is not always possible without adding 
-     great complexity to the language. JSON-LD focuses on simplicity when 
+     mapping JSON to a graph representation is a complex undertaking.
+     In these instances, rather than extending JSON-LD to support
+     esoteric use cases, we chose not to support the use case. While Zero
+     Edits is a design goal, it is not always possible without adding
+     great complexity to the language. JSON-LD focuses on simplicity when
      possible.</dd>
     <dt>Usable as RDF</dt>
     <dd>JSON-LD is usable by developers as
@@ -516,7 +518,7 @@
         },
         "homepage": {
           "@id": "http://schema.org/url", **** ← This means that 'homepage' is shorthand for 'http://schema.org/url' ****
-          "@type": "@id" **** ← This means that the value associated with 'homepage' should be interpreted as an identifier that is an IRI **** 
+          "@type": "@id" **** ← This means that the value associated with 'homepage' should be interpreted as an identifier that is an IRI ****
         }
       }****
     }
@@ -603,9 +605,9 @@
     }
     -->
     </pre>
-    
+
     <p>This section only covers the most basic features of the JSON-LD
-    Context. More advanced features related to the JSON-LD Context are covered 
+    Context. More advanced features related to the JSON-LD Context are covered
     in section <a href="#advanced-concepts"></a>.
     </p>
   </section>
@@ -742,10 +744,10 @@
   </ol>
 
   <p>This section only covers the most basic features associated with IRIs
-  in JSON-LD. More advanced features related to IRIs are covered in 
+  in JSON-LD. More advanced features related to IRIs are covered in
   section <a href="#advanced-concepts"></a>.
   </p>
-  
+
 </section>
 
 <section class="informative">
@@ -782,8 +784,8 @@
   <p>The example above contains a <tref>node object</tref> identified by the IRI
     <code>http://me.markus-lanthaler.com/</code>.</p>
 
-  <p>This section only covers the most basic features associated with 
-  node identifiers in JSON-LD. More advanced features related to 
+  <p>This section only covers the most basic features associated with
+  node identifiers in JSON-LD. More advanced features related to
   node identifiers are covered in section <a href="#advanced-concepts"></a>.
   </p>
 
@@ -839,8 +841,8 @@
 -->
 </pre>
 
-<p>This section only covers the most basic features associated with 
-types in JSON-LD. More advanced features related to 
+<p>This section only covers the most basic features associated with
+types in JSON-LD. More advanced features related to
 types are covered in section <a href="#advanced-concepts"></a>.
 </p>
 
@@ -1489,7 +1491,8 @@
     be unambiguously machine-readable without requiring developers to drastically
     change their documents and provides an upgrade path for existing infrastructure
     without breaking existing clients that rely on the <code>application/json</code>
-    media type.</p>
+    media type or a media type with a <code>+json</code> suffix as defined in
+    [[RFC6839]].</p>
 
   <p>In order to use an external context with an ordinary JSON document, an author
     MUST specify an <tref>IRI</tref> to a valid <tref>JSON-LD document</tref> in
@@ -3231,42 +3234,42 @@
   <p>Summarized, these differences mean that JSON-LD is capable of serializing any RDF
     graph or dataset and most, but not all, JSON-LD documents can be directly
     interpreted as RDF as described in RDF 1.1 Concepts [[RDF11-CONCEPTS]].</p>
-    
-  <p>For authors and developers working with 
+
+  <p>For authors and developers working with
     <tref title="blank node">blank nodes</tref> as
-    <tref title="property">properties</tref> when converting to RDF, there are 
+    <tref title="property">properties</tref> when converting to RDF, there are
     three potential approaches (in order of preference):</p>
-    
+
   <ol>
     <li>If the author is not yet ready to commit to a stable IRI, the
       property should be mapped to an IRI that is documented as unstable.</li>
-    <li>If the developer wishes to use 
+    <li>If the developer wishes to use
     <tref title="blank node">blank nodes</tref> as
     <tref title="property">properties</tref> and also wishes to interpret the
-    data as a 
+    data as a
     <tref href="http://www.w3.org/TR/rdf11-concepts/#fn-generalized-rdf-dataset">generalized RDF Dataset</tref>,
     there is an option in the [[JSON-LD-API]] to do so.</li>
-    <li>If the author or developer wishes to use 
+    <li>If the author or developer wishes to use
     <tref title="blank node">blank nodes</tref> as
     <tref title="property">properties</tref> and wishes to interpret the data
-    as a non-generalized RDF Dataset, it is possible 
-    to losslessly interpret JSON-LD as RDF by 
-    transforming <tref title="blank node">blank nodes</tref> used as 
+    as a non-generalized RDF Dataset, it is possible
+    to losslessly interpret JSON-LD as RDF by
+    transforming <tref title="blank node">blank nodes</tref> used as
     <tref title="property">properties</tref> to <tref title="IRI">IRIs</tref>,
     minting new "Skolem IRIs" as per
     <cite><a href="http://www.w3.org/TR/rdf11-concepts/#section-skolemization">Replacing Blank Nodes with IRIs</a></cite>
     of [[RDF11-CONCEPTS]].</li>
   </ol>
-  
-  <p>The normative algorithms for interpreting JSON-LD as RDF and serializing 
-    RDF as JSON-LD are specified in the JSON-LD Processing Algorithms and API 
+
+  <p>The normative algorithms for interpreting JSON-LD as RDF and serializing
+    RDF as JSON-LD are specified in the JSON-LD Processing Algorithms and API
     specification [[JSON-LD-API]].</p>
 
   <p>Even though JSON-LD serializes
     <tref href="http://www.w3.org/TR/rdf11-concepts/#fn-generalized-rdf-dataset">generalized RDF Datasets</tref>, it can
     also be used as a <tref href="http://www.w3.org/TR/rdf11-concepts/#dfn-rdf-source">RDF graph source</tref>.
     In that case, a consumer MUST only use the default graph and ignore all named graphs.
-    This allows servers to expose data in languages such as Turtle and JSON-LD 
+    This allows servers to expose data in languages such as Turtle and JSON-LD
     using content negotiation.</p>
 
   <p class="note">Publishers supporting both dataset and graph syntaxes have to ensure that
--- a/spec/latest/respec-w3c-extensions.js	Tue Jul 23 21:17:06 2013 +0200
+++ b/spec/latest/respec-w3c-extensions.js	Tue Jul 23 21:26:50 2013 +0200
@@ -12,7 +12,8 @@
     "TURTLE": "Eric Prud'hommeaux, Gavin Carothers, Editors. <cite><a href=\"http://www.w3.org/TR/2013/CR-turtle-20130219/\">Turtle: Terse RDF Triple Language.</a></cite> 19 February 2013. W3C Candidate Recommendation (work in progress). URL: <a href=\"http://www.w3.org/TR/2013/CR-turtle-20130219/\">http://www.w3.org/TR/2013/CR-turtle-20130219/</a>. The latest edition is available at <a href=\"http://www.w3.org/TR/turtle/\">http://www.w3.org/TR/turtle/</a>",
     "WEBIDL": "Cameron McCormack, Editor. <cite><a href=\"http://www.w3.org/TR/2012/CR-WebIDL-20120419/\">Web IDL.</a></cite> 19 April 2012. W3C Candidate Recommendation (work in progress). URL: <a href=\"http://www.w3.org/TR/2012/CR-WebIDL-20120419/\">http://www.w3.org/TR/2012/CR-WebIDL-20120419/</a>. The latest edition is available at <a href=\"http://www.w3.org/TR/WebIDL/\">http://www.w3.org/TR/WebIDL/</a>",
     "DOM-WHATWG": "Anne van Kesteren, Aryeh Gregor, Ms2ger, Editors. <cite><a href=\"http://dom.spec.whatwg.org/\">DOM</a>.</cite> April 2013. WHATWG Living Standard (work in progress). URL: <a href=\"http://dom.spec.whatwg.org/\">http://dom.spec.whatwg.org/</a>",
-    "RDF11-MT": "Patrick J. Hayes, Peter F. Patel-Schneider, Editors. <cite><a href=\"http://www.w3.org/TR/2013/WD-rdf11-mt-20130409/\">RDF 1.1 Semantics.</a></cite> 9 April 2013. W3C Working Draft (work in progress). URL: <a href=\"http://www.w3.org/TR/2013/WD-rdf11-mt-20130409/\">http://www.w3.org/TR/2013/WD-rdf11-mt-20130409/</a>. The latest edition is available at <a href=\"http://www.w3.org/TR/rdf11-mt/\">http://www.w3.org/TR/rdf11-mt/</a>"
+    "RDF11-MT": "Patrick J. Hayes, Peter F. Patel-Schneider, Editors. <cite><a href=\"http://www.w3.org/TR/2013/WD-rdf11-mt-20130409/\">RDF 1.1 Semantics.</a></cite> 9 April 2013. W3C Working Draft (work in progress). URL: <a href=\"http://www.w3.org/TR/2013/WD-rdf11-mt-20130409/\">http://www.w3.org/TR/2013/WD-rdf11-mt-20130409/</a>. The latest edition is available at <a href=\"http://www.w3.org/TR/rdf11-mt/\">http://www.w3.org/TR/rdf11-mt/</a>",
+    "RFC6839": "Tony Hansen, Alexey Melnikov. <cite><a href=\"http://www.ietf.org/rfc/rfc6839.txt\">Additional Media Type Structured Syntax Suffixes</a>.</cite> January 2013. Internet RFC 6839. URL: <a href=\"http://www.ietf.org/rfc/rfc6839.txt\">http://www.ietf.org/rfc/rfc6839.txt</a>",
 };
 
 var preProc = {