Interpret objects that do not have a @context entry as the JSON-LD context when passed into the API functions
Previously, all context parameters required a valid context document, i.e., an object with a @context member. Now the value of such a member can be passed in directly.
This addresses #245
--- a/spec/latest/json-ld-api/index.html Sun Aug 11 22:07:57 2013 +0200
+++ b/spec/latest/json-ld-api/index.html Sun Aug 11 22:40:18 2013 +0200
@@ -211,6 +211,8 @@
[[RFC6839]]</li>
<li>Use the <a>LoadDocumentCallback</a> (previously <code>LoadContextCallback</code>)
to retrieve remote contexts and remote documents</li>
+ <li>Allow contexts to be passed into the API directly. Previously only context documents, i.e.,
+ objects having a <code>@context</code> member were allowed.</li>
</ul>
</section>
@@ -3842,7 +3844,9 @@
has been passed, update the <tref>active context</tref> using the
<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>
+ as <tref>local context</tref>. If
+ <code class="idlMemberName"><a href="#widl-JsonLdOptions-expandContext">expandContext</a></code>
+ is a <tref>JSON object</tref> having a <code>@context</code> member, pass that member's value instead.</li>
<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
@@ -3858,6 +3862,8 @@
<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>
+ <li>If <i>context</i> is a <tref>JSON object</tref> having a <code>@context</code> member, set
+ <i>context</i> to that member's value.</li>
<li>Set <i>compacted</i> to the result of using the
<a href="#compaction-algorithm">Compaction algorithm</a>, passing
<i>context</i>, <i>expanded</i> as <i>element</i>, and if passed, the
@@ -3906,7 +3912,9 @@
has been passed, update the <tref>active context</tref> using the
<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>
+ as <tref>local context</tref>. If
+ <code class="idlMemberName"><a href="#widl-JsonLdOptions-expandContext">expandContext</a></code>
+ is a <tref>JSON object</tref> having a <code>@context</code> member, pass that member's value instead.</li>
<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
@@ -3961,7 +3969,9 @@
has been passed, update the <tref>active context</tref> using the
<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>
+ as <tref>local context</tref>. If
+ <code class="idlMemberName"><a href="#widl-JsonLdOptions-expandContext">expandContext</a></code>
+ is a <tref>JSON object</tref> having a <code>@context</code> member, pass that member's value instead.</li>
<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
@@ -3977,6 +3987,8 @@
<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>
+ <li>If <i>context</i> is a <tref>JSON object</tref> having a <code>@context</code> member, set
+ <i>context</i> to that member's value.</li>
<li>Initialize an empty <i>identifier map</i> and a <i>counter</i> (set to <code>0</code>)
to be used by the
<a href="#generate-blank-node-identifier">Generate Blank Node Identifier algorithm</a>.</li>
@@ -4009,9 +4021,9 @@
<div class='idl' title='typedef (object or DOMString or (object or DOMString)[]) JsonLdContext'>
<p>The <a>JsonLdContext</a> type is used to refer to a value that
- that may be a <tref>JSON object</tref>, an <tref>IRI</tref>, or an
- array of <tref>JSON object</tref>s and <tref>IRI</tref>s.
- </p>
+ that may be a <tref>JSON object</tref>, a <tref>string</tref> representing an
+ <tref>IRI</tref>, or an array of <tref title="JSON object">JSON objects</tref>
+ and <tref title="string">strings</tref>.</p>
</div>
</section> <!-- end of JsonLdProcessor -->