Skip to content

Commit c4a0c31

Browse files
committed
Add tests and spec text for scoped-contexts on @nest alias.
For #380
1 parent 7039b65 commit c4a0c31

File tree

5 files changed

+142
-4
lines changed

5 files changed

+142
-4
lines changed

index.html

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2444,7 +2444,7 @@ <h3>Algorithm</h3>
24442444
<li>If <var>element</var> is <code>null</code>, return <code>null</code>.</li>
24452445
<li class="changed">If <var>active property</var> is <code>@default</code>,
24462446
initialize the {{JsonLdOptions/frameExpansion}} flag to <code>false</code>.</li>
2447-
<li class="changed">If <var>active property</var> has a <a>term definition</a> in <var>active context</var>
2447+
<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>
24482448
with a <a>local context</a>, initialize <var>property-scoped context</var> to that <a>local context</a>.</li>
24492449
<li>If <var>element</var> is a <a>scalar</a>,
24502450
<ol>
@@ -2498,7 +2498,7 @@ <h3>Algorithm</h3>
24982498
(where <a>entries</a> are <span class="changed"><a data-lt="IRI expanding">IRI expanded</a></span>,
24992499
set <var>active context</var> to <a>previous context</a> from <var>active context</var>,
25002500
as the scope of a term-scoped <a>context</a> does not apply when processing new <a>node objects</a>.</li>
2501-
<li id="alg-expand-property-scoped-context" class="changed">If <var>property-scoped context</var> is defined,
2501+
<li id="alg-expand-property-scoped-context2" id="alg-expand-property-scoped-context" class="changed">If <var>property-scoped context</var> is defined,
25022502
set <var>active context</var> to the result of the
25032503
<a href="#context-processing-algorithm">Context Processing algorithm</a>,
25042504
passing <var>active context</var>, <var>property-scoped context</var> as <var>local context</var>,
@@ -3033,9 +3033,20 @@ <h3>Algorithm</h3>
30333033
<var>nested value</var> expands to <code>@value</code>, an
30343034
<a data-link-for="JsonLdErrorCode">invalid @nest value</a> error
30353035
has been detected and processing is aborted.</li>
3036-
<li>Recursively repeat steps <a href="#alg-expand-each-key-value">13</a>
3036+
<li>Recursively repeat steps
3037+
<a href="#alg-expand-property-scoped-context">3</a>,
3038+
<a href="#alg-expand-property-scoped-context2">8</a>,
3039+
<a href="#alg-expand-each-key-value">13</a>,
30373040
and <a href="#alg-expand-resolve-nest">14</a>
3038-
using <var>nested value</var> for <var>element</var>.
3041+
using <var>nesting-key</var> for <var>active property</var>, and
3042+
<var>nested value</var> for <var>element</var>.
3043+
<div class="note">Steps <a href="#alg-expand-property-scoped-context">3</a>
3044+
and <a href="#alg-expand-property-scoped-context2">8</a>
3045+
may update the <var>active context</var> based on a
3046+
property-scoped context associated with <var>nesting-key</var>.
3047+
Updates to <var>active context</var> are restricted to the
3048+
recursive operation, and do not propogate to subsequent iterations
3049+
on <var>nested value</var> and <var>nesting-key</var>.</div>
30393050
<div class="note">By invoking steps <a href="#alg-expand-each-key-value">13</a>
30403051
and <a href="#alg-expand-resolve-nest">14</a> on <var>nested value</var>
30413052
we are able to unfold arbitrary levels of nesting, with results being merged into

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/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/toRdf/c035-out.nq

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<http://example.org/base/book/one> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://purl.org/ontology/bibo/Book> .
2+
<http://example.org/base/book/one> <http://purl.org/dc/terms/published> "1999" .
3+
<http://example.org/base/book/one> <http://purl.org/ontology/bibo/isbn> "1234567890" .
4+
<http://example.org/base/book/one> <http://purl.org/dc/terms/creator> _:b0 .
5+
<http://example.org/base/book/one> <http://purl.org/dc/terms/publisher> _:b1 .
6+
_:b0 <http://www.w3.org/2000/01/rdf-schema#label> "Some Body" .
7+
_:b1 <http://www.w3.org/2000/01/rdf-schema#label> "PubCorp" .

0 commit comments

Comments
 (0)