Skip to content

Commit f2b62f6

Browse files
committed
@container: @type implies and requires that @type not be a literal.
Also, fix compaction of type maps to have string values instead of node references. Fixes #121.
1 parent 61eb0a6 commit f2b62f6

29 files changed

+286
-9
lines changed

index.html

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1577,6 +1577,14 @@ <h3>Algorithm</h3>
15771577
has been detected and processing is aborted.</li>
15781578
<li>Set the <a>container mapping</a> of <var>definition</var> to
15791579
<var>container</var>.</li>
1580+
<li class="changed">If <a>container mapping</a> is `@type`:
1581+
<ol>
1582+
<li>If <var>type mapping</var> in <var>definition</var> is undefined, set it to `@id`.</li>
1583+
<li>If <var>type mapping</var> in <var>definition</var> is neither `@id` nor `@vocab`,
1584+
an <a data-link-for="JsonLdErrorCode">invalid type mapping</a>
1585+
error has been detected and processing is aborted.</li>
1586+
</ol>
1587+
</li>
15801588
</ol>
15811589
</li>
15821590
<li class="changed">If <var>value</var> contains the <a>entry</a> <code>@index</code>:
@@ -3097,13 +3105,26 @@ <h3>Algorithm</h3>
30973105
<li class="changed">Otherwise, if <var>container</var> includes <code>@id</code>, set
30983106
<var>map key</var> to the value of <var>container key</var> in
30993107
<var>compacted item</var> and remove <var>container key</var> from <var>compacted item</var>.</li>
3100-
<li class="changed">Otherwise, if <var>container</var> is <code>@type</code>,
3101-
set <var>map key</var> to the first value of <var>container key</var> in <var>compacted item</var>, if any.
3102-
If there are remaining values in <var>compacted item</var>
3103-
for <var>container key</var>, set the value of
3104-
<var>container key</var> in <var>compacted item</var>
3105-
to those remaining values. Otherwise, remove that
3106-
<a>entry</a> from <var>compacted item</var>.</li>
3108+
<li class="changed">Otherwise, if <var>container</var> is <code>@type</code>:
3109+
<ol>
3110+
<li>Set <var>map key</var> to the first value of <var>container key</var> in <var>compacted item</var>, if any.</li>
3111+
<li>If there are remaining values in <var>compacted item</var>
3112+
for <var>container key</var>, set the value of
3113+
<var>container key</var> in <var>compacted item</var>
3114+
to those remaining values.</li>
3115+
<li>Otherwise, remove that <a>entry</a> from <var>compacted item</var>.</li>
3116+
<li>If <var>compacted item</var> contains a single <a>entry</a> with a key expanding
3117+
to `@id`, set <var>compacted item</var>
3118+
to the result of using
3119+
this algorithm recursively, passing
3120+
<var>active context</var>, <var>inverse context</var>,
3121+
<var>item active property</var> for <var>active property</var>,
3122+
and a <a>map</a> composed of the single <a>entry</a> for `@id` from <var>expanded item</var> for <var>element</var>.
3123+
<!-- Note: This will result in a string value, rather than a node object,
3124+
because of either the implicit or explicit `@type` of `@id` or `@vocab` on <var>item active property</var>. -->
3125+
</li>
3126+
</ol>
3127+
</li>
31073128
<li class="changed">If <var>compacted item</var> is not an
31083129
<a>array</a> and <var>as array</var> is <code>true</code>,
31093130
set <var>compacted item</var> to an <a>array</a> containing that value.</li>

tests/compact-manifest.jsonld

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,6 +1580,33 @@
15801580
"context": "compact/m019-context.jsonld",
15811581
"expect": "compact/m019-out.jsonld",
15821582
"option": {"processingMode": "json-ld-1.1", "specVersion": "json-ld-1.1"}
1583+
}, {
1584+
"@id": "#tm020",
1585+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
1586+
"name": "node reference compacts to string value of type map",
1587+
"purpose": "index on @type",
1588+
"input": "compact/m020-in.jsonld",
1589+
"context": "compact/m020-context.jsonld",
1590+
"expect": "compact/m020-out.jsonld",
1591+
"option": {"processingMode": "json-ld-1.1", "specVersion": "json-ld-1.1"}
1592+
}, {
1593+
"@id": "#tm021",
1594+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
1595+
"name": "node reference compacts to string value of type map with @type: @id",
1596+
"purpose": "index on @type",
1597+
"input": "compact/m021-in.jsonld",
1598+
"context": "compact/m021-context.jsonld",
1599+
"expect": "compact/m021-out.jsonld",
1600+
"option": {"processingMode": "json-ld-1.1", "specVersion": "json-ld-1.1"}
1601+
}, {
1602+
"@id": "#tm022",
1603+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
1604+
"name": "node reference compacts to string value of type map with @type: @vocab",
1605+
"purpose": "index on @type",
1606+
"input": "compact/m022-in.jsonld",
1607+
"context": "compact/m022-context.jsonld",
1608+
"expect": "compact/m022-out.jsonld",
1609+
"option": {"processingMode": "json-ld-1.1", "specVersion": "json-ld-1.1"}
15831610
}, {
15841611
"@id": "#tn001",
15851612
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],

tests/compact/m020-context.jsonld

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"@vocab": "http://example.org/ns/",
5+
"@base": "http://example.org/base/",
6+
"foo": { "@container": "@type" }
7+
}
8+
}

tests/compact/m020-in.jsonld

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[{
2+
"http://example.org/ns/foo": [{
3+
"@id": "http://example.org/base/baz",
4+
"@type": [ "http://example.org/ns/bar" ]
5+
}]
6+
}]

tests/compact/m020-out.jsonld

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"@vocab": "http://example.org/ns/",
5+
"@base": "http://example.org/base/",
6+
"foo": { "@container": "@type" }
7+
},
8+
"foo": {"bar": "baz"}
9+
}

tests/compact/m021-context.jsonld

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"@vocab": "http://example.org/ns/",
5+
"@base": "http://example.org/base/",
6+
"foo": { "@type": "@id", "@container": "@type" }
7+
}
8+
}

tests/compact/m021-in.jsonld

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[{
2+
"http://example.org/ns/foo": [{
3+
"@id": "http://example.org/base/baz",
4+
"@type": [ "http://example.org/ns/bar" ]
5+
}]
6+
}]

tests/compact/m021-out.jsonld

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"@vocab": "http://example.org/ns/",
5+
"@base": "http://example.org/base/",
6+
"foo": { "@type": "@id", "@container": "@type" }
7+
},
8+
"foo": {"bar": "baz"}
9+
}

tests/compact/m022-context.jsonld

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"@vocab": "http://example.org/ns/",
5+
"@base": "http://example.org/base/",
6+
"foo": { "@type": "@vocab", "@container": "@type" }
7+
}
8+
}

tests/compact/m022-in.jsonld

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[{
2+
"http://example.org/ns/foo": [{
3+
"@id": "http://example.org/ns/baz",
4+
"@type": [ "http://example.org/ns/bar" ]
5+
}]
6+
}]

0 commit comments

Comments
 (0)