Treat reverse term definitions more like regular definitions
authorMarkus Lanthaler <mark_lanthaler@gmx.net>
Tue, 11 Jun 2013 18:36:35 +0200
changeset 1719 39e9b87c3eb5
parent 1716 8931799756e6
child 1720 b79a3438f984
Treat reverse term definitions more like regular definitions

This addresses #253
spec/latest/json-ld-api/index.html
spec/latest/json-ld/index.html
test-suite/tests/compact-0035-context.jsonld
test-suite/tests/compact-0035-out.jsonld
test-suite/tests/compact-0050-context.jsonld
test-suite/tests/compact-0050-in.jsonld
test-suite/tests/compact-0050-out.jsonld
test-suite/tests/compact-0068-context.jsonld
test-suite/tests/compact-0068-in.jsonld
test-suite/tests/compact-0068-out.jsonld
test-suite/tests/compact-0069-context.jsonld
test-suite/tests/compact-0069-in.jsonld
test-suite/tests/compact-0069-out.jsonld
test-suite/tests/compact-manifest.jsonld
test-suite/tests/expand-0049-in.jsonld
test-suite/tests/toRdf-0089-in.jsonld
--- a/spec/latest/json-ld-api/index.html	Mon Jun 10 14:02:34 2013 -0400
+++ b/spec/latest/json-ld-api/index.html	Tue Jun 11 18:36:35 2013 +0200
@@ -1079,10 +1079,27 @@
           <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>
         <li>Create a new <tref>term definition</tref>, <i>definition</i>.</li>
+        <li>If <i>value</i> contains the key <code>@type</code>:
+          <ol class="algorithm">
+            <li>Initialize <i>type</i> to the value associated with the
+              <code>@type</code> key, which must be a <tref>string</tref>. Otherwise, an
+              <code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-type-mapping">invalid type mapping</a></code>
+              error has been detected and processing is aborted.</li>
+            <li>Set <i>type</i> to the result of using the
+              <a href="#iri-expansion">IRI Expansion algorithm</a>, passing
+              <tref>active context</tref>, <i>type</i> for <i>value</i>,
+              <tref>true</tref> for <i>vocab</i>,
+              <tref>false</tref> for <i>document relative</i>,
+              <tref>local context</tref>, and <i>defined</i>. If the expanded <i>type</i> is
+              neither <code>@id</code>, nor <code>@vocab</code>, nor an <tref>absolute IRI</tref>, an
+              <code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-type-mapping">invalid type mapping</a></code>
+              error has been detected and processing is aborted.</li>
+            <li>Set the <tref>type mapping</tref> for <i>definition</i> to <i>type</i>.</li>
+          </ol>
+        </li>
         <li>If <i>value</i> contains the key <code>@reverse</code>:
           <ol class="algorithm">
-            <li>If <i>value</i> contains an <code>@id</code>, an
-              <code>@type</code>, or an <code>@language</code>, member, an
+            <li>If <i>value</i> contains an <code>@id</code>, member, an
               <code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-reverse-property">invalid reverse property</a></code>
               error has been detected and processing is aborted.</li>
             <li>If the value associated with the <code>@reverse</code> key
@@ -1099,14 +1116,12 @@
               colon (<code>:</code>), an
               <code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-IRI-mapping">invalid IRI mapping</a></code>
               error has been detected and processing is aborted.</li>
-            <li>Set the <tref>type mapping</tref> of <i>definition</i> to
-              <code>@id</code>.</li>
             <li>If <i>value</i> contains an <code>@container</code> member,
               set the <tref>container mapping</tref> of <i>definition</i>
-              to <code>@index</code> if that is the value of the
-              <code>@container</code> member; otherwise an
+              to its value; if its value is neither <code>@set</code>, nor
+              <code>@index</code>, nor <tref>null</tref>, an
               <code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-reverse-property">invalid reverse property</a></code>
-              error has been detected (reverse properties only support
+              error has been detected (reverse properties only support set- and
               index-containers) and processing is aborted.</li>
             <li>Set the <tref>reverse property</tref> flag of <i>definition</i>
               to <tref>true</tref>.</li>
@@ -1159,24 +1174,6 @@
           If it does not have a <tref>vocabulary mapping</tref>, an
           <code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-IRI-mapping">invalid IRI mapping</a></code>
           error been detected and processing is aborted.</li>
-        <li>If <i>value</i> contains the key <code>@type</code>:
-          <ol class="algorithm">
-            <li>Initialize <i>type</i> to the value associated with the
-              <code>@type</code> key, which must be a <tref>string</tref>. Otherwise, an
-              <code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-type-mapping">invalid type mapping</a></code>
-              error has been detected and processing is aborted.</li>
-            <li>Set <i>type</i> to the result of using the
-              <a href="#iri-expansion">IRI Expansion algorithm</a>, passing
-              <tref>active context</tref>, <i>type</i> for <i>value</i>,
-              <tref>true</tref> for <i>vocab</i>,
-              <tref>false</tref> for <i>document relative</i>,
-              <tref>local context</tref>, and <i>defined</i>. If the expanded <i>type</i> is
-              neither <code>@id</code>, nor <code>@vocab</code>, nor an <tref>absolute IRI</tref>, an
-              <code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-type-mapping">invalid type mapping</a></code>
-              error has been detected and processing is aborted.</li>
-            <li>Set the <tref>type mapping</tref> for <i>definition</i> to <i>type</i>.</li>
-          </ol>
-        </li>
         <li>If <i>value</i> contains the key <code>@container</code>:
           <ol class="algorithm">
             <li>Initialize <i>container</i> to the value associated with the
@@ -1986,9 +1983,11 @@
                       <tref>active context</tref> indicates that <i>property</i> is
                       a <tref>reverse property</tref>
                       <ol class="algorithm">
-                        <li>If
+                        <li>If the <tref>term definition</tref> for <i>property</i> in
+                          the <tref>active context</tref> does not have a
+                          <tref>container mapping</tref> of <code>@set</code>,
                           <code class="idlMemberName"><a href="#widl-JsonLdOptions-compactArrays">compactArrays</a></code>
-                          is <tref>false</tref> and <i>value</i> is not an
+                          is <tref>false</tref>, and <i>value</i> is not an
                           <tref>array</tref>, set <i>value</i> to a new
                           <tref>array</tref> containing only <i>value</i>.</li>
                         <li>If <i>property</i> is not a member of
--- a/spec/latest/json-ld/index.html	Mon Jun 10 14:02:34 2013 -0400
+++ b/spec/latest/json-ld/index.html	Tue Jun 11 18:36:35 2013 +0200
@@ -3085,9 +3085,9 @@
     <tref>expanded term definition</tref> SHOULD NOT contain any other keys.</p>
 
   <p>If an <tref>expanded term definition</tref> has an <code>@reverse</code> member,
-    <code>@id</code>, <code>@type</code>, and <code>@language</code> are not allowed.
-    If an <code>@container</code> member exists, its value MUST be <tref>null</tref>
-    or <code>@index</code>.</p>
+    it MUST NOT have an <code>@id</code> member at the same time. If an
+    <code>@container</code> member exists, its value MUST be <tref>null</tref>,
+    <code>@set</code>, or <code>@index</code>.</p>
 
   <p>If the term being defined is not a <tref>compact IRI</tref> or
     <tref>absolute IRI</tref> and the <tref>active context</tref> does not have an
--- a/test-suite/tests/compact-0035-context.jsonld	Mon Jun 10 14:02:34 2013 -0400
+++ b/test-suite/tests/compact-0035-context.jsonld	Tue Jun 11 18:36:35 2013 +0200
@@ -1,6 +1,6 @@
 {
   "@context": {
     "name": "http://xmlns.com/foaf/0.1/name",
-    "isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows" }
+    "isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows", "@type": "@id" }
   }
 }
--- a/test-suite/tests/compact-0035-out.jsonld	Mon Jun 10 14:02:34 2013 -0400
+++ b/test-suite/tests/compact-0035-out.jsonld	Tue Jun 11 18:36:35 2013 +0200
@@ -1,7 +1,7 @@
 {
   "@context": {
     "name": "http://xmlns.com/foaf/0.1/name",
-    "isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows" }
+    "isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows", "@type": "@id" }
   },
   "@id": "http://example.com/people/markus",
   "name": "Markus Lanthaler",
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/compact-0050-context.jsonld	Tue Jun 11 18:36:35 2013 +0200
@@ -0,0 +1,6 @@
+{
+  "@context": {
+    "name": "http://xmlns.com/foaf/0.1/name",
+    "isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows" }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/compact-0050-in.jsonld	Tue Jun 11 18:36:35 2013 +0200
@@ -0,0 +1,16 @@
+[
+  {
+    "@id": "http://example.com/people/markus",
+    "@reverse": {
+      "http://xmlns.com/foaf/0.1/knows": [
+        {
+          "@id": "http://example.com/people/dave"
+        },
+        {
+          "@id": "http://example.com/people/gregg"
+        }
+      ]
+    },
+    "http://xmlns.com/foaf/0.1/name": [ { "@value": "Markus Lanthaler" } ]
+  }
+]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/compact-0050-out.jsonld	Tue Jun 11 18:36:35 2013 +0200
@@ -0,0 +1,12 @@
+{
+  "@context": {
+    "name": "http://xmlns.com/foaf/0.1/name",
+    "isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows" }
+  },
+  "@id": "http://example.com/people/markus",
+  "name": "Markus Lanthaler",
+  "isKnownBy": [
+    { "@id": "http://example.com/people/dave" },
+    { "@id": "http://example.com/people/gregg" }
+  ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/compact-0068-context.jsonld	Tue Jun 11 18:36:35 2013 +0200
@@ -0,0 +1,6 @@
+{
+  "@context": {
+    "name": "http://xmlns.com/foaf/0.1/name",
+    "isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows", "@container": "@set" }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/compact-0068-in.jsonld	Tue Jun 11 18:36:35 2013 +0200
@@ -0,0 +1,13 @@
+[
+  {
+    "@id": "http://example.com/people/markus",
+    "@reverse": {
+      "http://xmlns.com/foaf/0.1/knows": [
+        {
+          "@id": "http://example.com/people/dave"
+        }
+      ]
+    },
+    "http://xmlns.com/foaf/0.1/name": [ { "@value": "Markus Lanthaler" } ]
+  }
+]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/compact-0068-out.jsonld	Tue Jun 11 18:36:35 2013 +0200
@@ -0,0 +1,11 @@
+{
+  "@context": {
+    "name": "http://xmlns.com/foaf/0.1/name",
+    "isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows", "@container": "@set" }
+  },
+  "@id": "http://example.com/people/markus",
+  "name": "Markus Lanthaler",
+  "isKnownBy": [
+    { "@id": "http://example.com/people/dave" }
+  ]
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/compact-0069-context.jsonld	Tue Jun 11 18:36:35 2013 +0200
@@ -0,0 +1,6 @@
+{
+  "@context": {
+    "name": "http://xmlns.com/foaf/0.1/name",
+    "isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows", "@container": "@set" }
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/compact-0069-in.jsonld	Tue Jun 11 18:36:35 2013 +0200
@@ -0,0 +1,13 @@
+[
+  {
+    "@id": "http://example.com/people/markus",
+    "@reverse": {
+      "http://xmlns.com/foaf/0.1/knows": [
+        {
+          "@id": "http://example.com/people/dave"
+        }
+      ]
+    },
+    "http://xmlns.com/foaf/0.1/name": [ { "@value": "Markus Lanthaler" } ]
+  }
+]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/compact-0069-out.jsonld	Tue Jun 11 18:36:35 2013 +0200
@@ -0,0 +1,11 @@
+{
+  "@context": {
+    "name": "http://xmlns.com/foaf/0.1/name",
+    "isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows", "@container": "@set" }
+  },
+  "@id": "http://example.com/people/markus",
+  "name": "Markus Lanthaler",
+  "isKnownBy": [
+    { "@id": "http://example.com/people/dave" }
+  ]
+}
--- a/test-suite/tests/compact-manifest.jsonld	Mon Jun 10 14:02:34 2013 -0400
+++ b/test-suite/tests/compact-manifest.jsonld	Tue Jun 11 18:36:35 2013 +0200
@@ -247,7 +247,7 @@
     }, {
       "@id": "#t0035",
       "@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
-      "name": "Compact pure node references to strings for reverse properties",
+      "name": "Compact node references to strings for reverse properties using @type: @id",
       "input": "compact-0035-in.jsonld",
       "context": "compact-0035-context.jsonld",
       "expect": "compact-0035-out.jsonld"
@@ -350,6 +350,13 @@
       "context": "compact-0049-context.jsonld",
       "expect": "compact-0049-out.jsonld"
     }, {
+      "@id": "#t0050",
+      "@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
+      "name": "Node references in reverse properties are not compacted to strings without explicit type-coercion",
+      "input": "compact-0050-in.jsonld",
+      "context": "compact-0050-context.jsonld",
+      "expect": "compact-0050-out.jsonld"
+    }, {
       "@id": "#t0051",
       "@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
       "name": "Round tripping @list with scalar",
@@ -468,6 +475,20 @@
       "input": "compact-0067-in.jsonld",
       "context": "compact-0067-context.jsonld",
       "expect": "compact-0067-out.jsonld"
+    }, {
+      "@id": "#t0068",
+      "@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
+      "name": "Single values of reverse properties are compacted as values of ordinary properties",
+      "input": "compact-0068-in.jsonld",
+      "context": "compact-0068-context.jsonld",
+      "expect": "compact-0068-out.jsonld"
+    }, {
+      "@id": "#t0069",
+      "@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
+      "name": "Single values are kept in array form for reverse properties if the container is to @set",
+      "input": "compact-0069-in.jsonld",
+      "context": "compact-0069-context.jsonld",
+      "expect": "compact-0069-out.jsonld"
     }
   ]
 }
--- a/test-suite/tests/expand-0049-in.jsonld	Mon Jun 10 14:02:34 2013 -0400
+++ b/test-suite/tests/expand-0049-in.jsonld	Tue Jun 11 18:36:35 2013 +0200
@@ -1,7 +1,7 @@
 {
   "@context": {
     "name": "http://xmlns.com/foaf/0.1/name",
-    "isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows" }
+    "isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows", "@type": "@id" }
   },
   "@id": "http://example.com/people/markus",
   "name": "Markus Lanthaler",
--- a/test-suite/tests/toRdf-0089-in.jsonld	Mon Jun 10 14:02:34 2013 -0400
+++ b/test-suite/tests/toRdf-0089-in.jsonld	Tue Jun 11 18:36:35 2013 +0200
@@ -1,7 +1,7 @@
 {
   "@context": {
     "name": "http://xmlns.com/foaf/0.1/name",
-    "isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows" }
+    "isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows", "@type": "@id" }
   },
   "@id": "http://example.com/people/markus",
   "name": "Markus Lanthaler",