Skip to content

Commit 41cc618

Browse files
committed
Allow @type to be duplicated, either through aliasing, or nesting.
1 parent 74781a0 commit 41cc618

File tree

11 files changed

+128
-37
lines changed

11 files changed

+128
-37
lines changed

index.html

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1971,7 +1971,8 @@ <h3>Algorithm</h3>
19711971
<li class="changed">Set <var>type-scoped context</var> to <var>active context</var>.
19721972
This is used for expanding values that may be relevant to any previous
19731973
<a>type-scoped context</a>.</li>
1974-
<li class="changed">For each <var>key</var>/<var>value</var> pair in <var>element</var>
1974+
<li class="changed">For each <var>key</var> and <var>value</var> in <var>element</var>
1975+
ordered lexicographically by <var>key</var>
19751976
where <var>key</var> expands to <code>@type</code> using the
19761977
<a href="#iri-expansion">IRI Expansion algorithm</a>,
19771978
passing <var>active context</var>, <var>key</var> for
@@ -1991,8 +1992,8 @@ <h3>Algorithm</h3>
19911992
</li>
19921993
<li>Initialize two empty <a class="changed">maps</a>, <var>result</var>
19931994
<span class="changed">and <var>nests</var>.
1994-
Set <var>input type</var> to the last value of any <a>entry</a> of <var>element</var>
1995-
expanding to <code>@type</code></span>.
1995+
Set <var>input type</var> to the last value of the first <a>entry</a> in <var>element</var>
1996+
expanding to <code>@type</code>, ordering <a>entries</a> lexicographically by key</span>.
19961997
</li>
19971998
<li id="alg-expand-each-key-value">
19981999
For each <var>key</var> and <var>value</var> in <var>element</var>,
@@ -2012,8 +2013,9 @@ <h3>Algorithm</h3>
20122013
<li>If <var>active property</var> equals <code>@reverse</code>, an
20132014
<a data-link-for="JsonLdErrorCode">invalid reverse property map</a>
20142015
error has been detected and processing is aborted.</li>
2015-
<li>If <var>result</var> has already an <var>expanded property</var> <a>entry</a>, a
2016-
<a data-link-for="JsonLdErrorCode">colliding keywords</a>
2016+
<li>If <var>result</var> has already an <var>expanded property</var> <a>entry</a>,
2017+
<span class="changed">other than `@type`</span>,
2018+
a <a data-link-for="JsonLdErrorCode">colliding keywords</a>
20172019
error has been detected and processing is aborted.</li>
20182020
<li>If <var>expanded property</var> is <code>@id</code> and
20192021
<var>value</var> is not a <a>string</a>, an
@@ -2041,6 +2043,9 @@ <h3>Algorithm</h3>
20412043
<code>true</code> for <var>vocab</var>,
20422044
and <code>true</code> for <var>document relative</var> to expand the <var>value</var>
20432045
or each of its items.
2046+
<span class="changed">If <var>result</var> already has an entry for `@type`,
2047+
prepend the value of `@type` in <var>result</var> to <var>expanded value</var>,
2048+
transforming it into an <a>array</a>, if necessary.</span>
20442049
<span class="changed">
20452050
When the <a data-link-for="JsonLdOptions">frameExpansion</a> flag is set, <var>value</var>
20462051
may also be an empty <a>map</a>.
@@ -2368,7 +2373,7 @@ <h3>Algorithm</h3>
23682373
in <var>element</var>, ensuring that it is an <a>array</a>.</li>
23692374
<li>For each <var>nested value</var> in <var>nested values</var>:
23702375
<ol>
2371-
<li>If <var>nested value</var> is not a <a class="changed">map</a>, or any key within
2376+
<li>If <var>nested value</var> is not a <a>map</a>, or any key within
23722377
<var>nested value</var> expands to <code>@value</code>, an
23732378
<a data-link-for="JsonLdErrorCode">invalid @nest value</a> error
23742379
has been detected and processing is aborted.</li>
@@ -6331,6 +6336,8 @@ <h2>Changes since JSON-LD Community Group Final Report</h2>
63316336
<li>A context may contain a <code>@import</code> <a>entry</a> used to reference a remote context
63326337
within a context, allowing <code>JSON-LD 1.1</code> features to be added to contexts originally
63336338
authored for <code>JSON-LD 1.0</code>.</li>
6339+
<li>The <a data-link-for="JsonLdErrorCode">colliding keywords</a> error is not issued for `@type`;
6340+
instead, previous values of `@type` are prepended to any new values, when expanding.</li>
63346341
</ul>
63356342
</section>
63366343

tests/expand-manifest.jsonld

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -840,6 +840,14 @@
840840
"purpose": "Expand with context including JavaScript Object property names",
841841
"input": "expand/0113-in.jsonld",
842842
"expect": "expand/0113-out.jsonld"
843+
}, {
844+
"@id": "#t0114",
845+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
846+
"name": "Expansion allows multiple properties expanding to @type",
847+
"purpose": "An exception for the colliding keywords error is made for @type",
848+
"input": "expand/0114-in.jsonld",
849+
"expect": "expand/0114-out.jsonld",
850+
"option": {"specVersion": "json-ld-1.1"}
843851
}, {
844852
"@id": "#tc001",
845853
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
@@ -2083,6 +2091,14 @@
20832091
"input": "expand/n007-in.jsonld",
20842092
"expect": "expand/n007-out.jsonld",
20852093
"option": {"processingMode": "json-ld-1.1", "specVersion": "json-ld-1.1"}
2094+
}, {
2095+
"@id": "#tn008",
2096+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
2097+
"name": "Multiple keys may mapping to @type when nesting",
2098+
"purpose": "Expansion using @nest",
2099+
"input": "expand/n008-in.jsonld",
2100+
"expect": "expand/n008-out.jsonld",
2101+
"option": {"processingMode": "json-ld-1.1", "specVersion": "json-ld-1.1"}
20862102
}, {
20872103
"@id": "#tp001",
20882104
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],

tests/expand/0114-in.jsonld

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example.org/",
4+
"type1": "@type",
5+
"type2": "@type"
6+
},
7+
"type1": "Type1",
8+
"type2": "Type2"
9+
}

tests/expand/0114-out.jsonld

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[{
2+
"@type": ["http://example.org/Type1", "http://example.org/Type2"]
3+
}]

tests/expand/n008-in.jsonld

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example.org/",
4+
"nest": "@nest"
5+
},
6+
"p1": "v1",
7+
"nest": [
8+
{"@type": "T1"},
9+
{"@type": "T2"}
10+
]
11+
}

tests/expand/n008-out.jsonld

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[{
2+
"@type": ["http://example.org/T1", "http://example.org/T2"],
3+
"http://example.org/p1": [{"@value": "v1"}]
4+
}]

tests/toRdf-manifest.jsonld

Lines changed: 47 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,6 +1231,14 @@
12311231
"purpose": "Expand with context including JavaScript Object property names",
12321232
"input": "toRdf/e113-in.jsonld",
12331233
"expect": "toRdf/e113-out.nq"
1234+
}, {
1235+
"@id": "#te114",
1236+
"@type": ["jld:PositiveEvaluationTest", "jld:ToRDFTest"],
1237+
"name": "Expansion allows multiple properties expanding to @type",
1238+
"purpose": "An exception for the colliding keywords error is made for @type",
1239+
"input": "toRdf/e114-in.jsonld",
1240+
"expect": "toRdf/e114-out.nq",
1241+
"option": {"specVersion": "json-ld-1.1"}
12341242
}, {
12351243
"@id": "#th001",
12361244
"@type": ["jld:PositiveEvaluationTest", "jld:ToRDFTest"],
@@ -1640,37 +1648,37 @@
16401648
"expect": "toRdf/m016-out.nq",
16411649
"option": {"processingMode": "json-ld-1.1", "specVersion": "json-ld-1.1"}
16421650
}, {
1643-
"@id": "#tm017",
1644-
"@type": ["jld:PositiveEvaluationTest", "jld:ToRDFTest"],
1645-
"name": "string value of type map expands to node reference",
1646-
"purpose": "index on @type",
1647-
"input": "toRdf/m017-in.jsonld",
1648-
"expect": "toRdf/m017-out.nq",
1649-
"option": {"processingMode": "json-ld-1.1", "specVersion": "json-ld-1.1"}
1650-
}, {
1651-
"@id": "#tm018",
1652-
"@type": ["jld:PositiveEvaluationTest", "jld:ToRDFTest"],
1653-
"name": "string value of type map expands to node reference with @type: @id",
1654-
"purpose": "index on @type",
1655-
"input": "toRdf/m018-in.jsonld",
1656-
"expect": "toRdf/m018-out.nq",
1657-
"option": {"processingMode": "json-ld-1.1", "specVersion": "json-ld-1.1"}
1658-
}, {
1659-
"@id": "#tm019",
1660-
"@type": ["jld:PositiveEvaluationTest", "jld:ToRDFTest"],
1661-
"name": "string value of type map expands to node reference with @type: @vocab",
1662-
"purpose": "index on @type",
1663-
"input": "toRdf/m019-in.jsonld",
1664-
"expect": "toRdf/m019-out.nq",
1665-
"option": {"processingMode": "json-ld-1.1", "specVersion": "json-ld-1.1"}
1666-
}, {
1667-
"@id": "#tm020",
1668-
"@type": ["jld:NegativeEvaluationTest", "jld:ToRDFTest"],
1669-
"name": "string value of type map must not be a literal",
1670-
"purpose": "index on @type",
1671-
"input": "toRdf/m020-in.jsonld",
1672-
"expect": "invalid type mapping",
1673-
"option": {"processingMode": "json-ld-1.1", "specVersion": "json-ld-1.1"}
1651+
"@id": "#tm017",
1652+
"@type": ["jld:PositiveEvaluationTest", "jld:ToRDFTest"],
1653+
"name": "string value of type map expands to node reference",
1654+
"purpose": "index on @type",
1655+
"input": "toRdf/m017-in.jsonld",
1656+
"expect": "toRdf/m017-out.nq",
1657+
"option": {"processingMode": "json-ld-1.1", "specVersion": "json-ld-1.1"}
1658+
}, {
1659+
"@id": "#tm018",
1660+
"@type": ["jld:PositiveEvaluationTest", "jld:ToRDFTest"],
1661+
"name": "string value of type map expands to node reference with @type: @id",
1662+
"purpose": "index on @type",
1663+
"input": "toRdf/m018-in.jsonld",
1664+
"expect": "toRdf/m018-out.nq",
1665+
"option": {"processingMode": "json-ld-1.1", "specVersion": "json-ld-1.1"}
1666+
}, {
1667+
"@id": "#tm019",
1668+
"@type": ["jld:PositiveEvaluationTest", "jld:ToRDFTest"],
1669+
"name": "string value of type map expands to node reference with @type: @vocab",
1670+
"purpose": "index on @type",
1671+
"input": "toRdf/m019-in.jsonld",
1672+
"expect": "toRdf/m019-out.nq",
1673+
"option": {"processingMode": "json-ld-1.1", "specVersion": "json-ld-1.1"}
1674+
}, {
1675+
"@id": "#tm020",
1676+
"@type": ["jld:NegativeEvaluationTest", "jld:ToRDFTest"],
1677+
"name": "string value of type map must not be a literal",
1678+
"purpose": "index on @type",
1679+
"input": "toRdf/m020-in.jsonld",
1680+
"expect": "invalid type mapping",
1681+
"option": {"processingMode": "json-ld-1.1", "specVersion": "json-ld-1.1"}
16741682
}, {
16751683
"@id": "#tn001",
16761684
"@type": ["jld:PositiveEvaluationTest", "jld:ToRDFTest"],
@@ -1727,6 +1735,14 @@
17271735
"input": "toRdf/n007-in.jsonld",
17281736
"expect": "toRdf/n007-out.nq",
17291737
"option": {"processingMode": "json-ld-1.1", "specVersion": "json-ld-1.1"}
1738+
}, {
1739+
"@id": "#tn008",
1740+
"@type": ["jld:PositiveEvaluationTest", "jld:ToRDFTest"],
1741+
"name": "Multiple keys may mapping to @type when nesting",
1742+
"purpose": "Expansion using @nest",
1743+
"input": "toRdf/n008-in.jsonld",
1744+
"expect": "toRdf/n008-out.nq",
1745+
"option": {"processingMode": "json-ld-1.1", "specVersion": "json-ld-1.1"}
17301746
}, {
17311747
"@id": "#tnt01",
17321748
"@type": ["jld:PositiveSyntaxTest", "jld:ToRDFTest"],

tests/toRdf/e114-in.jsonld

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example.org/",
4+
"type1": "@type",
5+
"type2": "@type"
6+
},
7+
"type1": "Type1",
8+
"type2": "Type2"
9+
}

tests/toRdf/e114-out.nq

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
_:b0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/Type1> .
2+
_:b0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://example.org/Type2> .

tests/toRdf/n008-in.jsonld

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example.org/",
4+
"nest": "@nest"
5+
},
6+
"p1": "v1",
7+
"nest": [
8+
{"@type": "T1"},
9+
{"@type": "T2"}
10+
]
11+
}

0 commit comments

Comments
 (0)