Skip to content

Commit c8683de

Browse files
committed
Relax to allow @version to be set in any context; it only conflicts if processingMode is set to something else in the API. Also changes term selection for compact IRIs in 1.0 mode as a necessary byproduct of this approach.
Fixes #581
1 parent d4361fb commit c8683de

File tree

8 files changed

+44
-21
lines changed

8 files changed

+44
-21
lines changed

spec/latest/json-ld-api/index.html

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -958,8 +958,6 @@ <h3>Algorithm</h3>
958958
error has been detected and processing is aborted.</li>
959959
</ol>
960960
</li>
961-
<li class="changed">Set <a>processing mode</a>,
962-
to <code>json-ld-1.0</code>, if not already set.</li>
963961
<li>Create a <a class="changed">dictionary</a> <var>defined</var> to use to keep
964962
track of whether or not a <a>term</a> has already been defined
965963
or currently being defined during recursion.</li>
@@ -1044,10 +1042,12 @@ <h3>Algorithm</h3>
10441042
key <var>term</var> to <code>true</code>, and return.</li>
10451043
<li>Otherwise, if <var>value</var> is a <a>string</a>, convert it
10461044
to a <a class="changed">dictionary</a> consisting of a single member whose
1047-
key is <code>@id</code> and whose value is <var>value</var>.</li>
1045+
key is <code>@id</code> and whose value is <var>value</var>.
1046+
<span class="changed">Set <var>simple term</var> to <code>true</code></span>.</li>
10481047
<li>Otherwise, <var>value</var> must be a <a class="changed">dictionary</a>, if not, an
10491048
<a data-link-for="JsonLdErrorCode">invalid term definition</a>
1050-
error has been detected and processing is aborted.</li>
1049+
error has been detected and processing is aborted.
1050+
<span class="changed">Set <var>simple term</var> to <code>false</code></span>.</li>
10511051
<li>Create a new <a>term definition</a>, <var>definition</var>.</li>
10521052
<li>If <var>value</var> contains the key <code>@type</code>:
10531053
<ol>
@@ -1120,14 +1120,10 @@ <h3>Algorithm</h3>
11201120
<a data-link-for="JsonLdErrorCode">invalid keyword alias</a>
11211121
error has been detected and processing is aborted.</li>
11221122
<li class="changed">If <var>term</var> does not contain a colon (<code>:</code>),
1123-
and if <a>processing mode</a> is <code>json-ld-1.0</code>, and the,
1123+
<span class="changed"><var>simple term</var> is <code>true</code></span>, and the,
11241124
<a>IRI mapping</a> of <var>definition</var> ends with a URI
11251125
<a data-cite="RFC3986#section-2.2">gen-delim</a> character,
1126-
set the <a>prefix flag</a> in <var>definition</var> to <code>true</code>.
1127-
If <a>processing mode</a> is not <code>json-ld-1.0</code>, and the <a>IRI mapping</a> ends with a URI
1128-
<a data-cite="RFC3986#section-2.2">gen-delim</a> character,
1129-
set the <a>prefix flag</a> in <var>definition</var> to <code>true</code>, only if
1130-
<var>value</var> was originally a <a>string</a>.</li>
1126+
set the <a>prefix flag</a> in <var>definition</var> to <code>true</code>.</li>
11311127
</ol>
11321128
</li>
11331129
<li>

spec/latest/json-ld/index.html

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -972,7 +972,7 @@ <h2>JSON-LD 1.1 Processing Mode</h2>
972972
</pre>
973973

974974
<p>The first <code>context</code> encountered when processing a
975-
document determines the <code>processing mode</code>,
975+
document which contains <code>@version</code> determines the <code>processing mode</code>,
976976
unless it is defined explicitly through an API option.</p>
977977

978978
<p class="note">Setting the <a>processing mode</a> explicitly
@@ -1191,10 +1191,18 @@ <h2>Compact IRIs</h2>
11911191
-->
11921192
</pre>
11931193

1194-
<p class="changed">In JSON-LD 1.0, terms will be used as <a>compact IRI</a> prefixes when
1195-
compacting only if they map to a value that ends with a URI <a
1196-
data-cite="RFC3986#section-2.2">gen-delim</a> character (e.g, <code>/</code>,
1197-
<code>#</code> and others, see [[!RFC3986]]).</p>
1194+
<p class="changed">In JSON-LD 1.0, terms may be chosen as <a>compact IRI</a> prefixes when
1195+
compacting only if a <a>simple term definition</a> is used where the value ends with a
1196+
URI <a data-cite="RFC3986#section-2.2">gen-delim</a> character (e.g, <code>/</code>,
1197+
<code>#</code> and others, see [[!RFC3986]]).
1198+
<span class="note">The previous specification allows any term to be chosen as
1199+
a compact IRI prefix, which lead to a poor experience.</span></p>
1200+
1201+
<p class="changed">In JSON-LD 1.1, terms may be chosen as <a>compact IRI</a> prefixes
1202+
when compacting only if
1203+
a <a>simple term definition</a> is used where the value ends with a URI <a data-cite="RFC3986#section-2.2">gen-delim</a> character,
1204+
or if their <a>expanded term definition</a> contains
1205+
a <code>@prefix</code> member with the value <a>true</a>.</p>
11981206

11991207
<p class="note">This represents a small change to the 1.0 algorithm to prevent IRIs
12001208
that are not really intended to be used as prefixes from being used for creating
@@ -5070,6 +5078,7 @@ <h3>Serializing/Deserializing RDF</h3>
50705078
<section class="appendix informative">
50715079
<h2>Changes since 1.0 Recommendation of 16 January 2014</h2>
50725080
<ul>
5081+
<li>A context may contain a <code>@version</code> member which is used to set the <a>processing mode</a>.</li>
50735082
<li>An <a>expanded term definition</a> can now have an
50745083
<code>@context</code> property, which defines a <a>context</a> used for values of
50755084
a <a>property</a> identified with such a <a>term</a>.</li>
@@ -5093,7 +5102,7 @@ <h2>Changes since 1.0 Recommendation of 16 January 2014</h2>
50935102
keyword along with <code>@set</code> (other than <code>@list</code>).
50945103
This allows a way to ensure that such property values will always
50955104
be expressed in <a>array</a> form.</li>
5096-
<li>In JSON-LD 1.1, terms will be used as <a>compact IRI</a> prefixes
5105+
<li>In JSON-LD 1.1, terms will be chosen as <a>compact IRI</a> prefixes
50975106
when compacting only if
50985107
a <a>simple term definition</a> is used where the value ends with a URI <a data-cite="RFC3986#section-2.2">gen-delim</a> character,
50995108
or if their <a>expanded term definition</a> contains

test-suite/tests/cmopact-0096-context.jsonld

Whitespace-only changes.

test-suite/tests/compact-manifest.jsonld

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1241,8 +1241,8 @@
12411241
}, {
12421242
"@id": "#tp001",
12431243
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
1244-
"name": "Compact IRI may use an expanded term definition in 1.0",
1245-
"purpose": "Terms with an expanded term definition may be used for creating compact IRIs",
1244+
"name": "Compact IRI will not use an expanded term definition in 1.0",
1245+
"purpose": "Terms with an expanded term definition are not used for creating compact IRIs",
12461246
"option": {"processingMode": "json-ld-1.0", "specVersion": "json-ld-1.1"},
12471247
"input": "compact-p001-in.jsonld",
12481248
"context": "compact-p001-context.jsonld",

test-suite/tests/compact-p001-out.jsonld

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"@context": {
33
"ex": {"@id": "http://example.org/"}
44
},
5-
"@id": "ex:id1",
6-
"@type": ["ex:Type1", "ex:Type2"],
7-
"ex:term": {"@id": "ex:id2"}
5+
"@id": "http://example.org/id1",
6+
"@type": ["http://example.org/Type1", "http://example.org/Type2"],
7+
"http://example.org/term": {"@id": "http://example.org/id2"}
88
}

test-suite/tests/expand-manifest.jsonld

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,14 @@
10741074
"input": "expand-n007-in.jsonld",
10751075
"expect": "expand-n007-out.jsonld",
10761076
"option": {"processingMode": "json-ld-1.1", "specVersion": "json-ld-1.1"}
1077+
}, {
1078+
"@id": "#tp001",
1079+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
1080+
"name": "@version may be specified after first context",
1081+
"purpose": "If processing mode is not set through API, it is set by the first context containing @version.",
1082+
"option": {"specVersion": "json-ld-1.1"},
1083+
"input": "expand-p001-in.jsonld",
1084+
"expect": "expand-p001-out.jsonld"
10771085
}, {
10781086
"@id": "#tl001",
10791087
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"@context": [
3+
{"@vocab": "http://example/"},
4+
{"@version": 1.1, "a": {"@type": "@id"}}
5+
],
6+
"a": "http://example.org/foo"
7+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[{
2+
"http://example/a": [{"@id": "http://example.org/foo"}]
3+
}]

0 commit comments

Comments
 (0)