Added support for absolute IRIs and CURIEs as context keys, and amend IRI expansion rules to look for full match before prefix match.
This addresses issue #43 (not closed, because of ongoing concerns about multiple mappings to the same IRI and the effect on compression).
--- a/spec/latest/json-ld-api/index.html Thu Jan 26 17:16:24 2012 -0800
+++ b/spec/latest/json-ld-api/index.html Fri Jan 27 10:55:33 2012 -0800
@@ -802,6 +802,7 @@
simple <tref>string</tref> or <code>null</code>. Add the language to the <tref>local context</tref>.</li>
<li id="object-context">Otherwise, for each key in <em>value</em> having the lexical form of an <cite><a
href="http://www.w3.org/TR/2009/REC-xml-names-20091208/#NT-NCName">NCName</a></cite> (see [[XML-NAMES]]),
+ <tref>compact IRI</tref>, absolute <tref>IRI</tref>,
or being an empty string, perform the following steps:
<ol class="algorithm">
<li>If the key's value is a simple <tref>string</tref>, the value MUST have the form of
@@ -811,11 +812,20 @@
<tref>term mapping</tref>.</li>
<li>Otherwise, the key's value MUST be a <tref>JSON object</tref>.
<ol class="algorithm">
- <li>The value MUST have a <code>@id</code> key with a string value, the value MUST have the
- form of <tref>term</tref>, <tref>compact IRI</tref>, <tref>absolute IRI</tref>. Determine the IRI mapping value
- by performing <a href="#iri-expansion">IRI Expansion</a> on the associated value. If the result of
- the IRI mapping is an <tref>absolute IRI</tref>, merge the key-value pair into the <tref>local context</tref>
- <tref>term mapping</tref>.</li>
+ <li>If the key has the form of <tref>term</tref>, the value MUST have a <code>@id</code>
+ key with a string value, the value MUST have the
+ form of <tref>term</tref>, <tref>compact IRI</tref>, <tref>absolute IRI</tref>.
+ Determine the IRI mapping value
+ by performing <a href="#iri-expansion">IRI Expansion</a> on the associated value.
+ If the result of the IRI mapping is an <tref>absolute IRI</tref>, merge the
+ key-value pair into the <tref>local context</tref> <tref>term mapping</tref>.</li>
+ <li>If the key has the form of <tref>compact IRI</tref> or <tref>absolute IRI</tref>,
+ the value MAY have a <code>@id</code> key with a string value, this value MUST have the
+ form of <tref>term</tref>, <tref>compact IRI</tref>, absolute <tref>IRI</tref>.
+ Determine the IRI mapping value
+ by performing <a href="#iri-expansion">IRI Expansion</a> on the associated value.
+ If the result of the IRI mapping is an <tref>absolute IRI</tref>, merge the
+ key-value pair into the <tref>local context</tref> <tref>term mapping</tref>.</li>
<li>If the value has a <code>@type</code> key, the value MUST have the form of <tref>term</tref>,
<tref>compact IRI</tref>, <tref>absolute IRI</tref> or the <tref>keyword</tref> <code>@id</code>. Determine the IRI by
performing <a href="#iri-expansion">IRI Expansion</a> on the associated value. If the result of the
@@ -859,7 +869,9 @@
<p>The algorithm for generating an IRI is:
<ol class="algorithm">
- <li>Split the value into a <em>prefix</em> and <em>suffix</em> from the first occurrence of ':'.</li>
+ <li>If the <tref>active context</tref> contains a <tref>term</tref> mapping for the value using
+ a case-sensitive comparison, use the mapped value as an IRI.</li>
+ <li>Otherwise, split the value into a <em>prefix</em> and <em>suffix</em> from the first occurrence of ':'.</li>
<li>If the prefix is a '_' (underscore), the value represents a named <tref>blank node</tref>.</li>
<li>If the <tref>active context</tref> contains a <tref>term</tref> mapping for <em>prefix</em> using
a case-sensitive comparison, generate an <tref>IRI</tref>
@@ -878,7 +890,7 @@
<section>
<h2>IRI Compaction</h2>
<p>Some keys and values are expressed using <tref>IRI</tref>s. This section defines an
- algorithm for transforming an IRI to a compact IRI using the
+ algorithm for transforming an IRI to a <tref>term</tref> or <tref>compact IRI</tref> using the
<tref>term</tref>s specified in the <tref>local context</tref>.</p>
<p>The algorithm for generating a <tref>compact IRI</tref> is:
--- a/spec/latest/json-ld-syntax/index.html Thu Jan 26 17:16:24 2012 -0800
+++ b/spec/latest/json-ld-syntax/index.html Fri Jan 27 10:55:33 2012 -0800
@@ -1727,6 +1727,39 @@
] .
-->
</pre>
+
+<p>Terms may also be defined using <tref title="absolute iri">absolute IRIs</tref> or <tref title="compact_iri">compact IRIs</tref>.
+ This allows coercion rules to by applied to keys which are not represented as a simple <tref>term</tref>.
+ For example:</p>
+
+<pre class="example" data-transform="updateExample">
+<!--
+{
+ "@context":
+ {
+ ****"foaf": "http://xmlns.com/foaf/0.1/"****,
+ "****foaf:age****":
+ {
+ "@id": "http://xmlns.com/foaf/0.1/"",
+ "@type": "xsd:integer"
+ },
+ "****foaf:homepage****":
+ ****{
+ "@type": "@id"
+ }****
+}
+-->
+</pre>
+
+<p>In this case, the <code>@id</code> definition is optional, but if it does exist, the <tref>compact IRI</tref>
+ or <tref>IRI</tref> is treated as a term so that the actual definition of a <tref>prefix</tref> becomes unnecessary.</p>
+
+<!-- FIXME: pending final resolution of coercion
+<p class="note">Keys in the context are treated as <tref title="term">terms</tref> for the purpose of
+ expansion and value coercion. This allows multiple representations for the same expanded IRI, which may be
+ useful for establishing different type coercion rules. It also allows a <tref>compact IRI</tref> (or even an
+ absolute <tref>IRI</tref>) to be defined as something else entirely, but this usage is discouraged.</p>
+-->
</section>
<section>