Ensure that free-floating lists are kept
authorMarkus Lanthaler <mark_lanthaler@gmx.net>
Thu, 10 Jan 2013 13:36:19 +0100
changeset 1119 fe8ac27f5569
parent 1118 3bbcaba766b8
child 1120 a3aa38aa81ed
Ensure that free-floating lists are kept

As they represent a linked structure of blank nodes which are by definition never free-floating.

This addresses #207.
spec/latest/json-ld-api/index.html
test-suite/tests/expand-0045-in.jsonld
test-suite/tests/expand-0045-out.jsonld
test-suite/tests/expand-0046-in.jsonld
test-suite/tests/expand-0046-out.jsonld
test-suite/tests/expand-0047-in.jsonld
test-suite/tests/expand-0047-out.jsonld
test-suite/tests/expand-manifest.jsonld
--- a/spec/latest/json-ld-api/index.html	Thu Jan 10 10:57:51 2013 +0100
+++ b/spec/latest/json-ld-api/index.html	Thu Jan 10 13:36:19 2013 +0100
@@ -827,10 +827,15 @@
                 <li>If <em>expanded property</em> equals <code>@annotation</code>, set the <code>@annotation</code>
                   member of <em>result</em> to <em>value</em>. If <em>value</em> is not a <tref>string</tref>
                   trigger an <code class="error">invalid @annotation value</code> error.</li>
-                <li>If <em>expanded property</em> equals <code>@set</code> or <code>@list</code>, set the
-                  <em>expanded property</em> member of <em>result</em> to the result of expanding <em>value</em> by
+                <li>If <em>expanded property</em> equals <code>@set</code> set the <em>expanded property</em>
+                  member of <em>result</em> to the result of expanding <em>value</em> by
                   recursively using this algorithm, passing copies of the <tref>active context</tref> and
                   <tref>active property</tref>.</li>
+                <li>If <em>expanded property</em> equals <code>@list</code>, set the <em>expanded property</em>
+                  member of <em>result</em> to the result of expanding <em>value</em> by
+                  recursively using this algorithm, passing copies of the <tref>active context</tref> and
+                  <tref>active property</tref>; if <tref>active property</tref> equals <tref>null</tref> or
+                  <code>@graph</code>, pass <code>@list</code> as <tref>active property</tref> instead.</li>
                 <li>If <em>expanded property</em> equals <code>@graph</code>, set the <code>@graph</code>
                   member of <em>result</em> to the result of expanding <em>value</em> by
                   recursively using this algorithm, passing copies of the <tref>active context</tref> and
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/expand-0045-in.jsonld	Thu Jan 10 13:36:19 2013 +0100
@@ -0,0 +1,3 @@
+{
+    "@value": "free-floating value"
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/expand-0045-out.jsonld	Thu Jan 10 13:36:19 2013 +0100
@@ -0,0 +1,1 @@
+[ ]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/expand-0046-in.jsonld	Thu Jan 10 13:36:19 2013 +0100
@@ -0,0 +1,14 @@
+{
+    "@graph": [
+        { "@id": "http://example.com/free-floating-node" },
+        { "@value": "free-floating value object" },
+        { "@value": "free-floating value language-tagged string",  "@language": "en" },
+        { "@value": "free-floating value typed value",  "@type": "http://example.com/type" },
+        "free-floating plain string",
+        true,
+        false,
+        null,
+        1,
+        1.5
+    ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/expand-0046-out.jsonld	Thu Jan 10 13:36:19 2013 +0100
@@ -0,0 +1,1 @@
+[ ]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/expand-0047-in.jsonld	Thu Jan 10 13:36:19 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/expand-0047-out.jsonld	Thu Jan 10 13:36:19 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/expand-manifest.jsonld	Thu Jan 10 10:57:51 2013 +0100
+++ b/test-suite/tests/expand-manifest.jsonld	Thu Jan 10 13:36:19 2013 +0100
@@ -226,6 +226,21 @@
       "name": "Ensure annotation maps use language mapping",
       "input": "expand-0044-in.jsonld",
       "expect": "expand-0044-out.jsonld"
+    }, {
+      "@type": ["test:TestCase", "jld:ExpandTest"],
+      "name": "Top-level value objects are removed",
+      "input": "expand-0045-in.jsonld",
+      "expect": "expand-0045-out.jsonld"
+    }, {
+      "@type": ["test:TestCase", "jld:ExpandTest"],
+      "name": "Free-floating nodes are removed",
+      "input": "expand-0046-in.jsonld",
+      "expect": "expand-0046-out.jsonld"
+    }, {
+      "@type": ["test:TestCase", "jld:ExpandTest"],
+      "name": "Free-floating values in sets are removed, free-floating lists are kept",
+      "input": "expand-0047-in.jsonld",
+      "expect": "expand-0047-out.jsonld"
     }
   ]
 }