Skip to content

Commit 876251e

Browse files
committed
Add tests and spec text for scoped-contexts on @nest alias.
For #380
1 parent 8099234 commit 876251e

13 files changed

+322
-6
lines changed

index.html

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2424,7 +2424,7 @@ <h3>Algorithm</h3>
24242424
<li>If <var>element</var> is <code>null</code>, return <code>null</code>.</li>
24252425
<li class="changed">If <var>active property</var> is <code>@default</code>,
24262426
initialize the {{JsonLdOptions/frameExpansion}} flag to <code>false</code>.</li>
2427-
<li class="changed">If <var>active property</var> has a <a>term definition</a> in <var>active context</var>
2427+
<li id="alg-expand-property-scoped-context" class="changed">If <var>active property</var> has a <a>term definition</a> in <var>active context</var>
24282428
with a <a>local context</a>, initialize <var>property-scoped context</var> to that <a>local context</a>.</li>
24292429
<li>If <var>element</var> is a <a>scalar</a>,
24302430
<ol>
@@ -2478,7 +2478,7 @@ <h3>Algorithm</h3>
24782478
(where <a>entries</a> are <span class="changed"><a data-lt="IRI expanding">IRI expanded</a></span>,
24792479
set <var>active context</var> to <a>previous context</a> from <var>active context</var>,
24802480
as the scope of a term-scoped <a>context</a> does not apply when processing new <a>node objects</a>.</li>
2481-
<li id="alg-expand-property-scoped-context" class="changed">If <var>property-scoped context</var> is defined,
2481+
<li id="alg-expand-property-scoped-context2" id="alg-expand-property-scoped-context" class="changed">If <var>property-scoped context</var> is defined,
24822482
set <var>active context</var> to the result of the
24832483
<a href="#context-processing-algorithm">Context Processing algorithm</a>,
24842484
passing <var>active context</var>, <var>property-scoped context</var> as <var>local context</var>,
@@ -3013,9 +3013,20 @@ <h3>Algorithm</h3>
30133013
<var>nested value</var> expands to <code>@value</code>, an
30143014
<a data-link-for="JsonLdErrorCode">invalid @nest value</a> error
30153015
has been detected and processing is aborted.</li>
3016-
<li>Recursively repeat steps <a href="#alg-expand-each-key-value">13</a>
3016+
<li>Recursively repeat steps
3017+
<a href="#alg-expand-property-scoped-context">3</a>,
3018+
<a href="#alg-expand-property-scoped-context2">8</a>,
3019+
<a href="#alg-expand-each-key-value">13</a>,
30173020
and <a href="#alg-expand-resolve-nest">14</a>
3018-
using <var>nested value</var> for <var>element</var>.
3021+
using <var>nesting-key</var> for <var>active property</var>, and
3022+
<var>nested value</var> for <var>element</var>.
3023+
<div class="note">Steps <a href="#alg-expand-property-scoped-context">3</a>
3024+
and <a href="#alg-expand-property-scoped-context2">8</a>
3025+
may update the <var>active context</var> based on a
3026+
property-scoped context associated with <var>nesting-key</var>.
3027+
Updates to <var>active context</var> are restricted to the
3028+
recursive operation, and do not propogate to subsequent iterations
3029+
on <var>nested value</var> and <var>nesting-key</var>.</div>
30193030
<div class="note">By invoking steps <a href="#alg-expand-each-key-value">13</a>
30203031
and <a href="#alg-expand-resolve-nest">14</a> on <var>nested value</var>
30213032
we are able to unfold arbitrary levels of nesting, with results being merged into

tests/expand-manifest.html

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1765,7 +1765,7 @@ <h2>
17651765
<dd>
17661766
<dl class='options'>
17671767
<dt>expandContext</dt>
1768-
<dd>0077-context.jsonld</dd>
1768+
<dd>expand/0077-context.jsonld</dd>
17691769
</dl>
17701770
</dd>
17711771
</dl>
@@ -3956,6 +3956,62 @@ <h2>
39563956
</dd>
39573957
</dl>
39583958
</dd>
3959+
<dt id='tc034'>
3960+
Test tc034 property-scoped contexts which are alias of @nest
3961+
</dt>
3962+
<dd>
3963+
<dl class='entry'>
3964+
<dt>id</dt>
3965+
<dd>#tc034</dd>
3966+
<dt>Type</dt>
3967+
<dd>jld:PositiveEvaluationTest, jld:ExpandTest</dd>
3968+
<dt>Purpose</dt>
3969+
<dd>Nesting terms may have property-scoped contexts defined.</dd>
3970+
<dt>input</dt>
3971+
<dd>
3972+
<a href='expand/c034-in.jsonld'>expand/c034-in.jsonld</a>
3973+
</dd>
3974+
<dt>expect</dt>
3975+
<dd>
3976+
<a href='expand/c034-out.jsonld'>expand/c034-out.jsonld</a>
3977+
</dd>
3978+
<dt>Options</dt>
3979+
<dd>
3980+
<dl class='options'>
3981+
<dt>specVersion</dt>
3982+
<dd>json-ld-1.1</dd>
3983+
</dl>
3984+
</dd>
3985+
</dl>
3986+
</dd>
3987+
<dt id='tc035'>
3988+
Test tc035 Bibframe example (poor-mans inferrence)
3989+
</dt>
3990+
<dd>
3991+
<dl class='entry'>
3992+
<dt>id</dt>
3993+
<dd>#tc035</dd>
3994+
<dt>Type</dt>
3995+
<dd>jld:PositiveEvaluationTest, jld:ExpandTest</dd>
3996+
<dt>Purpose</dt>
3997+
<dd>Nesting terms may have property-scoped contexts defined.</dd>
3998+
<dt>input</dt>
3999+
<dd>
4000+
<a href='expand/c035-in.jsonld'>expand/c035-in.jsonld</a>
4001+
</dd>
4002+
<dt>expect</dt>
4003+
<dd>
4004+
<a href='expand/c035-out.jsonld'>expand/c035-out.jsonld</a>
4005+
</dd>
4006+
<dt>Options</dt>
4007+
<dd>
4008+
<dl class='options'>
4009+
<dt>specVersion</dt>
4010+
<dd>json-ld-1.1</dd>
4011+
</dl>
4012+
</dd>
4013+
</dl>
4014+
</dd>
39594015
<dt id='tdi01'>
39604016
Test tdi01 Expand string using default and term directions
39614017
</dt>

tests/expand-manifest.jsonld

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,6 +1188,22 @@
11881188
"input": "expand/c033-in.jsonld",
11891189
"expectErrorCode": "invalid scoped context",
11901190
"option": {"specVersion": "json-ld-1.1"}
1191+
}, {
1192+
"@id": "#tc034",
1193+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
1194+
"name": "property-scoped contexts which are alias of @nest",
1195+
"purpose": "Nesting terms may have property-scoped contexts defined.",
1196+
"input": "expand/c034-in.jsonld",
1197+
"expect": "expand/c034-out.jsonld",
1198+
"option": {"specVersion": "json-ld-1.1"}
1199+
}, {
1200+
"@id": "#tc035",
1201+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
1202+
"name": "Bibframe example (poor-mans inferrence)",
1203+
"purpose": "Nesting terms may have property-scoped contexts defined.",
1204+
"input": "expand/c035-in.jsonld",
1205+
"expect": "expand/c035-out.jsonld",
1206+
"option": {"specVersion": "json-ld-1.1"}
11911207
}, {
11921208
"@id": "#tdi01",
11931209
"@type": [ "jld:PositiveEvaluationTest", "jld:ExpandTest" ],

tests/expand/c034-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.org/",
5+
"nest": {
6+
"@id": "@nest",
7+
"@context": {
8+
"@vocab": "http://example.org/nest/"
9+
}
10+
}
11+
},
12+
"nest": {
13+
"property": "should be in /nest"
14+
}
15+
}

tests/expand/c034-out.jsonld

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[{
2+
"http://example.org/nest/property": [{"@value": "should be in /nest"}]
3+
}]

tests/expand/c035-in.jsonld

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"@base": "http://example.org/base/",
5+
"@vocab": "http://purl.org/dc/terms/",
6+
"bibo": "http://purl.org/ontology/bibo/",
7+
"Print": "bibo:Book",
8+
"name": "http://www.w3.org/2000/01/rdf-schema#label",
9+
"instanceOf": "@nest",
10+
"contributionByRole": {
11+
"@id": "@nest",
12+
"@context": {
13+
"agent": "@nest",
14+
"aut": "creator"
15+
}
16+
},
17+
"provisionActivityByType": {
18+
"@id": "@nest",
19+
"@context": {
20+
"Publication": {
21+
"@id": "@nest",
22+
"@context": {"date": "published", "agent": "publisher"}
23+
}
24+
}
25+
},
26+
"identifiedByType": {
27+
"@id": "@nest",
28+
"@context": {
29+
"Isbn": {"@id": "@nest"},
30+
"value": "bibo:isbn"
31+
}
32+
}
33+
},
34+
"@id": "book/one",
35+
"@type": "Print",
36+
"instanceOf": {
37+
"contributionByRole": {
38+
"aut": {
39+
"agent": {"name": "Some Body"}
40+
}
41+
}
42+
},
43+
"identifiedByType": {
44+
"Isbn": {
45+
"value": "1234567890"
46+
}
47+
},
48+
"provisionActivityByType": {
49+
"Publication": {
50+
"date": "1999",
51+
"agent": {"name": "PubCorp"}
52+
}
53+
}
54+
}

tests/expand/c035-out.jsonld

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[{
2+
"@id": "http://example.org/base/book/one",
3+
"@type": ["http://purl.org/ontology/bibo/Book"],
4+
"http://purl.org/dc/terms/creator": [{
5+
"http://www.w3.org/2000/01/rdf-schema#label": [{"@value": "Some Body"}]
6+
}],
7+
"http://purl.org/ontology/bibo/isbn": [{"@value": "1234567890"}],
8+
"http://purl.org/dc/terms/published": [{"@value": "1999"}],
9+
"http://purl.org/dc/terms/publisher": [{
10+
"http://www.w3.org/2000/01/rdf-schema#label": [{"@value": "PubCorp"}]
11+
}]
12+
}]

tests/toRdf-manifest.html

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2195,6 +2195,62 @@ <h2>
21952195
</dd>
21962196
</dl>
21972197
</dd>
2198+
<dt id='tc034'>
2199+
Test tc034 property-scoped contexts which are alias of @nest
2200+
</dt>
2201+
<dd>
2202+
<dl class='entry'>
2203+
<dt>id</dt>
2204+
<dd>#tc034</dd>
2205+
<dt>Type</dt>
2206+
<dd>jld:PositiveEvaluationTest, jld:ToRDFTest</dd>
2207+
<dt>Purpose</dt>
2208+
<dd>Nesting terms may have property-scoped contexts defined.</dd>
2209+
<dt>input</dt>
2210+
<dd>
2211+
<a href='toRdf/c034-in.jsonld'>toRdf/c034-in.jsonld</a>
2212+
</dd>
2213+
<dt>expect</dt>
2214+
<dd>
2215+
<a href='toRdf/c034-out.nq'>toRdf/c034-out.nq</a>
2216+
</dd>
2217+
<dt>Options</dt>
2218+
<dd>
2219+
<dl class='options'>
2220+
<dt>specVersion</dt>
2221+
<dd>json-ld-1.1</dd>
2222+
</dl>
2223+
</dd>
2224+
</dl>
2225+
</dd>
2226+
<dt id='tc035'>
2227+
Test tc035 Bibframe example (poor-mans inferrence)
2228+
</dt>
2229+
<dd>
2230+
<dl class='entry'>
2231+
<dt>id</dt>
2232+
<dd>#tc035</dd>
2233+
<dt>Type</dt>
2234+
<dd>jld:PositiveEvaluationTest, jld:ToRDFTest</dd>
2235+
<dt>Purpose</dt>
2236+
<dd>Nesting terms may have property-scoped contexts defined.</dd>
2237+
<dt>input</dt>
2238+
<dd>
2239+
<a href='toRdf/c035-in.jsonld'>toRdf/c035-in.jsonld</a>
2240+
</dd>
2241+
<dt>expect</dt>
2242+
<dd>
2243+
<a href='toRdf/c035-out.nq'>toRdf/c035-out.nq</a>
2244+
</dd>
2245+
<dt>Options</dt>
2246+
<dd>
2247+
<dl class='options'>
2248+
<dt>specVersion</dt>
2249+
<dd>json-ld-1.1</dd>
2250+
</dl>
2251+
</dd>
2252+
</dl>
2253+
</dd>
21982254
<dt id='tdi01'>
21992255
Test tdi01 Expand string using default and term directions
22002256
</dt>
@@ -4254,7 +4310,7 @@ <h2>
42544310
<dd>
42554311
<dl class='options'>
42564312
<dt>expandContext</dt>
4257-
<dd>e077-context.jsonld</dd>
4313+
<dd>toRdf/e077-context.jsonld</dd>
42584314
</dl>
42594315
</dd>
42604316
</dl>

tests/toRdf-manifest.jsonld

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,22 @@
660660
"input": "toRdf/c033-in.jsonld",
661661
"expectErrorCode": "invalid scoped context",
662662
"option": {"specVersion": "json-ld-1.1"}
663+
}, {
664+
"@id": "#tc034",
665+
"@type": ["jld:PositiveEvaluationTest", "jld:ToRDFTest"],
666+
"name": "property-scoped contexts which are alias of @nest",
667+
"purpose": "Nesting terms may have property-scoped contexts defined.",
668+
"input": "toRdf/c034-in.jsonld",
669+
"expect": "toRdf/c034-out.nq",
670+
"option": {"specVersion": "json-ld-1.1"}
671+
}, {
672+
"@id": "#tc035",
673+
"@type": ["jld:PositiveEvaluationTest", "jld:ToRDFTest"],
674+
"name": "Bibframe example (poor-mans inferrence)",
675+
"purpose": "Nesting terms may have property-scoped contexts defined.",
676+
"input": "toRdf/c035-in.jsonld",
677+
"expect": "toRdf/c035-out.nq",
678+
"option": {"specVersion": "json-ld-1.1"}
663679
}, {
664680
"@id": "#tdi01",
665681
"@type": [ "jld:PositiveEvaluationTest", "jld:ToRDFTest" ],

tests/toRdf/c034-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.org/",
5+
"nest": {
6+
"@id": "@nest",
7+
"@context": {
8+
"@vocab": "http://example.org/nest/"
9+
}
10+
}
11+
},
12+
"nest": {
13+
"property": "should be in /nest"
14+
}
15+
}

tests/toRdf/c034-out.nq

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_:b0 <http://example.org/nest/property> "should be in /nest" .

tests/toRdf/c035-in.jsonld

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"@context": {
3+
"@version": 1.1,
4+
"@base": "http://example.org/base/",
5+
"@vocab": "http://purl.org/dc/terms/",
6+
"bibo": "http://purl.org/ontology/bibo/",
7+
"Print": "bibo:Book",
8+
"name": "http://www.w3.org/2000/01/rdf-schema#label",
9+
"instanceOf": "@nest",
10+
"contributionByRole": {
11+
"@id": "@nest",
12+
"@context": {
13+
"agent": "@nest",
14+
"aut": "creator"
15+
}
16+
},
17+
"provisionActivityByType": {
18+
"@id": "@nest",
19+
"@context": {
20+
"Publication": {
21+
"@id": "@nest",
22+
"@context": {"date": "published", "agent": "publisher"}
23+
}
24+
}
25+
},
26+
"identifiedByType": {
27+
"@id": "@nest",
28+
"@context": {
29+
"Isbn": {"@id": "@nest"},
30+
"value": "bibo:isbn"
31+
}
32+
}
33+
},
34+
"@id": "book/one",
35+
"@type": "Print",
36+
"instanceOf": {
37+
"contributionByRole": {
38+
"aut": {
39+
"agent": {"name": "Some Body"}
40+
}
41+
}
42+
},
43+
"identifiedByType": {
44+
"Isbn": {
45+
"value": "1234567890"
46+
}
47+
},
48+
"provisionActivityByType": {
49+
"Publication": {
50+
"date": "1999",
51+
"agent": {"name": "PubCorp"}
52+
}
53+
}
54+
}

0 commit comments

Comments
 (0)