Skip to content

Commit 5da5e73

Browse files
committed
Algorithm updates and tests to allow @container: @set on @type or an alias in 1.1. Remains an error to redefine @type in 1.0.
For w3c/json-ld-syntax#34.
1 parent 651bc81 commit 5da5e73

13 files changed

+115
-26
lines changed

index.html

Lines changed: 33 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ <h2>Create Term Definition</h2>
11391139
<section class="informative">
11401140
<h3>Overview</h3>
11411141

1142-
<p><a>term definitions</a> are created by
1142+
<p><a>Term definitions</a> are created by
11431143
parsing the information in the given <a>local context</a> for the
11441144
given <a>term</a>. If the given <a>term</a> is a
11451145
<a>compact IRI</a>, it may omit an <a>IRI mapping</a> by
@@ -1179,14 +1179,21 @@ <h3>Algorithm</h3>
11791179
<li>Set the value associated with <var>defined</var>'s <var>term</var> <a>member</a> to
11801180
<code>false</code>. This indicates that the <a>term definition</a>
11811181
is now being created but is not yet complete.</li>
1182-
<li>Since <a>keywords</a> cannot be overridden,
1183-
<var>term</var> must not be a <a>keyword</a>. Otherwise, a
1182+
<li>Initialize <var>value</var> to a copy of the value associated with the <a>member</a>
1183+
<var>term</var> in <var>local context</var>.</li>
1184+
<li class="changed">If <a data-link-for="JsonLdOptions">processingMode</a>
1185+
is <code>json-ld-1.1</code>
1186+
and <var>term</var> is <code>@type</code>, <var>value</var>
1187+
MUST be a <a>dictionary</a> with the member <code>@container</code>
1188+
and value <code>@set</code>. Any other value means that a
1189+
<a data-link-for="JsonLdErrorCode">keyword redefinition</a> error has
1190+
been detected and processing is aborted.</li>
1191+
<li><span class="changed">Otherwise</span>, since <a>keywords</a> cannot be overridden,
1192+
<var>term</var> MUST NOT be a <a>keyword</a> and a
11841193
<a data-link-for="JsonLdErrorCode">keyword redefinition</a>
11851194
error has been detected and processing is aborted.</li>
11861195
<li>Remove any existing <a>term definition</a> for <var>term</var> in
11871196
<var>active context</var>.</li>
1188-
<li>Initialize <var>value</var> to a copy of the value associated with the <a>member</a>
1189-
<var>term</var> in <var>local context</var>.</li>
11901197
<li>If <var>value</var> is <code>null</code> or <var>value</var>
11911198
is a <a class="changed">dictionary</a> containing the key-value pair
11921199
<code>@id</code>-<code>null</code>, set the
@@ -1197,15 +1204,15 @@ <h3>Algorithm</h3>
11971204
to a <a class="changed">dictionary</a> consisting of a single <a>member</a> whose
11981205
key is <code>@id</code> and whose value is <var>value</var>.
11991206
<span class="changed">Set <var>simple term</var> to <code>true</code></span>.</li>
1200-
<li>Otherwise, <var>value</var> must be a <a class="changed">dictionary</a>, if not, an
1207+
<li>Otherwise, <var>value</var> MUST be a <a class="changed">dictionary</a>, if not, an
12011208
<a data-link-for="JsonLdErrorCode">invalid term definition</a>
12021209
error has been detected and processing is aborted.
12031210
<span class="changed">Set <var>simple term</var> to <code>false</code></span>.</li>
12041211
<li>Create a new <a>term definition</a>, <var>definition</var>.</li>
12051212
<li>If <var>value</var> contains the <a>member</a> <code>@type</code>:
12061213
<ol>
12071214
<li>Initialize <var>type</var> to the value associated with the
1208-
<code>@type</code> <a>member</a>, which must be a <a>string</a>. Otherwise, an
1215+
<code>@type</code> <a>member</a>, which MUST be a <a>string</a>. Otherwise, an
12091216
<a data-link-for="JsonLdErrorCode">invalid type mapping</a>
12101217
error has been detected and processing is aborted.</li>
12111218
<li>Set <var>type</var> to the result of using the
@@ -1297,6 +1304,8 @@ <h3>Algorithm</h3>
12971304
of <var>definition</var> to <var>term</var>.</li>
12981305
</ol>
12991306
</li>
1307+
<li class="changed">Otherwise, if term is <code>@type</code>, set the <a>IRI mapping</a>
1308+
of <var>definition</var> to <code>@type</code>.</li>
13001309
<li>Otherwise, if <var>active context</var> has a
13011310
<a>vocabulary mapping</a>, the <a>IRI mapping</a>
13021311
of <var>definition</var> is set to the result of concatenating the value
@@ -1307,7 +1316,7 @@ <h3>Algorithm</h3>
13071316
<li>If <var>value</var> contains the <a>member</a> <code>@container</code>:
13081317
<ol>
13091318
<li>Initialize <var>container</var> to the value associated with the
1310-
<code>@container</code> <a>member</a>, which must be either
1319+
<code>@container</code> <a>member</a>, which MUST be either
13111320
<code class="changed">@graph</code>,
13121321
<code class="changed">@id</code>,
13131322
<code>@index</code>,
@@ -1355,7 +1364,7 @@ <h3>Algorithm</h3>
13551364
does not contain the <a>member</a> <code>@type</code>:
13561365
<ol>
13571366
<li>Initialize <var>language</var> to the value associated with the
1358-
<code>@language</code> <a>member</a>, which must be either <code>null</code>
1367+
<code>@language</code> <a>member</a>, which MUST be either <code>null</code>
13591368
or a <a>string</a>. Otherwise, an
13601369
<a data-link-for="JsonLdErrorCode">invalid language mapping</a>
13611370
error has been detected and processing is aborted.</li>
@@ -1370,8 +1379,8 @@ <h3>Algorithm</h3>
13701379
<a data-link-for="JsonLdErrorCode">invalid term definition</a>
13711380
has been detected and processing is aborted.</li>
13721381
<li>Initialize <a>nest value</a> in <var>definition</var> to the value associated with the
1373-
<code>@nest</code> <a>member</a>, which must be a <a>string</a> and
1374-
must not be a keyword other than <code>@nest</code>. Otherwise, an
1382+
<code>@nest</code> <a>member</a>, which MUST be a <a>string</a> and
1383+
MUST NOT be a keyword other than <code>@nest</code>. Otherwise, an
13751384
<a data-link-for="JsonLdErrorCode">invalid @nest value</a>
13761385
error has been detected and processing is aborted.</li>
13771386
</ol>
@@ -1383,7 +1392,7 @@ <h3>Algorithm</h3>
13831392
<a data-link-for="JsonLdErrorCode">invalid term definition</a>
13841393
has been detected and processing is aborted.</li>
13851394
<li>Initialize the <a>prefix flag</a> to the value associated with the
1386-
<code>@prefix</code> <a>member</a>, which must be a <a>boolean</a>. Otherwise, an
1395+
<code>@prefix</code> <a>member</a>, which MUST be a <a>boolean</a>. Otherwise, an
13871396
<a data-link-for="JsonLdErrorCode">invalid @prefix value</a>
13881397
error has been detected and processing is aborted.</li>
13891398
</ol>
@@ -2412,6 +2421,12 @@ <h3>Algorithm</h3>
24122421
passing <var>active context</var>, <var>inverse context</var>,
24132422
<var>expanded property</var> for <var>var</var>,
24142423
and <code>true</code> for <var>vocab</var>.</li>
2424+
<li class="changed">If <a>processing mode</a> is <code>json-ld-1.1</code>,
2425+
<var>element</var> does not have an <code>@value</code> member,
2426+
<var>expanded property</var> is <code>@type</code>,
2427+
and the <a>term definition</a> for <var>alias</var> in the
2428+
<var>active context</var> has a <a>container mapping</a> including <code>@set</code>,
2429+
ensure that <var>compacted value</var> is an <a>array</a>.</li>
24152430
<li>Add a <a>member</a> <var>alias</var> to <var>result</var> whose value is
24162431
set to <var>compacted value</var> and continue to the next
24172432
<var>expanded property</var>.</li>
@@ -2431,7 +2446,7 @@ <h3>Algorithm</h3>
24312446
<li>If the <a>term definition</a> for <var>property</var> in the
24322447
<var>active context</var> indicates that <var>property</var> is
24332448
a <a>reverse property</a>
2434-
<ol>
2449+
<ol>
24352450
<li>If the <a>term definition</a> for <var>property</var> in
24362451
the <var>active context</var> has a
24372452
<a>container mapping</a> <span class="changed">including</span> <code>@set</code> or
@@ -5471,20 +5486,8 @@ <h2>Changes since 1.0 Recommendation of 16 January 2014</h2>
54715486
a context. When this is set, vocabulary-relative IRIs, such as the
54725487
<a>members</a> of <a>node objects</a>, are expanded or compacted relative
54735488
to the <a>base IRI</a> using string concatenation.</li>
5474-
<li><a>Lists</a> may now have <a>members</a> which are themselves <a>lists</a>.</li>
5475-
<li>The <a href="#deserialize-json-ld-to-rdf-algorithm">Deserialize JSON-LD to RDF Algorithm</a>
5476-
has been updated to ensure that only <a>well-formed</a> <a>triples</a>
5477-
are emitted; previously, it only ensured that <a>triples</a> containing
5478-
<a>relative IRIs</a> were excluded.</li>
5479-
<li>The API now adds an <a data-link-for="JsonLdOptions">ordered</a>
5480-
option, defaulting to <code>false</code> This is used in algorithms to
5481-
control interation of <a>dictionary member</a> keys. Previously, the
5482-
algorithms always required such an order. The instructions for
5483-
evaluating test results have been updated accordingly.</li>
5484-
<li>The <a href="#generate-blank-node-identifier">Generate Blank Node Identifier algorithm</a>
5485-
has been updated to remove the specifics of how new blank node
5486-
identifiers are created.</li>
54875489
</ul>
5490+
<p>Additionally, see <a href="#changes-from-cg" class="sectionRef"></a>.</p>
54885491
</section>
54895492

54905493
<section class="appendix informative" id="changes-from-cg">
@@ -5503,6 +5506,10 @@ <h2>Changes since JSON-LD Community Group Final Report</h2>
55035506
<li>The <a href="#generate-blank-node-identifier">Generate Blank Node Identifier algorithm</a>
55045507
has been updated to remove the specifics of how new blank node
55055508
identifiers are created.</li>
5509+
<li>Values of <code>@type</code>, or an alais of <code>@type</code>, may now have their <code>@container</code> set to @set
5510+
to ensure that <code>@type</code> members are always represented as an array. This
5511+
also allows a term to be defined for <code>@type</code>, where the value MUST be a <a>dictionary</a>
5512+
with <code>@container</code> set to <code>@set</code>.</li>
55065513
</ul>
55075514
</section>
55085515

tests/compact-manifest.jsonld

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,33 @@
869869
"context": "compact/0103-context.jsonld",
870870
"expect": "compact/0103-out.jsonld",
871871
"option": {"processingMode": "json-ld-1.1", "specVersion": "json-ld-1.1"}
872+
}, {
873+
"@id": "#t0104",
874+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
875+
"name": "Compact @type with @container: @set",
876+
"purpose": "Ensures that a single @type value is represented as an array",
877+
"input": "compact/0104-in.jsonld",
878+
"context": "compact/0104-context.jsonld",
879+
"expect": "compact/0104-out.jsonld",
880+
"option": {"processingMode": "json-ld-1.1", "specVersion": "json-ld-1.1"}
881+
}, {
882+
"@id": "#t0105",
883+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
884+
"name": "Compact @type with @container: @set using an alias of @type",
885+
"purpose": "Ensures that a single @type value is represented as an array",
886+
"input": "compact/0105-in.jsonld",
887+
"context": "compact/0105-context.jsonld",
888+
"expect": "compact/0105-out.jsonld",
889+
"option": {"processingMode": "json-ld-1.1", "specVersion": "json-ld-1.1"}
890+
}, {
891+
"@id": "#t0106",
892+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
893+
"name": "Do not compact @type with @container: @set to an array using an alias of @type",
894+
"purpose": "Ensures that a single @type value is not represented as an array in 1.0",
895+
"input": "compact/0106-in.jsonld",
896+
"context": "compact/0106-context.jsonld",
897+
"expect": "compact/0106-out.jsonld",
898+
"option": {"processingMode": "json-ld-1.0", "specVersion": "json-ld-1.1"}
872899
}, {
873900
"@id": "#tc001",
874901
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],

tests/compact/0104-context.jsonld

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"@context": {
3+
"@type": {"@container": "@set"}
4+
}
5+
}

tests/compact/0104-in.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/type"
3+
}

tests/compact/0104-out.jsonld

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

tests/compact/0105-context.jsonld

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"@context": {
3+
"type": {"@id": "@type", "@container": "@set"}
4+
}
5+
}

tests/compact/0105-in.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/type"
3+
}

tests/compact/0105-out.jsonld

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

tests/compact/0106-context.jsonld

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"@context": {
3+
"type": {"@id": "@type", "@container": "@set"}
4+
}
5+
}

tests/compact/0106-in.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/type"
3+
}

tests/compact/0106-out.jsonld

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"@context": {
3+
"type": {"@id": "@type", "@container": "@set"}
4+
},
5+
"type": "http://example.org/type"
6+
}

tests/expand-manifest.jsonld

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1180,6 +1180,13 @@
11801180
"purpose": "Verifies that an exception is raised in Expansion when an invalid set or list object is found",
11811181
"input": "expand/e041-in.jsonld",
11821182
"expect": "invalid set or list object"
1183+
}, {
1184+
"@id": "#te042",
1185+
"@type": [ "jld:NegativeEvaluationTest", "jld:ExpandTest" ],
1186+
"name": "Keywords may not be redefined",
1187+
"purpose": "Verifies that an exception is raised on expansion when processing an invalid context attempting to define @container on a keyword",
1188+
"input": "expand/e042-in.jsonld",
1189+
"expect": "keyword redefinition"
11831190
}, {
11841191
"@id": "#tec01",
11851192
"@type": [ "jld:NegativeEvaluationTest", "jld:ExpandTest" ],

tests/expand/e042-in.jsonld

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"@context": {
3+
"@type": {"@container": "@set"}
4+
},
5+
"@type": "http://example.org/type"
6+
}

0 commit comments

Comments
 (0)