Skip to content

Commit 5c543e6

Browse files
committed
Add text and tests for @propagate.
1 parent 40e3bda commit 5c543e6

15 files changed

+208
-12
lines changed

index.html

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ <h2>Context Processing Algorithm</h2>
10011001
keys and values have to be interpreted as well as the current <a>base IRI</a>,
10021002
the <a>vocabulary mapping</a>, the <a>default language</a>,
10031003
<span class="changed">and an optional <dfn>previous context</dfn>,
1004-
used when a type-scoped <a>context</a> is defined</span>.
1004+
used when a non-propagated <a>context</a> is defined</span>.
10051005
Each <a>term definition</a> consists of:</p>
10061006
<ul>
10071007
<li>an <dfn>IRI mapping</dfn>,</li>
@@ -1012,7 +1012,7 @@ <h2>Context Processing Algorithm</h2>
10121012
<li class="changed">an optional <dfn>prefix flag</dfn>,</li>
10131013
<li class="changed">an optional <dfn>index mapping</dfn>,</li>
10141014
<li class="changed">a <dfn>protected</dfn>, used to mark this as a protected term,</li>
1015-
<li>and an optional <dfn>container mapping</dfn></li>.
1015+
<li>and an optional <dfn>container mapping</dfn>.</li>
10161016
</ul>
10171017

10181018
<p>A <a>term definition</a> can not only be used to map a <a>term</a>
@@ -1067,6 +1067,11 @@ <h3>Overview</h3>
10671067
they affect how the other <a>members</a> are processed. Please note that <code>@base</code> is
10681068
ignored when processing remote contexts.</p>
10691069

1070+
<p class="changed">If <a>context</a> is not to be propagated,
1071+
a reference to the <var>previous context</var> is retained so that
1072+
it may be rolled back when a new <a>node object</a> is entered.
1073+
By default, all contexts are propagated, other than type-scoped contexts.</p>
1074+
10701075
<p>Then, for every other <a>member</a> in <a>local context</a>, we update
10711076
the <a>term definition</a> in <var>result</var>. Since
10721077
<a>term definitions</a> in a <a>local context</a>
@@ -1094,19 +1099,23 @@ <h3>Algorithm</h3>
10941099
<span class="changed">, <var>from property</var>, defaulting to <code>false</code>,
10951100
which is used to allow changes to protected terms,
10961101
and <var>from type</var>, defaulting to <code>false</code>,
1097-
which is used to mark <a>term definitions</a> associated with a type-scoped <a>context</a>.</span>.
1102+
which is used to set the default for <var>propagated</var>
1103+
to mark <a>term definitions</a> associated with non-propagated <a>contexts</a>.</span>.
10981104
</p>
10991105

11001106
<ol>
11011107
<li>Initialize <var>result</var> to the result of cloning
11021108
<var>active context</var>.</li>
1109+
<li class="changed">If <var>local context</var> is an object containing the member <code>@propagate</code>,
1110+
its value MUST be <a>boolean</a> <code>true</code> or <code>false</code>,
1111+
set <var>propagate</var> to that value.</li>
1112+
<li class="changed">Otherwise, set <var>propagate</var> to <var>from type</var>.</li>
1113+
<li class="changed">If <var>propagate</var> is <code>false</code>, and <var>result</var>
1114+
does not have a <a>previous context</a>, set <a>previous context</a>
1115+
in <var>result</var> to <var>active context</var>.</li>
11031116
<li>If <var>local context</var> is not an <a>array</a>,
11041117
set it to an <a>array</a> containing only
11051118
<var>local context</var>.</li>
1106-
<li class="changed">
1107-
If <var>from type</var> is <code>true</code>, and <var>result</var>
1108-
does not have a <a>previous context</a>, set <a>previous context</a>
1109-
in <var>result</var> to <var>active context</var>.</li>
11101119
<li>
11111120
For each item <var>context</var> in <var>local context</var>:
11121121
<ol>
@@ -1240,12 +1249,24 @@ <h3>Algorithm</h3>
12401249
error has been detected and processing is aborted.</li>
12411250
</ol>
12421251
</li>
1252+
<li>If <var>context</var> has a <code>@propagate</code> <a>member</a>
1253+
and its value is not <a>boolean</a> <code>true</code> or <code>false</code>,
1254+
or <a>processing mode</a> is <code>json-ld-1.0</code>,
1255+
an <a data-link-for="JsonLdErrorCode">invalid local context</a>
1256+
error has been detected and processing is aborted.
1257+
<span class="note"><var>previous context</var> was determined before.</span></li>
12431258
<li>Create a <a class="changed">dictionary</a> <var>defined</var> to use to keep
12441259
track of whether or not a <a>term</a> has already been defined
12451260
or currently being defined during recursion.</li>
12461261
<li>For each <var>key</var>-<var>value</var> pair in <var>context</var> where
1247-
<var>key</var> is not <code>@base</code>, <code>@vocab</code>,
1248-
<code>@language</code>, <code>@protected</code>, or <code>@version</code>, invoke the
1262+
<var>key</var> is not
1263+
<code>@base</code>,
1264+
<code>@vocab</code>,
1265+
<code>@language</code>,
1266+
<code class="changed">@propagate</code>,
1267+
<code class="changed">@protected</code>, or
1268+
<code>@version</code>,
1269+
invoke the
12491270
<a href="#create-term-definition">Create Term Definition algorithm</a>,
12501271
passing <var>result</var> for <var>active context</var>,
12511272
<var>context</var> for <var>local context</var>, <var>key</var>,
@@ -1789,7 +1810,7 @@ <h3>Algorithm</h3>
17891810
the <a data-link-for="JsonLdOptions">ordered</a> flag, used to order
17901811
<a>dictionary member</a> keys lexicographically, where noted,
17911812
and the <var>from map</var> flag, used to control reverting
1792-
previous <a>term definitions</a> in the <a>active context</a> associated with a type-scoped <a>context</a>.</span>
1813+
previous <a>term definitions</a> in the <a>active context</a> associated with non-propagated <a>contexts</a>.</span>
17931814
To begin, the <var>active property</var> is set to <code>null</code>,
17941815
and <var>element</var> is set to the <a>JSON-LD input</a>.
17951816
<span class="changed">If not passed, the both flags are set to <code>false</code></span>.</p>
@@ -1864,7 +1885,7 @@ <h3>Algorithm</h3>
18641885
</li>
18651886
<li>Otherwise <var>element</var> is a <a class="changed">dictionary</a>.</li>
18661887
<li class="changed">If <var>active context</var> has a <a>previous context</a>,
1867-
the <var>active context</var> is type-scoped.
1888+
the <var>active context</var> is not propagated.
18681889
If <var>from map</var> is undefined or <code>false</code>,
18691890
and <var>element</var> does not contain a <a>member</a> expanding to <code>@value</code>,
18701891
and <var>element</var> does not consist of a single member expanding to <code>@id</code>,
@@ -2568,7 +2589,7 @@ <h3>Algorithm</h3>
25682589
</li>
25692590
<li>Otherwise <var>element</var> is a <a class="changed">dictionary</a>.</li>
25702591
<li class="changed">If <var>active context</var> has a <a>previous context</a>,
2571-
the <var>active context</var> is type-scoped.
2592+
the <var>active context</var> is not propagated.
25722593
If <var>element</var> does not contain an <code>@value</code> <a>member</a>,
25732594
and <var>element</var> does not consist of a single <code>@id</code> member,
25742595
set <var>active context</var> to <a>previous context</a> from <var>active context</var>,
@@ -6216,6 +6237,9 @@ <h2>Changes since JSON-LD Community Group Final Report</h2>
62166237
<li>The <a href="#iri-compaction">IRI compaction algorithm</a> may generate an error if the result is an
62176238
<a>absolute IRI</a> which could be confused with a compact IRI in the
62186239
<a>active context</a>.</li>
6240+
<li>By default, all contexts are propagated when traversing <a>node objects</a>, other than
6241+
type-scoped contexts. This can be controlled using the <code>@preserve</code>
6242+
<a>member</a> in a <a>local context</a>.</li>
62196243
</ul>
62206244
</section>
62216245

tests/compact-manifest.jsonld

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,6 +1139,24 @@
11391139
"context": "compact/c025-context.jsonld",
11401140
"expect": "compact/c025-out.jsonld",
11411141
"option": {"processingMode": "json-ld-1.1", "specVersion": "json-ld-1.1"}
1142+
}, {
1143+
"@id": "#tc026",
1144+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
1145+
"name": "@propagate: true on type-scoped context",
1146+
"purpose": "type-scoped context with @propagate: true survive node-objects",
1147+
"input": "compact/c026-in.jsonld",
1148+
"context": "compact/c026-context.jsonld",
1149+
"expect": "compact/c026-out.jsonld",
1150+
"option": {"specVersion": "json-ld-1.1"}
1151+
}, {
1152+
"@id": "#tc027",
1153+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
1154+
"name": "@propagate: false on property-scoped context",
1155+
"purpose": "property-scoped context with @propagate: false do not survive node-objects",
1156+
"input": "compact/c027-in.jsonld",
1157+
"context": "compact/c027-context.jsonld",
1158+
"expect": "compact/c027-out.jsonld",
1159+
"option": {"specVersion": "json-ld-1.1"}
11421160
}, {
11431161
"@id": "#te001",
11441162
"@type": [ "jld:NegativeEvaluationTest", "jld:CompactTest" ],

tests/compact/c026-context.jsonld

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"@vocab": "http://example/",
5+
"Foo": {
6+
"@context": {
7+
"@propagate": true,
8+
"baz": {"@type": "@vocab"}
9+
}
10+
}
11+
}
12+
}

tests/compact/c026-in.jsonld

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

tests/compact/c026-out.jsonld

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"@vocab": "http://example/",
5+
"Foo": {
6+
"@context": {
7+
"@propagate": true,
8+
"baz": {"@type": "@vocab"}
9+
}
10+
}
11+
},
12+
"@type": "Foo",
13+
"bar": {"baz": "buzz"}
14+
}

tests/compact/c027-context.jsonld

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"@vocab": "http://example/",
5+
"bar": {
6+
"@context": {
7+
"@propagate": false,
8+
"baz": {"@type": "@id"}
9+
}
10+
}
11+
}
12+
}

tests/compact/c027-in.jsonld

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[{
2+
"http://example/bar": [{
3+
"http://example/baz": [{
4+
"http://example/baz": [{"@value": "buzz"}]
5+
}]
6+
}]
7+
}]

tests/compact/c027-out.jsonld

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"@vocab": "http://example/",
5+
"bar": {
6+
"@context": {
7+
"@propagate": false,
8+
"baz": {"@type": "@id"}
9+
}
10+
}
11+
},
12+
"bar": {"baz": {"baz": "buzz"}}
13+
}

tests/expand-manifest.jsonld

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1040,6 +1040,30 @@
10401040
"input": "expand/c025-in.jsonld",
10411041
"expect": "expand/c025-out.jsonld",
10421042
"option": {"processingMode": "json-ld-1.1", "specVersion": "json-ld-1.1"}
1043+
}, {
1044+
"@id": "#tc026",
1045+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
1046+
"name": "@propagate: true on type-scoped context",
1047+
"purpose": "type-scoped context with @propagate: true survive node-objects",
1048+
"input": "expand/c026-in.jsonld",
1049+
"expect": "expand/c026-out.jsonld",
1050+
"option": {"specVersion": "json-ld-1.1"}
1051+
}, {
1052+
"@id": "#tc027",
1053+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
1054+
"name": "@propagate: false on property-scoped context",
1055+
"purpose": "property-scoped context with @propagate: false do not survive node-objects",
1056+
"input": "expand/c027-in.jsonld",
1057+
"expect": "expand/c027-out.jsonld",
1058+
"option": {"specVersion": "json-ld-1.1"}
1059+
}, {
1060+
"@id": "#tc028",
1061+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
1062+
"name": "@propagate: false on embedded context",
1063+
"purpose": "embedded context with @propagate: false do not survive node-objects",
1064+
"input": "expand/c028-in.jsonld",
1065+
"expect": "expand/c028-out.jsonld",
1066+
"option": {"specVersion": "json-ld-1.1"}
10431067
}, {
10441068
"@id": "#te001",
10451069
"@type": [ "jld:NegativeEvaluationTest", "jld:ExpandTest" ],

tests/expand/c026-in.jsonld

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"@vocab": "http://example/",
5+
"Foo": {
6+
"@context": {
7+
"@propagate": true,
8+
"baz": {"@type": "@vocab"}
9+
}
10+
}
11+
},
12+
"@type": "Foo",
13+
"bar": {"baz": "buzz"}
14+
}

tests/expand/c026-out.jsonld

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

tests/expand/c027-in.jsonld

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"@vocab": "http://example/",
5+
"bar": {
6+
"@context": {
7+
"@propagate": false,
8+
"baz": {"@type": "@id"}
9+
}
10+
}
11+
},
12+
"bar": {"baz": {"baz": "buzz"}}
13+
}

tests/expand/c027-out.jsonld

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[{
2+
"http://example/bar": [{
3+
"http://example/baz": [{
4+
"http://example/baz": [{"@value": "buzz"}]
5+
}]
6+
}]
7+
}]

tests/expand/c028-in.jsonld

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"@vocab": "http://example/"
5+
},
6+
"bar": {
7+
"@context": {
8+
"@propagate": false,
9+
"baz": {"@type": "@vocab"}
10+
},
11+
"baz": {
12+
"baz": "buzz"
13+
}
14+
}
15+
}

tests/expand/c028-out.jsonld

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[{
2+
"http://example/bar": [{
3+
"http://example/baz": [{
4+
"http://example/baz": [{"@value": "buzz"}]
5+
}]
6+
}]
7+
}]

0 commit comments

Comments
 (0)