Fix bug in Create Term Definition algorithm
authorMarkus Lanthaler <mark_lanthaler@gmx.net>
Sun, 05 May 2013 18:05:11 +0200
changeset 1625 286baedd8225
parent 1624 eb8c98b25d85
child 1626 6e809b352d83
Fix bug in Create Term Definition algorithm

... which resulted in a cyclic IRI mapping error when a term was redefined to itself

See https://github.com/json-ld/json-ld.org/commit/657c90f3fc4050fce006fa11a2a420e7e4efe049

/cc @dlongley @gkellogg
spec/latest/changes-since-lc.txt
spec/latest/json-ld-api/index.html
--- a/spec/latest/changes-since-lc.txt	Sun May 05 17:01:37 2013 +0200
+++ b/spec/latest/changes-since-lc.txt	Sun May 05 18:05:11 2013 +0200
@@ -10,3 +10,5 @@
 ---------------------
 
 - Update API to use DOM Futures instead of node-style callbacks (section 11. The Application Programming Interface)
+- Fix bug in Create Term Definition algorithm which resulted in a cyclic IRI mapping error when a term was redefined to itself (see https://github.com/json-ld/json-ld.org/commit/657c90f3fc4050fce006fa11a2a420e7e4efe049)
+
--- a/spec/latest/json-ld-api/index.html	Sun May 05 17:01:37 2013 +0200
+++ b/spec/latest/json-ld-api/index.html	Sun May 05 18:05:11 2013 +0200
@@ -1042,7 +1042,7 @@
           error has been detected and processing is aborted.</li>
         <li>Remove any existing <tref>term definition</tref> for <i>term</i> in
           <tref>active context</tref>.</li>
-        <li>Initialize <i>value</i> to the value associated with the key
+        <li>Initialize <i>value</i> to a copy of the value associated with the key
           <i>term</i> in <tref>local context</tref>.</li>
         <li>If <i>value</i> is <tref>null</tref> or <i>value</i>
           is a <tref>JSON object</tref> containing the key-value pair
@@ -1050,23 +1050,9 @@
           <tref>term definition</tref> in <tref>active context</tref> to
           <tref>null</tref>, set the value associated with <i>defined</i>'s
           key <i>term</i> to <tref>true</tref>, and return.</li>
-        <li>Otherwise, if <i>value</i> is a <tref>string</tref>:
-          <ol class="algorithm">
-            <li>Expand <i>value</i> by setting it to the result of
-              using the <a href="#iri-expansion">IRI Expansion algorithm</a>,
-              passing <tref>active context</tref>, <i>value</i>,
-              <tref>true</tref> for <i>vocab</i>,
-              <tref>true</tref> for <i>document relative</i>,
-              <tref>local context</tref>, and <i>defined</i>.</li>
-            <li>If <i>value</i> is <code>@context</code>, an
-              <code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-keyword-alias">invalid keyword alias</a></code>
-              error has been detected and processing is aborted.</li>
-            <li>Set the <tref>IRI mapping</tref> for the <tref>term definition</tref>
-              for <i>term</i> in <tref>active context</tref> to <i>value</i>,
-              set the value associated with <i>defined</i>'s key <i>term</i> to
-              <tref>true</tref>, and return.</li>
-          </ol>
-        </li>
+        <li>Otherwise, if <i>value</i> is a <tref>string</tref>, convert it
+          to a <tref>JSON object</tref> consisting of a single member whose
+          key is <code>@id</code> and whose value is <i>value</i>.</li>
         <li>Otherwise, <i>value</i> must be a <tref>JSON object</tref>, if not, an
           <code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-term-definition">invalid term definition</a></code>
           error has been detected and processing is aborted.</li>
@@ -1110,7 +1096,8 @@
         </li>
         <li>Set the <tref>reverse property</tref> flag of <i>definition</i>
           to <tref>false</tref>.</li>
-        <li>If <i>value</i> contains the key <code>@id</code>:
+        <li>If <i>value</i> contains the key <code>@id</code> and its value
+          does not equal <i>term</i>:
           <ol class="algorithm">
             <li>If the value associated with the <code>@id</code> key is not a <tref>string</tref>, an
               <code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-IRI-mapping">invalid IRI mapping</a></code>
@@ -1120,7 +1107,10 @@
               <tref>active context</tref>, the value associated with the <code>@id</code> key for
               <i>value</i>, <tref>true</tref> for <i>vocab</i>,
               <tref>true</tref> for <i>document relative</i>,
-              <tref>local context</tref>, and <i>defined</i>.</li>
+              <tref>local context</tref>, and <i>defined</i>. If the resulting
+              <tref>IRI mapping</tref> equals <code>@context</code>, an
+              <code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-keyword-alias">invalid keyword alias</a></code>
+              error has been detected and processing is aborted.</li>
           </ol>
         </li>
         <li>