Skip to content

Commit 239c3eb

Browse files
committed
Update use of _validate scoped contexts_ to skip only if false and the context is in the _remote contexts_ array, which allows for validating scoped contexts when the term is defined up to the point that it has already been processed.
1 parent 545376b commit 239c3eb

17 files changed

+306
-38
lines changed

index.html

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1261,6 +1261,10 @@ <h3>Algorithm</h3>
12611261
<a data-link-for="JsonLdErrorCode">context overflow</a>
12621262
error has been detected and processing is aborted;
12631263
otherwise, add <var>context</var> to <var>remote contexts</var>.</li>
1264+
<li id="alg-context-validate-scoped" class="changed">If <var>validate scoped context</var> is <code>false</code>,
1265+
and <var>remote contexts</var> already includes <var>context</var>
1266+
do not process <var>context</var> further and continue to any next
1267+
<var>context</var> in <var>local context</var>.</li>
12641268
<li class="changed">If <var>context</var> was previously dereferenced,
12651269
then the processor MUST NOT do a further dereference, and
12661270
<a>context</a> is set to the
@@ -1292,16 +1296,14 @@ <h3>Algorithm</h3>
12921296
<li>Set <var>loaded context</var> to the value of that <a>entry</a>.</li>
12931297
</ol>
12941298
</li>
1295-
<li id="alg-context-validate-scoped" class="changed">If <var>validate scoped context</var> is <code>false</code>,
1296-
do not process <var>loaded context</var> and continue to any next
1297-
<var>context</var> in <var>local context</var>.</li>
12981299
<li>Set <var>result</var> to the result of recursively calling this algorithm,
12991300
passing <var>result</var> for <var>active context</var>,
13001301
<var>loaded context</var> for <var>local context</var>,
13011302
<span class="changed">
13021303
the {{RemoteDocument/documentUrl}} of <var>context document</var> for <var>base URL</var>,
13031304
</span>
1304-
and <span class="changed">a copy of</span> <var>remote contexts</var>.
1305+
<span class="changed">a copy of</span> <var>remote contexts</var>,
1306+
<span class="changed">and <var>validate scoped context</var></span>.
13051307
<div class="note">If <var>context</var> was previously dereferenced,
13061308
<a>processors</a> MUST make provisions for retaining the <var>base URL</var>
13071309
of that <a>context</a> for this step to enable the resolution of any
@@ -1477,6 +1479,7 @@ <h3>Algorithm</h3>
14771479
<var>base URL</var>,
14781480
the value of the <code>@protected</code>
14791481
entry from <var>context</var>, if any, for <var>protected</var>,
1482+
<span class="changed">a copy of</span> <var>remote contexts</var>,
14801483
and <var>validate scoped context</var>.
14811484
</span>
14821485
</li>
@@ -1525,7 +1528,7 @@ <h3>Overview</h3>
15251528
<section class="algorithm">
15261529
<h3>Algorithm</h3>
15271530

1528-
<p>The algorithm has four required <span class="changed">and four optional</span> inputs.
1531+
<p>The algorithm has four required <span class="changed">and five optional</span> inputs.
15291532
The required inputs are
15301533
an <var>active context</var>,
15311534
a <var>local context</var>,
@@ -1536,6 +1539,8 @@ <h3>Algorithm</h3>
15361539
<var>protected</var> which defaults to <code>false</code>,
15371540
and <var>override protected</var>, defaulting to <code>false</code>,
15381541
which is used to allow changes to protected terms,
1542+
an <a>array</a> <var>remote contexts</var>,
1543+
defaulting to a new empty <a>array</a>, which is used to detect cyclical context inclusions,
15391544
and <var>validate scoped context</var> defaulting to <code>true</code>,
15401545
which is used to limit recursion when validating possibly recusive <a>scoped contexts</a>.</span>.
15411546
</p>
@@ -1814,6 +1819,7 @@ <h3>Algorithm</h3>
18141819
using the <var>active context</var>, <var>context</var> as <var>local context</var>,
18151820
<var>base URL</var>,
18161821
<code>true</code> for <var>override protected</var>,
1822+
<span class="changed">a copy of</span> <var>remote contexts</var>,
18171823
and <code>false</code> for <var>validate scoped context</var>.
18181824
If any error is detected, an
18191825
<a data-link-for="JsonLdErrorCode">invalid scoped context</a> error
@@ -7002,7 +7008,7 @@ <h2>Changes since Candidate Release of 05 March 2020</h2>
70027008
of <a href="#merge-node-maps" class="sectionRef"></a> to
70037009
exclude `@type`, leaving it to the next step.
70047010
This could cause type values from a node to be left out of the merge.</li>
7005-
<li>Added step <a href="#alg-context-validate-scoped">5.2.5</a>
7011+
<li>Added step <a href="#alg-context-validate-scoped">5.2.3</a>
70067012
to the <a href="#context-processing-algorithm">Context Processing algorithm</a>,
70077013
which is added <var>validate scoped context</var> as a new
70087014
optional argument, and passed to the

tests/expand-manifest.html

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3086,6 +3086,90 @@ <h2>
30863086
</dd>
30873087
</dl>
30883088
</dd>
3089+
<dt id='t0126'>
3090+
Test t0126 A scoped context may include itself recursively (direct)
3091+
</dt>
3092+
<dd>
3093+
<dl class='entry'>
3094+
<dt>id</dt>
3095+
<dd>#t0126</dd>
3096+
<dt>Type</dt>
3097+
<dd>jld:PositiveEvaluationTest, jld:ExpandTest</dd>
3098+
<dt>Purpose</dt>
3099+
<dd>Verifies that no exception is raised on expansion when processing a scoped context referencing itself directly</dd>
3100+
<dt>input</dt>
3101+
<dd>
3102+
<a href='expand/0126-in.jsonld'>expand/0126-in.jsonld</a>
3103+
</dd>
3104+
<dt>expect</dt>
3105+
<dd>
3106+
<a href='expand/0126-out.jsonld'>expand/0126-out.jsonld</a>
3107+
</dd>
3108+
<dt>Options</dt>
3109+
<dd>
3110+
<dl class='options'>
3111+
<dt>specVersion</dt>
3112+
<dd>json-ld-1.1</dd>
3113+
</dl>
3114+
</dd>
3115+
</dl>
3116+
</dd>
3117+
<dt id='t0127'>
3118+
Test t0127 A scoped context may include itself recursively (indirect)
3119+
</dt>
3120+
<dd>
3121+
<dl class='entry'>
3122+
<dt>id</dt>
3123+
<dd>#t0127</dd>
3124+
<dt>Type</dt>
3125+
<dd>jld:PositiveEvaluationTest, jld:ExpandTest</dd>
3126+
<dt>Purpose</dt>
3127+
<dd>Verifies that no exception is raised on expansion when processing a scoped context referencing itself indirectly</dd>
3128+
<dt>input</dt>
3129+
<dd>
3130+
<a href='expand/0127-in.jsonld'>expand/0127-in.jsonld</a>
3131+
</dd>
3132+
<dt>expect</dt>
3133+
<dd>
3134+
<a href='expand/0127-out.jsonld'>expand/0127-out.jsonld</a>
3135+
</dd>
3136+
<dt>Options</dt>
3137+
<dd>
3138+
<dl class='options'>
3139+
<dt>specVersion</dt>
3140+
<dd>json-ld-1.1</dd>
3141+
</dl>
3142+
</dd>
3143+
</dl>
3144+
</dd>
3145+
<dt id='t0128'>
3146+
Test t0128 Two scoped context may include a shared context
3147+
</dt>
3148+
<dd>
3149+
<dl class='entry'>
3150+
<dt>id</dt>
3151+
<dd>#t0128</dd>
3152+
<dt>Type</dt>
3153+
<dd>jld:PositiveEvaluationTest, jld:ExpandTest</dd>
3154+
<dt>Purpose</dt>
3155+
<dd>Verifies that no exception is raised on expansion when processing two scoped contexts referencing a shared context</dd>
3156+
<dt>input</dt>
3157+
<dd>
3158+
<a href='expand/0128-in.jsonld'>expand/0128-in.jsonld</a>
3159+
</dd>
3160+
<dt>expect</dt>
3161+
<dd>
3162+
<a href='expand/0128-out.jsonld'>expand/0128-out.jsonld</a>
3163+
</dd>
3164+
<dt>Options</dt>
3165+
<dd>
3166+
<dl class='options'>
3167+
<dt>specVersion</dt>
3168+
<dd>json-ld-1.1</dd>
3169+
</dl>
3170+
</dd>
3171+
</dl>
3172+
</dd>
30893173
<dt id='tc001'>
30903174
Test tc001 adding new term
30913175
</dt>

tests/expand-manifest.jsonld

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,30 @@
940940
"input": "expand/0125-in.jsonld",
941941
"expect": "expand/0125-out.jsonld",
942942
"option": {"specVersion": "json-ld-1.1"}
943+
}, {
944+
"@id": "#t0126",
945+
"@type": [ "jld:PositiveEvaluationTest", "jld:ExpandTest" ],
946+
"name": "A scoped context may include itself recursively (direct)",
947+
"purpose": "Verifies that no exception is raised on expansion when processing a scoped context referencing itself directly",
948+
"input": "expand/0126-in.jsonld",
949+
"expect": "expand/0126-out.jsonld",
950+
"option": {"specVersion": "json-ld-1.1"}
951+
}, {
952+
"@id": "#t0127",
953+
"@type": [ "jld:PositiveEvaluationTest", "jld:ExpandTest" ],
954+
"name": "A scoped context may include itself recursively (indirect)",
955+
"purpose": "Verifies that no exception is raised on expansion when processing a scoped context referencing itself indirectly",
956+
"input": "expand/0127-in.jsonld",
957+
"expect": "expand/0127-out.jsonld",
958+
"option": {"specVersion": "json-ld-1.1"}
959+
}, {
960+
"@id": "#t0128",
961+
"@type": [ "jld:PositiveEvaluationTest", "jld:ExpandTest" ],
962+
"name": "Two scoped context may include a shared context",
963+
"purpose": "Verifies that no exception is raised on expansion when processing two scoped contexts referencing a shared context",
964+
"input": "expand/0128-in.jsonld",
965+
"expect": "expand/0128-out.jsonld",
966+
"option": {"specVersion": "json-ld-1.1"}
943967
}, {
944968
"@id": "#tc001",
945969
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],

tests/expand/0124-out.jsonld

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

tests/expand/0125-in.jsonld

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"@context": [
3+
{
4+
"@version": 1.1,
5+
"ex": {
6+
"@id": "http://example.org/",
7+
"@prefix": true
8+
}
9+
},
10+
{
11+
"@vocab": "ex"
12+
}
13+
],
14+
"foo": "bar"
15+
}

tests/expand/0125-out.jsonld

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

tests/expand/0127-in.jsonld

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,7 @@
11
{
2-
"@context": [
3-
{
4-
"@version": 1.1,
5-
"ex": {
6-
"@id": "http://example.org/",
7-
"@prefix": true
8-
}
9-
},
10-
{
11-
"@vocab": "ex"
12-
}
13-
],
14-
"foo": "bar"
2+
"@context": "0127-context-1.jsonld",
3+
"@id": "ex:id",
4+
"prop": {
5+
"value": "v"
6+
}
157
}

tests/expand/0127-out.jsonld

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
[
22
{
3-
"http://example.org/ns/foo": [
3+
"@id": "ex:id",
4+
"ex:prop": [
45
{
5-
"@value": "bar"
6+
"ex:value": [
7+
{
8+
"@value": "v"
9+
}
10+
]
611
}
712
]
813
}

tests/expand/0128-out.jsonld

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
[
22
{
3-
"http://example.org/foo": [
3+
"@id": "ex:id",
4+
"ex:prop": [
45
{
5-
"@value": "bar"
6+
"ex:value": [
7+
{
8+
"@value": "v"
9+
}
10+
]
611
}
712
]
813
}

tests/toRdf-manifest.html

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5561,6 +5561,90 @@ <h2>
55615561
</dd>
55625562
</dl>
55635563
</dd>
5564+
<dt id='te126'>
5565+
Test te126 A scoped context may include itself recursively (direct)
5566+
</dt>
5567+
<dd>
5568+
<dl class='entry'>
5569+
<dt>id</dt>
5570+
<dd>#te126</dd>
5571+
<dt>Type</dt>
5572+
<dd>jld:PositiveEvaluationTest, jld:ToRDFTest</dd>
5573+
<dt>Purpose</dt>
5574+
<dd>Verifies that no exception is raised on expansion when processing a scoped context referencing itself directly</dd>
5575+
<dt>input</dt>
5576+
<dd>
5577+
<a href='toRdf/e126-in.jsonld'>toRdf/e126-in.jsonld</a>
5578+
</dd>
5579+
<dt>expect</dt>
5580+
<dd>
5581+
<a href='toRdf/e126-out.nq'>toRdf/e126-out.nq</a>
5582+
</dd>
5583+
<dt>Options</dt>
5584+
<dd>
5585+
<dl class='options'>
5586+
<dt>specVersion</dt>
5587+
<dd>json-ld-1.1</dd>
5588+
</dl>
5589+
</dd>
5590+
</dl>
5591+
</dd>
5592+
<dt id='te127'>
5593+
Test te127 A scoped context may include itself recursively (indirect)
5594+
</dt>
5595+
<dd>
5596+
<dl class='entry'>
5597+
<dt>id</dt>
5598+
<dd>#te127</dd>
5599+
<dt>Type</dt>
5600+
<dd>jld:PositiveEvaluationTest, jld:ToRDFTest</dd>
5601+
<dt>Purpose</dt>
5602+
<dd>Verifies that no exception is raised on expansion when processing a scoped context referencing itself indirectly</dd>
5603+
<dt>input</dt>
5604+
<dd>
5605+
<a href='toRdf/e127-in.jsonld'>toRdf/e127-in.jsonld</a>
5606+
</dd>
5607+
<dt>expect</dt>
5608+
<dd>
5609+
<a href='toRdf/e127-out.nq'>toRdf/e127-out.nq</a>
5610+
</dd>
5611+
<dt>Options</dt>
5612+
<dd>
5613+
<dl class='options'>
5614+
<dt>specVersion</dt>
5615+
<dd>json-ld-1.1</dd>
5616+
</dl>
5617+
</dd>
5618+
</dl>
5619+
</dd>
5620+
<dt id='te128'>
5621+
Test te128 Two scoped context may include a shared context
5622+
</dt>
5623+
<dd>
5624+
<dl class='entry'>
5625+
<dt>id</dt>
5626+
<dd>#te128</dd>
5627+
<dt>Type</dt>
5628+
<dd>jld:PositiveEvaluationTest, jld:ToRDFTest</dd>
5629+
<dt>Purpose</dt>
5630+
<dd>Verifies that no exception is raised on expansion when processing two scoped contexts referencing a shared context</dd>
5631+
<dt>input</dt>
5632+
<dd>
5633+
<a href='toRdf/e128-in.jsonld'>toRdf/e128-in.jsonld</a>
5634+
</dd>
5635+
<dt>expect</dt>
5636+
<dd>
5637+
<a href='toRdf/e128-out.nq'>toRdf/e128-out.nq</a>
5638+
</dd>
5639+
<dt>Options</dt>
5640+
<dd>
5641+
<dl class='options'>
5642+
<dt>specVersion</dt>
5643+
<dd>json-ld-1.1</dd>
5644+
</dl>
5645+
</dd>
5646+
</dl>
5647+
</dd>
55645648
<dt id='tec01'>
55655649
Test tec01 Invalid keyword in term definition
55665650
</dt>

0 commit comments

Comments
 (0)