Add statement that keywords can't be aliased to other keywords, add test
authorMarkus Lanthaler <mark_lanthaler@gmx.net>
Fri, 28 Dec 2012 17:54:27 +0100
changeset 1101 86285cad4fab
parent 1100 a13341a551ed
child 1102 19cc407a11e0
Add statement that keywords can't be aliased to other keywords, add test

This addresses the discussion in 51703b8eb554a190f5263172877ff21212d18075.

/cc @msporny
spec/latest/json-ld-syntax/index.html
test-suite/tests/compact-0045-context.jsonld
test-suite/tests/compact-0045-in.jsonld
test-suite/tests/compact-0045-out.jsonld
test-suite/tests/compact-manifest.jsonld
test-suite/tests/expand-0043-in.jsonld
test-suite/tests/expand-0043-out.jsonld
test-suite/tests/expand-manifest.jsonld
--- a/spec/latest/json-ld-syntax/index.html	Fri Dec 28 17:17:35 2012 +0100
+++ b/spec/latest/json-ld-syntax/index.html	Fri Dec 28 17:54:27 2012 +0100
@@ -2314,37 +2314,41 @@
 </section>
 
 <section>
-<h2>Aliasing Keywords</h2>
-
-<p>Each of the JSON-LD <tref title="keyword">keywords</tref>,
-except for <code>@context</code>, may be aliased to application-specific
-keywords. This feature allows legacy JSON content to be utilized
-by JSON-LD by re-using JSON keys that already exist in legacy documents.
-This feature also allows developers to design domain-specific implementations
-using only the JSON-LD <tref>context</tref>.</p>
-
-<pre class="example" data-transform="updateExample"
-     title="Aliasing keywords">
-<!--
-{
-  "@context":
+  <h2>Aliasing Keywords</h2>
+
+  <p>Each of the JSON-LD <tref title="keyword">keywords</tref>,
+    except for <code>@context</code>, may be aliased to application-specific
+    keywords. This feature allows legacy JSON content to be utilized
+    by JSON-LD by re-using JSON keys that already exist in legacy documents.
+    This feature also allows developers to design domain-specific implementations
+    using only the JSON-LD <tref>context</tref>.</p>
+
+  <pre class="example" data-transform="updateExample"
+       title="Aliasing keywords">
+  <!--
   {
-     ****"url": "@id"****,
-     ****"a": "@type"****,
-     "name": "http://schema.org/name"
-  },
-  "****url****": "http://example.com/about#gregg",
-  "****a****": "http://schema.org/Person",
-  "name": "Gregg Kellogg"
-}
--->
-</pre>
-
-<p>In the example above, the <code>@id</code> and <code>@type</code>
-<tref title="keyword">keywords</tref> have been given the aliases <strong>url</strong> and
-<strong>a</strong>, respectively.
-</p>
-
+    "@context":
+    {
+       ****"url": "@id"****,
+       ****"a": "@type"****,
+       "name": "http://schema.org/name"
+    },
+    "****url****": "http://example.com/about#gregg",
+    "****a****": "http://schema.org/Person",
+    "name": "Gregg Kellogg"
+  }
+  -->
+  </pre>
+
+  <p>In the example above, the <code>@id</code> and <code>@type</code>
+    <tref title="keyword">keywords</tref> have been given the aliases
+    <strong>url</strong> and <strong>a</strong>, respectively.</p>
+
+  <p>Since keywords cannot be re-defined, they can also not be aliased to
+    other keywords. In fact, every statement in the context having a keyword
+    as the member name (as in
+    <code style="white-space: nowrap">{ "@type": ... }</code>) will be
+    completely ignored when being processed.</p>
 </section>
 
 <section>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/compact-0045-context.jsonld	Fri Dec 28 17:54:27 2012 +0100
@@ -0,0 +1,5 @@
+{
+  "@context": {
+    "@type": "@id"
+  }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/compact-0045-in.jsonld	Fri Dec 28 17:54:27 2012 +0100
@@ -0,0 +1,5 @@
+[
+  {
+    "@type": [ "http://example.org/type" ]
+  }
+]
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/compact-0045-out.jsonld	Fri Dec 28 17:54:27 2012 +0100
@@ -0,0 +1,6 @@
+{
+  "@context": {
+    "@type": "@id"
+  },
+  "@type": "http://example.org/type"
+}
--- a/test-suite/tests/compact-manifest.jsonld	Fri Dec 28 17:17:35 2012 +0100
+++ b/test-suite/tests/compact-manifest.jsonld	Fri Dec 28 17:54:27 2012 +0100
@@ -271,6 +271,12 @@
       "input": "compact-0044-in.jsonld",
       "context": "compact-0044-context.jsonld",
       "expect": "compact-0044-out.jsonld"
+    }, {
+      "@type": ["test:TestCase", "jld:CompactTest"],
+      "name": "Keywords cannot be aliased to other keywords",
+      "input": "compact-0045-in.jsonld",
+      "context": "compact-0045-context.jsonld",
+      "expect": "compact-0045-out.jsonld"
     }
   ]
 }
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/expand-0043-in.jsonld	Fri Dec 28 17:54:27 2012 +0100
@@ -0,0 +1,6 @@
+{
+  "@context": {
+    "@type": "@id"
+  },
+  "@type": "http://example.org/type"
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/expand-0043-out.jsonld	Fri Dec 28 17:54:27 2012 +0100
@@ -0,0 +1,5 @@
+[
+  {
+    "@type": [ "http://example.org/type" ]
+  }
+]
--- a/test-suite/tests/expand-manifest.jsonld	Fri Dec 28 17:17:35 2012 +0100
+++ b/test-suite/tests/expand-manifest.jsonld	Fri Dec 28 17:54:27 2012 +0100
@@ -216,6 +216,11 @@
       "name": "Keep empty arrays when expanding property generators",
       "input": "expand-0042-in.jsonld",
       "expect": "expand-0042-out.jsonld"
+    }, {
+      "@type": ["test:TestCase", "jld:ExpandTest"],
+      "name": "Keywords cannot be aliased to other keywords",
+      "input": "expand-0043-in.jsonld",
+      "expect": "expand-0043-out.jsonld"
     }
   ]
 }