Flatten free-floating lists correctly
authorMarkus Lanthaler <mark_lanthaler@gmx.net>
Thu, 10 Jan 2013 13:54:08 +0100
changeset 1120 a3aa38aa81ed
parent 1119 fe8ac27f5569
child 1121 aa9d21e1fc21
Flatten free-floating lists correctly

This addresses #207.
spec/latest/json-ld-api/index.html
test-suite/tests/flatten-0041-in.jsonld
test-suite/tests/flatten-0041-out.jsonld
test-suite/tests/flatten-manifest.jsonld
--- a/spec/latest/json-ld-api/index.html	Thu Jan 10 13:36:19 2013 +0100
+++ b/spec/latest/json-ld-api/index.html	Thu Jan 10 13:54:08 2013 +0100
@@ -1828,7 +1828,10 @@
           <code>@list</code> whose value is initialized to an empty <tref>array</tref>.</li>
         <li>Recursively call this algorithm passing the value of <em>element's</em>
           <code>@list</code> member as new <em>element</em> and <em>result</em> as <em>list</em>.</li>
-        <li>Add <em>result</em> to the the value of the <tref>active property</tref> member
+        <li>If <tref>active property</tref> equals <tref>null</tref> or <code>@graph</code>,
+          <a href="#generate-blank-node-identifier">generate a blank node identifier</a> <em>id</em>
+          and store <em>result</em> as value of the member <em>id</em> in <em>activeGraph</em>.</li>
+        <li>Otherwise, add <em>result</em> to the the value of the <tref>active property</tref> member
           of the <tref>active subject</tref> in <em>activeGraph</em>.</li>
       </ol>
     </li>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/flatten-0041-in.jsonld	Thu Jan 10 13:54:08 2013 +0100
@@ -0,0 +1,24 @@
+{
+    "@context": {
+        "property": "http://example.com/property"
+    },
+    "@graph": [
+        {
+            "@set": [
+                "free-floating strings in set objects are removed",
+                {
+                    "@id": "http://example.com/free-floating-node"
+                },
+                {
+                    "@id": "http://example.com/node",
+                    "property": "nodes with properties are not removed"
+                }
+            ]
+        },
+        {
+            "@list": [
+                "lists are never removed as they represent an invisible linked structure"
+            ]
+        }
+    ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/flatten-0041-out.jsonld	Thu Jan 10 13:54:08 2013 +0100
@@ -0,0 +1,15 @@
+[
+    {
+        "@id": "http://example.com/node",
+        "http://example.com/property": [
+            {
+                "@value": "nodes with properties are not removed"
+            }
+        ]
+    },
+    {
+        "@list": [
+            { "@value": "lists are never removed as they represent an invisible linked structure" }
+        ]
+    }
+]
--- a/test-suite/tests/flatten-manifest.jsonld	Thu Jan 10 13:36:19 2013 +0100
+++ b/test-suite/tests/flatten-manifest.jsonld	Thu Jan 10 13:54:08 2013 +0100
@@ -206,6 +206,11 @@
       "name": "Only invoke language and annotation map expansion if the value is a JSON object",
       "input": "flatten-0040-in.jsonld",
       "expect": "flatten-0040-out.jsonld"
+    }, {
+      "@type": ["test:TestCase", "jld:ExpandTest"],
+      "name": "Free-floating sets and lists",
+      "input": "expand-0041-in.jsonld",
+      "expect": "expand-0041-out.jsonld"
     }
   ]
 }