Ignore undefined terms when expanding
authorMarkus Lanthaler <mark_lanthaler@gmx.net>
Wed, 28 Mar 2012 23:53:22 +0800
changeset 416 63fa0b707804
parent 415 25efa13e9c52
child 417 2da486b08555
child 418 c150ca1167fe
Ignore undefined terms when expanding

Updated the expansion algorithm to ignore undefined terms that are not in the form of a compact IRI or absolute IRI. Removed wrong "Otherwise" that implied that the action gets just executed if the previous ones haven't - which isn't true. Furthermore, reverted removal of active property parameter from expansion algorithm done in 3aa65a7ef8f7216b7276427bdd61cf0e8f887e5a as that was a mistake.
spec/latest/json-ld-api/index.html
--- a/spec/latest/json-ld-api/index.html	Wed Mar 28 21:32:08 2012 +0800
+++ b/spec/latest/json-ld-api/index.html	Wed Mar 28 23:53:22 2012 +0800
@@ -1173,13 +1173,14 @@
 <section>
 <h3>Expansion Algorithm</h3>
 
-<p>The algorithm takes two input variables: an <tref>active context</tref> and an <em>element</em> to be expanded.
-  To begin, the <tref>active context</tref> is set to the <tref>initial context</tref> and <em>element</em> is set
-  to the <tref>JSON-LD input</tref>.</p>
+<p>The algorithm takes three input variables: an <tref>active context</tref>, an <tref>active property</tref>,
+  and a <em>value</em> to be expanded. To begin, the <tref>active context</tref> is set to the <tref>initial
+  context</tref>, <tref>active property</tref> is set to <tref>null</tref>, and <em>value</em> is set to the <tref>JSON-LD
+  input</tref>.</p>
 
 <ol class="algorithm">
   <li>If <em>element</em> is an <tref>array</tref>, process each item in <em>element</em> recursively
-    using this algorithm, passing copies of the <tref>active context</tref>.</li>
+    using this algorithm, passing copies of the <tref>active context</tref> and <tref>active property</tref>.</li>
   <li>Otherwise, if <em>element</em> is an object
     <ol class="algorithm">
       <li>If <em>element</em> has a <code>@context</code> property, update the <tref>active context</tref> according
@@ -1187,13 +1188,13 @@
       <li>For each <em>property</em> and <em>value</em> in <em>element</em>:
         <ol class="algorithm">
           <li>Set <em>property</em> as <tref>active property</tref>.</li>
-          <li>If <em>value</em> is <tref>null</tref>, skip this proporty/value pair and remove <em>property</em> from <em>element</em></li>
+          <li>If <em>value</em> is <tref>null</tref>, skip this property/value pair and remove <em>property</em> from <em>element</em></li>
           <li>Otherwise, if <em>value</em> is a <tref>JSON object</tref> having either a <code>@value</code>,
             <code>@list</code>, or <code>@set</code> key with a <tref>null</tref> value, skip this property/value pair and remove
             <em>property</em> from <em>element</em>.</li>
           <li>Otherwise, if <em>value</em> is a <tref>JSON object</tref> having a <code>@set</code> property with a
             non-<tref>null</tref> value, replace <em>value</em> with the value of <code>@set</code>.
-          <li>Otherwise, if the <em>property</em> is <code>@id</code> and the <em>value</em> is a <tref>string</tref>,
+          <li>If the <em>property</em> is <code>@id</code> and the <em>value</em> is a <tref>string</tref>,
             expand the value according to <a href="#iri-expansion">IRI Expansion</a>.</li>
           <li>Otherwise, if the <em>property</em> is <code>@type</code> and the <em>value</em> is a <tref>string</tref>
             expand <em>value</em> according to <a href="#iri-expansion">IRI Expansion</a>. If <em>element</em> has no
@@ -1201,24 +1202,27 @@
           <li>Otherwise, if the <em>property</em> is <code>@type</code> and the <em>value</em> is an <tref>array</tref>,
             expand every item according to <a href="#iri-expansion">IRI Expansion</a>.</li>
           <li>Otherwise, if the <em>property</em> is <code>@value</code>, the value is not subject to further expansion.</li>
-          <li>Otherwise, if the <em>property</em> is not a <tref>keyword</tref>, expand the <em>property</em> according to
-            <a href="#iri-expansion">IRI Expansion</a> rules.</li>
-          <li>If the <em>value</em> is an <tref>array</tref>, and <tref>active property</tref> is subject to <code>@list</code>
-            expansion, replace the <em>value</em> with an object having a <code>@list</code> property whose value is
-            set to the current <em>value</em>.</li>
-          <li>If the <em>value</em> is an <tref>array</tref>, process each item in the <tref>array</tref>
-            recursively using this algorithm, passing a copy of the <tref>active context</tref> removing items which
-            expand to <tref>null</tref>.</li>
-          <li>If the <em>value</em> is an object, process the object recursively using this algorithm, passing a copy
-            of the <tref>active context</tref>. If <tref>null</tref> is returned, skip this property/value pair and remove
-            <tref>active property</tref> from <em>element</em>.</li>
-          <li>Otherwise, expand the <em>value</em> according to the <a href="#value-expansion">Value Expansion</a> rules,
-            passing <tref>active property</tref>.</li>
+          <li>Otherwise, if the <em>property</em> has a <tref>term mapping</tref> or has the form of an <tref>compact IRI</tref>
+            or <tref>absolute IRI</tref>, expand the <em>property</em> according to the <a href="#iri-expansion">IRI Expansion</a>
+            rules and process <em>value</em> as follows:
+            <ol class="algorithm">
+              <li>If the <em>value</em> is an <tref>array</tref>, and <tref>active property</tref> is subject to <code>@list</code>
+                expansion, replace the <em>value</em> with array containing an object having a <code>@list</code> property whose value is
+                set to the current <em>value</em>.</li>
+              <li>If the <em>value</em> is an <tref>array</tref>, process each item in the <tref>array</tref>
+                recursively using this algorithm, passing copies of the <tref>active context</tref> and <tref>active property</tref>
+                removing all items that equal to <tref>null</tref>.</li>
+              <li>If the <em>value</em> is an object, process the object recursively using this algorithm, passing copies
+                of the <tref>active context</tref> and <tref>active property</tref>.</li>
+              <li>Otherwise, expand the <em>value</em> according to the <a href="#value-expansion">Value Expansion</a> rules,
+                passing copies of the <tref>active context</tref> and <tref>active property</tref>.</li>
+            </ol>
+          </li>
         </ol>
       </li>
     </ol>
   </li>
-  <li>Otherwise, expand <em>value</em> according to the <a href="#value-expansion">Value Expansion</a> rules,
+  <li>Otherwise, expand <em>element</em> according to the <a href="#value-expansion">Value Expansion</a> rules,
     passing <tref>active property</tref>.</li>
 </ol>
 </section>