Skip to content

Commit 295809a

Browse files
committed
Add tests and spec text for scoped-contexts on @nest alias.
For #380
1 parent ad97b98 commit 295809a

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 @@

Algorithm

24242424
<li>If <var>elementvar> is <code>nullcode>, return <code>nullcode>.li>
24252425
<li class="changed">If <var>active propertyvar> is <code>@defaultcode>,
24262426
initialize the {{JsonLdOptions/frameExpansion}} flag to <code>falsecode>.li>
2427-
<li class="changed">If <var>active propertyvar> has a <a>term definitiona> in <var>active contextvar>
2427+
<li id="alg-expand-property-scoped-context" class="changed">If <var>active propertyvar> has a <a>term definitiona> in <var>active contextvar>
24282428
with a <a>local contexta>, initialize <var>property-scoped contextvar> to that <a>local contexta>.li>
24292429
<li>If <var>elementvar> is a <a>scalara>,
24302430
<ol>
@@ -2478,7 +2478,7 @@

Algorithm

24782478
(where <a>entriesa> are <span class="changed"><a data-lt="IRI expanding">IRI expandeda>span>,
24792479
set <var>active contextvar> to <a>previous contexta> from <var>active contextvar>,
24802480
as the scope of a term-scoped <a>contexta> does not apply when processing new <a>node objectsa>.li>
2481-
<li id="alg-expand-property-scoped-context" class="changed">If <var>property-scoped contextvar> is defined,
2481+
<li id="alg-expand-property-scoped-context2" id="alg-expand-property-scoped-context" class="changed">If <var>property-scoped contextvar> is defined,
24822482
set <var>active contextvar> to the result of the
24832483
<a href="#context-processing-algorithm">Context Processing algorithma>,
24842484
passing <var>active contextvar>, <var>property-scoped contextvar> as <var>local contextvar>,
@@ -3013,9 +3013,20 @@

Algorithm

30133013
<var>nested valuevar> expands to <code>@valuecode>, an
30143014
<a data-link-for="JsonLdErrorCode">invalid @nest valuea> error
30153015
has been detected and processing is aborted.li>
3016-
<li>Recursively repeat steps <a href="#alg-expand-each-key-value">13a>
3016+
<li>Recursively repeat steps
3017+
<a href="#alg-expand-property-scoped-context">3a>,
3018+
<a href="#alg-expand-property-scoped-context2">8a>,
3019+
<a href="#alg-expand-each-key-value">13a>,
30173020
and <a href="#alg-expand-resolve-nest">14a>
3018-
using <var>nested valuevar> for <var>elementvar>.
3021+
using <var>nesting-keyvar> for <var>active propertyvar>, and
3022+
<var>nested valuevar> for <var>elementvar>.
3023+
<div class="note">Steps <a href="#alg-expand-property-scoped-context">3a>
3024+
and <a href="#alg-expand-property-scoped-context2">8a>
3025+
may update the <var>active contextvar> based on a
3026+
property-scoped context associated with <var>nesting-keyvar>.
3027+
Updates to <var>active contextvar> are restricted to the
3028+
recursive operation, and do not propogate to subsequent iterations
3029+
on <var>nested valuevar> and <var>nesting-keyvar>.div>
30193030
<div class="note">By invoking steps <a href="#alg-expand-each-key-value">13a>
30203031
and <a href="#alg-expand-resolve-nest">14a> on <var>nested valuevar>
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 @@

17651765
<dd>
17661766
<dl class='options'>
17671767
<dt>expandContextdt>
1768-
<dd>0077-context.jsonlddd>
1768+
<dd>expand/0077-context.jsonlddd>
17691769
dl>
17701770
dd>
17711771
dl>
@@ -3956,6 +3956,62 @@

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>iddt>
3965+
<dd>#tc034dd>
3966+
<dt>Typedt>
3967+
<dd>jld:PositiveEvaluationTest, jld:ExpandTestdd>
3968+
<dt>Purposedt>
3969+
<dd>Nesting terms may have property-scoped contexts defined.dd>
3970+
<dt>inputdt>
3971+
<dd>
3972+
<a href='expand/c034-in.jsonld'>expand/c034-in.jsonlda>
3973+
dd>
3974+
<dt>expectdt>
3975+
<dd>
3976+
<a href='expand/c034-out.jsonld'>expand/c034-out.jsonlda>
3977+
dd>
3978+
<dt>Optionsdt>
3979+
<dd>
3980+
<dl class='options'>
3981+
<dt>specVersiondt>
3982+
<dd>json-ld-1.1dd>
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>iddt>
3993+
<dd>#tc035dd>
3994+
<dt>Typedt>
3995+
<dd>jld:PositiveEvaluationTest, jld:ExpandTestdd>
3996+
<dt>Purposedt>
3997+
<dd>Nesting terms may have property-scoped contexts defined.dd>
3998+
<dt>inputdt>
3999+
<dd>
4000+
<a href='expand/c035-in.jsonld'>expand/c035-in.jsonlda>
4001+
dd>
4002+
<dt>expectdt>
4003+
<dd>
4004+
<a href='expand/c035-out.jsonld'>expand/c035-out.jsonlda>
4005+
dd>
4006+
<dt>Optionsdt>
4007+
<dd>
4008+
<dl class='options'>
4009+
<dt>specVersiondt>
4010+
<dd>json-ld-1.1dd>
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 @@

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>iddt>
2204+
<dd>#tc034dd>
2205+
<dt>Typedt>
2206+
<dd>jld:PositiveEvaluationTest, jld:ToRDFTestdd>
2207+
<dt>Purposedt>
2208+
<dd>Nesting terms may have property-scoped contexts defined.dd>
2209+
<dt>inputdt>
2210+
<dd>
2211+
<a href='toRdf/c034-in.jsonld'>toRdf/c034-in.jsonlda>
2212+
dd>
2213+
<dt>expectdt>
2214+
<dd>
2215+
<a href='toRdf/c034-out.nq'>toRdf/c034-out.nqa>
2216+
dd>
2217+
<dt>Optionsdt>
2218+
<dd>
2219+
<dl class='options'>
2220+
<dt>specVersiondt>
2221+
<dd>json-ld-1.1dd>
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>iddt>
2232+
<dd>#tc035dd>
2233+
<dt>Typedt>
2234+
<dd>jld:PositiveEvaluationTest, jld:ToRDFTestdd>
2235+
<dt>Purposedt>
2236+
<dd>Nesting terms may have property-scoped contexts defined.dd>
2237+
<dt>inputdt>
2238+
<dd>
2239+
<a href='toRdf/c035-in.jsonld'>toRdf/c035-in.jsonlda>
2240+
dd>
2241+
<dt>expectdt>
2242+
<dd>
2243+
<a href='toRdf/c035-out.nq'>toRdf/c035-out.nqa>
2244+
dd>
2245+
<dt>Optionsdt>
2246+
<dd>
2247+
<dl class='options'>
2248+
<dt>specVersiondt>
2249+
<dd>json-ld-1.1dd>
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 @@

42544310
<dd>
42554311
<dl class='options'>
42564312
<dt>expandContextdt>
4257-
<dd>e077-context.jsonlddd>
4313+
<dd>toRdf/e077-context.jsonlddd>
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 "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)