Update algorithms and tests to remove free-floating nodes
authorMarkus Lanthaler <mark_lanthaler@gmx.net>
Thu, 10 Jan 2013 10:57:51 +0100
changeset 1118 3bbcaba766b8
parent 1117 e281e6e6499e
child 1119 fe8ac27f5569
Update algorithms and tests to remove free-floating nodes

This addresses #207.
spec/latest/json-ld-api/index.html
spec/latest/json-ld-syntax/index.html
test-suite/tests/compact-0001-out.jsonld
test-suite/tests/compact-0003-out.jsonld
test-suite/tests/compact-0010-in.jsonld
test-suite/tests/compact-0010-out.jsonld
test-suite/tests/compact-0014-in.jsonld
test-suite/tests/compact-0014-out.jsonld
test-suite/tests/compact-0016-in.jsonld
test-suite/tests/compact-0016-out.jsonld
test-suite/tests/compact-0039-in.jsonld
test-suite/tests/compact-0039-out.jsonld
test-suite/tests/compact-manifest.jsonld
test-suite/tests/expand-0001-out.jsonld
test-suite/tests/expand-0003-out.jsonld
test-suite/tests/expand-0019-out.jsonld
test-suite/tests/expand-0021-in.jsonld
test-suite/tests/expand-0021-out.jsonld
test-suite/tests/expand-manifest.jsonld
test-suite/tests/flatten-0001-out.jsonld
test-suite/tests/flatten-0003-out.jsonld
test-suite/tests/flatten-0019-out.jsonld
test-suite/tests/flatten-0021-in.jsonld
test-suite/tests/flatten-0021-out.jsonld
--- a/spec/latest/json-ld-api/index.html	Thu Jan 10 10:26:34 2013 +0100
+++ b/spec/latest/json-ld-api/index.html	Thu Jan 10 10:57:51 2013 +0100
@@ -768,7 +768,9 @@
   <ol class="algorithm">
     <li>If <em>element</em> is a <tref>scalar</tref>, expand it according to the
       <a href="#value-expansion">Value Expansion</a> algorithm, passing copies of the
-      <tref>active context</tref> and <tref>active property</tref> and return.</li>
+      <tref>active context</tref> and <tref>active property</tref> and return. If the
+      <tref>active property</tref> equals <tref>null</tref> or <code>@graph</code>
+      set <em>element</em> to <tref>null</tref> instead and return.</li>
     <li>If <em>element</em> is <tref>null</tref>, return.</li>
     <li>If <em>element</em> is an <tref>array</tref>,
       <ol class="algorithm">
@@ -905,6 +907,10 @@
           of <em>result</em>.</li>
         <li>If <em>element</em> has an <code>@annotation</code> member, decrease <em>numProperties</em>
           by 1.</li>
+        <li>If the <tref>active property</tref> equals <tref>null</tref> or <code>@graph</code> and
+          <em>element</em> has an <code>@value</code> member, <em>numProperties</em> equals <code>0</code>,
+          or <em>element</em> consists of only an <code>@id</code> member, set <em>element</em> to
+          <tref>null</tref> and return.</li>
         <li>If <em>element</em> has an <code>@value</code> member,
           <ol class="algorithm">
             <li>decrease <em>numProperties</em> by 1.</li>
@@ -937,7 +943,8 @@
   <p>If, after the algorithm outlined above is run, the resulting <em>element</em> is an
     <tref>JSON object</tref> with just a <code>@graph</code> member, <em>element</em> is set to
     the value of <code>@graph</code>'s value. Finally, if <em>element</em> is a <tref>JSON object</tref>,
-    it is wrapped into an <tref>array</tref>.</p>
+    it is wrapped into an <tref>array</tref>, if <em>element</em> equals <tref>null</tref>, an empty
+    <tref>array</tref> is returned.</p>
 </section>
 
 <section>
@@ -1803,11 +1810,7 @@
     </li>
     <li>If <em>element</em> has an <code>@value</code> member, perform the following steps:
       <ol class="algorithm">
-        <li>If <tref>active property</tref> is <tref>null</tref>,
-          <a href="#generate-blank-node-identifier">generate a blank node identifier</a> <em>id</em>
-          and store <em>element</em> as value of the member <em>id</em> in <em>activeGraph</em>.
-          <p class="issue" data-number="207">Handling of free-floating values is still being discussed.</p></li>
-        <li>Otherwise, if no <em>list</em> has been passed, merge <em>element</em> into the
+        <li>If no <em>list</em> has been passed, merge <em>element</em> into the
           <tref>active property</tref> member of the <tref>active subject</tref> in
           <em>activeGraph</em>.</li>
         <li>Otherwise, append <em>element</em> to the <code>@list</code> member of <em>list</em>.</li>
@@ -1820,11 +1823,7 @@
           <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>If <tref>active property</tref> is <tref>null</tref>,
-          <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>.
-          <p class="issue" data-number="207">Handling of free-floating values is still being discussed.</p></li>
-        <li>Otherwise, add <em>result</em> to the the value of the <tref>active property</tref> member
+        <li>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>
--- a/spec/latest/json-ld-syntax/index.html	Thu Jan 10 10:26:34 2013 +0100
+++ b/spec/latest/json-ld-syntax/index.html	Thu Jan 10 10:57:51 2013 +0100
@@ -2674,7 +2674,7 @@
       a <tref>JSON-LD value</tref>, or a <tref>list</tref>.</li>
     <li>A node having an outgoing edge MUST be an <tref>IRI</tref> or a
       <tref>blank node</tref>.</li>
-    <li>A <tref>JSON-LD graph</tref> SHOULD NOT contain unconnected <tref title="node">nodes</tref>,
+    <li>A <tref>JSON-LD graph</tref> MUST NOT contain unconnected <tref title="node">nodes</tref>,
       i.e., nodes which are not connected by an <tref>edge</tref> to any other <tref>node</tref>.</li>
     <li>An <tdef><abbr title="Internationalized Resource Identifier">IRI</abbr></tdef>
       (Internationalized Resource Identifier) is a string that conforms to the syntax
@@ -3050,9 +3050,6 @@
       <tref title="IRI">IRIs</tref> or <tref title="blank node">blank nodes</tref>
       whereas in RDF properties (predicates) have to be
       <tref title="IRI">IRIs</tref>.</li>
-    <li>In contrast to RDF graphs <tref title="JSON-LD graph">JSON-LD graphs</tref>
-      support unconnected <tref title="node">nodes</tref>, i.e., nodes which are not
-      connected to any other node.</li>
     <li>In JSON-LD lists are part of the data model whereas in RDF they are part of
       a vocabulary, namely [[RDF-SCHEMA]].</li>
     <li>RDF values are either typed <em>literals</em>
--- a/test-suite/tests/compact-0001-out.jsonld	Thu Jan 10 10:26:34 2013 +0100
+++ b/test-suite/tests/compact-0001-out.jsonld	Thu Jan 10 10:57:51 2013 +0100
@@ -1,1 +1,3 @@
-{"@id": "http://example.org/test#example"}
\ No newline at end of file
+{
+    "@graph": []
+}
--- a/test-suite/tests/compact-0003-out.jsonld	Thu Jan 10 10:26:34 2013 +0100
+++ b/test-suite/tests/compact-0003-out.jsonld	Thu Jan 10 10:57:51 2013 +0100
@@ -1,3 +1,3 @@
 {
-  "@id": "http://example.org/id"
-}
\ No newline at end of file
+    "@graph": []
+}
--- a/test-suite/tests/compact-0010-in.jsonld	Thu Jan 10 10:26:34 2013 +0100
+++ b/test-suite/tests/compact-0010-in.jsonld	Thu Jan 10 10:57:51 2013 +0100
@@ -1,9 +1,13 @@
 [
   {
+    "@id": "http://example.com/john",
     "http://xmlns.com/foaf/0.1/homepage": {
       "@id": "http://john.doe.org/"
     },
     "http://xmlns.com/foaf/0.1/name": "John Doe"
   },
-  {}
-]
\ No newline at end of file
+  {
+    "@id": "http://example.com/jane",
+    "http://xmlns.com/foaf/0.1/name": "Jane Doe"
+  }
+]
--- a/test-suite/tests/compact-0010-out.jsonld	Thu Jan 10 10:26:34 2013 +0100
+++ b/test-suite/tests/compact-0010-out.jsonld	Thu Jan 10 10:57:51 2013 +0100
@@ -8,10 +8,13 @@
   },
   "@graph": [
     {
+      "@id": "http://example.com/john",
       "homepage": "http://john.doe.org/",
       "name": "John Doe"
     },
     {
+      "@id": "http://example.com/jane",
+      "name": "Jane Doe"
     }
   ]
-}
\ No newline at end of file
+}
--- a/test-suite/tests/compact-0014-in.jsonld	Thu Jan 10 10:26:34 2013 +0100
+++ b/test-suite/tests/compact-0014-in.jsonld	Thu Jan 10 10:57:51 2013 +0100
@@ -1,9 +1,13 @@
 [
   {
+    "@id": "http://example.com/john",
     "http://xmlns.com/foaf/0.1/homepage": {
       "@id": "http://john.doe.org/"
     },
     "http://xmlns.com/foaf/0.1/name": "John Doe"
   },
-  {}
-]
\ No newline at end of file
+  {
+    "@id": "http://example.com/jane",
+    "http://xmlns.com/foaf/0.1/name": "Jane Doe"
+  }
+]
--- a/test-suite/tests/compact-0014-out.jsonld	Thu Jan 10 10:26:34 2013 +0100
+++ b/test-suite/tests/compact-0014-out.jsonld	Thu Jan 10 10:57:51 2013 +0100
@@ -9,10 +9,13 @@
   },
   "data": [
     {
+      "@id": "http://example.com/john",
       "homepage": "http://john.doe.org/",
       "name": "John Doe"
     },
     {
+      "@id": "http://example.com/jane",
+      "name": "Jane Doe"
     }
   ]
 }
--- a/test-suite/tests/compact-0016-in.jsonld	Thu Jan 10 10:26:34 2013 +0100
+++ b/test-suite/tests/compact-0016-in.jsonld	Thu Jan 10 10:57:51 2013 +0100
@@ -14,9 +14,6 @@
           {
             "@id": "http://en.wikipedia.org/wiki/Berlin",
             "http://data.wikipedia.org/vocab#population": [ 3499879 ]
-          },
-          {
-            "@id": "http://data.wikipedia.org/snaks/ParisFact"
           }
         ]
       }
--- a/test-suite/tests/compact-0016-out.jsonld	Thu Jan 10 10:26:34 2013 +0100
+++ b/test-suite/tests/compact-0016-out.jsonld	Thu Jan 10 10:57:51 2013 +0100
@@ -14,9 +14,6 @@
         {
           "@id": "wp:Berlin",
           "wd:population": 3499879
-        },
-        {
-          "@id": "ws:ParisFact"
         }
       ],
       "wd:assertedBy": "Statistik Berlin/Brandenburg"
--- a/test-suite/tests/compact-0039-in.jsonld	Thu Jan 10 10:26:34 2013 +0100
+++ b/test-suite/tests/compact-0039-in.jsonld	Thu Jan 10 10:57:51 2013 +0100
@@ -3,7 +3,8 @@
      "@id": "http://example.com/graph/1",
      "@graph": [
        {
-          "@id": "http://example.com/node/1"
+          "@id": "http://example.com/node/1",
+          "http://example.com/property": [ { "@value": "property" } ]
        }
      ]
   }
--- a/test-suite/tests/compact-0039-out.jsonld	Thu Jan 10 10:26:34 2013 +0100
+++ b/test-suite/tests/compact-0039-out.jsonld	Thu Jan 10 10:57:51 2013 +0100
@@ -2,7 +2,8 @@
    "@id": "http://example.com/graph/1",
    "@graph": [
      {
-        "@id": "http://example.com/node/1"
+        "@id": "http://example.com/node/1",
+        "http://example.com/property": "property"
      }
    ]
 }
--- a/test-suite/tests/compact-manifest.jsonld	Thu Jan 10 10:26:34 2013 +0100
+++ b/test-suite/tests/compact-manifest.jsonld	Thu Jan 10 10:57:51 2013 +0100
@@ -8,7 +8,7 @@
   "sequence": [
     {
       "@type": ["test:TestCase", "jld:CompactTest"],
-      "name": "id",
+      "name": "drop free-floating nodes",
       "input": "compact-0001-in.jsonld",
       "context": "compact-0001-context.jsonld",
       "expect": "compact-0001-out.jsonld"
@@ -237,7 +237,7 @@
       "expect": "compact-0038-out.jsonld"
     }, {
       "@type": ["test:TestCase", "jld:CompactTest"],
-      "name": "Value of @graph is always an array, do not compact @id objects",
+      "name": "Value of @graph is always an array",
       "input": "compact-0039-in.jsonld",
       "context": "compact-0039-context.jsonld",
       "expect": "compact-0039-out.jsonld"
--- a/test-suite/tests/expand-0001-out.jsonld	Thu Jan 10 10:26:34 2013 +0100
+++ b/test-suite/tests/expand-0001-out.jsonld	Thu Jan 10 10:57:51 2013 +0100
@@ -1,1 +1,1 @@
-[{"@id": "http://example.org/test#example"}]
\ No newline at end of file
+[ ]
--- a/test-suite/tests/expand-0003-out.jsonld	Thu Jan 10 10:26:34 2013 +0100
+++ b/test-suite/tests/expand-0003-out.jsonld	Thu Jan 10 10:57:51 2013 +0100
@@ -1,3 +1,1 @@
-[{
-  "@id": "http://example.org/id"
-}]
+[ ]
--- a/test-suite/tests/expand-0019-out.jsonld	Thu Jan 10 10:26:34 2013 +0100
+++ b/test-suite/tests/expand-0019-out.jsonld	Thu Jan 10 10:57:51 2013 +0100
@@ -1,3 +1,1 @@
-[
-  { }
-]
+[ ]
--- a/test-suite/tests/expand-0021-in.jsonld	Thu Jan 10 10:26:34 2013 +0100
+++ b/test-suite/tests/expand-0021-in.jsonld	Thu Jan 10 10:57:51 2013 +0100
@@ -33,7 +33,8 @@
             "title": "Chapter Two"
           },
           {
-            "@id": "http://example.org/test#chapter3"
+            "@id": "http://example.org/test#chapter3",
+            "title": "Chapter Three"
           }
         ]
       }
--- a/test-suite/tests/expand-0021-out.jsonld	Thu Jan 10 10:26:34 2013 +0100
+++ b/test-suite/tests/expand-0021-out.jsonld	Thu Jan 10 10:57:51 2013 +0100
@@ -18,7 +18,10 @@
                 "http://purl.org/dc/elements/1.1/description": [ {"@value": "More fun"} ],
                 "http://purl.org/dc/elements/1.1/title": [ {"@value": "Chapter Two"} ]
               },
-              {"@id": "http://example.org/test#chapter3"}
+              {
+                "@id": "http://example.org/test#chapter3",
+                "http://purl.org/dc/elements/1.1/title": [ {"@value": "Chapter Three"} ]
+              }
             ]
           }
         ]
--- a/test-suite/tests/expand-manifest.jsonld	Thu Jan 10 10:26:34 2013 +0100
+++ b/test-suite/tests/expand-manifest.jsonld	Thu Jan 10 10:57:51 2013 +0100
@@ -8,7 +8,7 @@
   "sequence": [
     {
       "@type": ["test:TestCase", "jld:ExpandTest"],
-      "name": "id",
+      "name": "drop free-floating nodes",
       "input": "expand-0001-in.jsonld",
       "expect": "expand-0001-out.jsonld"
     }, {
--- a/test-suite/tests/flatten-0001-out.jsonld	Thu Jan 10 10:26:34 2013 +0100
+++ b/test-suite/tests/flatten-0001-out.jsonld	Thu Jan 10 10:57:51 2013 +0100
@@ -1,5 +1,1 @@
-[
-    {
-        "@id": "http://example.org/test#example"
-    }
-]
\ No newline at end of file
+[ ]
--- a/test-suite/tests/flatten-0003-out.jsonld	Thu Jan 10 10:26:34 2013 +0100
+++ b/test-suite/tests/flatten-0003-out.jsonld	Thu Jan 10 10:57:51 2013 +0100
@@ -1,5 +1,1 @@
-[
-    {
-        "@id": "http://example.org/id"
-    }
-]
\ No newline at end of file
+[ ]
--- a/test-suite/tests/flatten-0019-out.jsonld	Thu Jan 10 10:26:34 2013 +0100
+++ b/test-suite/tests/flatten-0019-out.jsonld	Thu Jan 10 10:57:51 2013 +0100
@@ -1,5 +1,1 @@
-[
-    {
-        "@id": "_:t0"
-    }
-]
\ No newline at end of file
+[ ]
--- a/test-suite/tests/flatten-0021-in.jsonld	Thu Jan 10 10:26:34 2013 +0100
+++ b/test-suite/tests/flatten-0021-in.jsonld	Thu Jan 10 10:57:51 2013 +0100
@@ -33,7 +33,8 @@
             "title": "Chapter Two"
           },
           {
-            "@id": "http://example.org/test#chapter3"
+            "@id": "http://example.org/test#chapter3",
+            "title": "Chapter Three"
           }
         ]
       }
--- a/test-suite/tests/flatten-0021-out.jsonld	Thu Jan 10 10:26:34 2013 +0100
+++ b/test-suite/tests/flatten-0021-out.jsonld	Thu Jan 10 10:57:51 2013 +0100
@@ -92,8 +92,13 @@
                 ]
             },
             {
-                "@id": "http://example.org/test#chapter3"
+                "@id": "http://example.org/test#chapter3",
+                "http://purl.org/dc/elements/1.1/title": [
+                    {
+                        "@value": "Chapter Three"
+                    }
+                ]
             }
         ]
     }
-]
\ No newline at end of file
+]