Skip to content

Commit d61c842

Browse files
authored
Add tests and spec text for scoped-contexts on @nest alias. (#388)
* Add tests and spec text for scoped-contexts on `@nest` alias. * @pchampin suggestions: Co-Authored-By: Pierre-Antoine Champin <[email protected]> For #380
1 parent 18bc029 commit d61c842

13 files changed

+261
-48
lines changed

.travis.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@ jobs:
1616
- stage: examples
1717
name: "Verify examples are consistent"
1818
language: ruby
19-
rvm: 2.6
19+
rvm: 2.7
20+
before_install:
21+
- 'gem update --system --conservative'
22+
- 'gem update bundler --conservative'
2023
script: "bundle exec rake test"
2124
- stage: links
2225
name: "Check internal links and HTML"
@@ -26,7 +29,10 @@ jobs:
2629
# Because (alas) rawgit is end of life, we'll run this only on the master branch.
2730
if: branch = master
2831
language: ruby
29-
rvm: 2.6
32+
rvm: 2.7
33+
before_install:
34+
- 'gem update --system --conservative'
35+
- 'gem update bundler --conservative'
3036
script:
3137
- docker pull stupchiy/checklink
3238
- docker run -it stupchiy/checklink -b -X '(http|https|mailto):' "https://labs.w3.org/spec-generator/?type=respec&url=https://raw.githack.com/w3c/json-ld-api/${TRAVIS_BRANCH}/index.html?specStatus=WD&shortName=json-ld11-api"

Gemfile.lock

Lines changed: 45 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
GIT
2-
remote: git://github.com/ruby-rdf/json-ld.git
3-
revision: f663709f5a98abca4106730e5139ad2c6aefa0e3
2+
remote: https://github.com/ruby-rdf/json-ld.git
3+
revision: d864b20f6c8bff286a9a12f7c69917105842bc29
44
branch: develop
55
specs:
6-
json-ld (3.1.1)
6+
json-ld (3.1.4)
77
htmlentities (~> 4.3)
88
json-canonicalization (~> 0.2)
99
link_header (~> 0.0, >= 0.0.8)
@@ -20,70 +20,72 @@ GEM
2020
i18n
2121
builder (3.2.4)
2222
colorize (0.8.1)
23-
concurrent-ruby (1.1.6)
24-
connection_pool (2.2.2)
25-
ebnf (1.2.0)
23+
concurrent-ruby (1.1.7)
24+
connection_pool (2.2.3)
25+
ebnf (2.1.2)
26+
htmlentities (~> 4.3)
2627
rdf (~> 3.1)
28+
scanf (~> 1.0)
2729
sxp (~> 1.1)
2830
equivalent-xml (0.6.0)
2931
nokogiri (>= 1.4.3)
30-
haml (5.1.2)
32+
haml (5.2.0)
3133
temple (>= 0.8.0)
3234
tilt
3335
hamster (3.0.0)
3436
concurrent-ruby (~> 1.0)
3537
htmlentities (4.3.4)
36-
i18n (1.8.2)
38+
i18n (1.8.5)
3739
concurrent-ruby (~> 1.0)
3840
json-canonicalization (0.2.0)
39-
json-ld-preloaded (3.1.1)
41+
json-ld-preloaded (3.1.3)
4042
json-ld (~> 3.1)
4143
rdf (~> 3.1)
42-
ld-patch (3.1.0)
43-
ebnf (~> 1.2)
44+
ld-patch (3.1.1)
45+
ebnf (~> 2.0)
4446
rdf (~> 3.1)
4547
rdf-xsd (~> 3.1)
4648
sparql (~> 3.1)
4749
sxp (~> 1.1)
4850
link_header (0.0.8)
49-
linkeddata (3.1.1)
51+
linkeddata (3.1.2)
5052
equivalent-xml (~> 0.6)
5153
json-ld (~> 3.1, >= 3.1.1)
5254
json-ld-preloaded (~> 3.1, >= 3.1.1)
5355
ld-patch (~> 3.1)
5456
nokogiri (~> 1.10)
5557
nokogumbo (~> 2.0)
56-
rdf (~> 3.1, >= 3.1.1)
58+
rdf (~> 3.1, >= 3.1.2)
5759
rdf-aggregate-repo (~> 3.1)
5860
rdf-isomorphic (~> 3.1)
5961
rdf-json (~> 3.1)
6062
rdf-microdata (~> 3.1)
6163
rdf-n3 (~> 3.1)
6264
rdf-normalize (~> 0.4)
63-
rdf-rdfa (~> 3.1)
65+
rdf-rdfa (~> 3.1, >= 3.1.1)
6466
rdf-rdfxml (~> 3.1)
65-
rdf-reasoner (~> 0.6)
67+
rdf-reasoner (~> 0.6, >= 0.6.1)
6668
rdf-tabular (~> 3.1)
6769
rdf-trig (~> 3.1)
6870
rdf-trix (~> 3.1)
69-
rdf-turtle (~> 3.1)
71+
rdf-turtle (~> 3.1, >= 3.1.1)
7072
rdf-vocab (~> 3.1, >= 3.1.2)
7173
rdf-xsd (~> 3.1)
7274
shex (~> 0.6)
73-
sparql (~> 3.1)
75+
sparql (~> 3.1, >= 3.1.1)
7476
sparql-client (~> 3.1)
7577
mini_portile2 (2.4.0)
76-
multi_json (1.14.1)
78+
multi_json (1.15.0)
7779
net-http-persistent (3.1.0)
7880
connection_pool (~> 2.2)
79-
nokogiri (1.10.8)
81+
nokogiri (1.10.10)
8082
mini_portile2 (~> 2.4.0)
8183
nokogumbo (2.0.2)
8284
nokogiri (~> 1.8, >= 1.8.4)
83-
public_suffix (4.0.3)
85+
public_suffix (4.0.6)
8486
rack (2.2.3)
8587
rake (13.0.1)
86-
rdf (3.1.1)
88+
rdf (3.1.6)
8789
hamster (~> 3.0)
8890
link_header (~> 0.0, >= 0.0.8)
8991
rdf-aggregate-repo (3.1.0)
@@ -92,7 +94,7 @@ GEM
9294
rdf (~> 3.1)
9395
rdf-json (3.1.0)
9496
rdf (~> 3.1)
95-
rdf-microdata (3.1.0)
97+
rdf-microdata (3.1.1)
9698
htmlentities (~> 4.3)
9799
nokogiri (~> 1.10)
98100
rdf (~> 3.1)
@@ -103,54 +105,56 @@ GEM
103105
sxp (~> 1.1)
104106
rdf-normalize (0.4.0)
105107
rdf (~> 3.1)
106-
rdf-rdfa (3.1.0)
108+
rdf-rdfa (3.1.2)
107109
haml (~> 5.1)
108110
htmlentities (~> 4.3)
109-
rdf (~> 3.1)
111+
rdf (~> 3.1, >= 3.1.2)
110112
rdf-aggregate-repo (~> 3.1)
113+
rdf-vocab (~> 3.1, >= 3.1.5)
111114
rdf-xsd (~> 3.1)
112115
rdf-rdfxml (3.1.0)
113116
htmlentities (~> 4.3)
114117
rdf (~> 3.1)
115118
rdf-rdfa (~> 3.1)
116119
rdf-xsd (~> 3.1)
117-
rdf-reasoner (0.6.0)
118-
rdf (~> 3.1)
119-
rdf-vocab (~> 3.1)
120+
rdf-reasoner (0.6.2)
121+
rdf (~> 3.1, >= 3.1.2)
122+
rdf-vocab (~> 3.1, >= 3.1.5)
120123
rdf-xsd (~> 3.1)
121-
rdf-tabular (3.1.0)
124+
rdf-tabular (3.1.1)
122125
addressable (~> 2.3)
123126
bcp47 (~> 0.3, >= 0.3.3)
124127
json-ld (~> 3.1)
125128
rdf (~> 3.1)
126129
rdf-vocab (~> 3.1)
127130
rdf-xsd (~> 3.1)
128-
rdf-trig (3.1.0)
129-
ebnf (~> 1.1)
131+
rdf-trig (3.1.1)
132+
ebnf (~> 2.0)
130133
rdf (~> 3.1)
131134
rdf-turtle (~> 3.1)
132135
rdf-trix (3.1.0)
133136
rdf (~> 3.1)
134-
rdf-turtle (3.1.0)
135-
ebnf (~> 1.2)
136-
rdf (~> 3.1)
137-
rdf-vocab (3.1.2)
138-
rdf (~> 3.1)
137+
rdf-turtle (3.1.2)
138+
ebnf (~> 2.0)
139+
rdf (~> 3.1, >= 3.1.2)
140+
rdf-vocab (3.1.8)
141+
rdf (~> 3.1, >= 3.1.2)
139142
rdf-xsd (3.1.0)
140143
rdf (~> 3.1)
141144
redcarpet (3.5.0)
142-
shex (0.6.0)
143-
ebnf (~> 1.2)
145+
scanf (1.0.0)
146+
shex (0.6.1)
147+
ebnf (~> 2.0)
144148
json-ld (~> 3.1)
145149
json-ld-preloaded (~> 3.1)
146150
rdf (~> 3.1)
147151
rdf-xsd (~> 3.1)
148152
sparql (~> 3.1)
149153
sxp (~> 1.1)
150-
sparql (3.1.0)
154+
sparql (3.1.3)
151155
builder (~> 3.2)
152-
ebnf (~> 1.2)
153-
rdf (~> 3.1)
156+
ebnf (>= 1.1)
157+
rdf (~> 3.1, >= 3.1.2)
154158
rdf-aggregate-repo (~> 3.1)
155159
rdf-xsd (~> 3.1)
156160
sparql-client (~> 3.1)
@@ -177,4 +181,4 @@ DEPENDENCIES
177181
redcarpet
178182

179183
BUNDLED WITH
180-
1.17.3
184+
2.1.4

index.html

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2476,7 +2476,7 @@ <h3>Algorithm</h3>
24762476
<li>If <var>element</var> is <code>null</code>, return <code>null</code>.</li>
24772477
<li class="changed">If <var>active property</var> is <code>@default</code>,
24782478
initialize the {{JsonLdOptions/frameExpansion}} flag to <code>false</code>.</li>
2479-
<li class="changed">If <var>active property</var> has a <a>term definition</a> in <var>active context</var>
2479+
<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>
24802480
with a <a>local context</a>, initialize <var>property-scoped context</var> to that <a>local context</a>.</li>
24812481
<li>If <var>element</var> is a <a>scalar</a>,
24822482
<ol>
@@ -2530,7 +2530,7 @@ <h3>Algorithm</h3>
25302530
(where <a>entries</a> are <span class="changed"><a data-lt="IRI expanding">IRI expanded</a></span>,
25312531
set <var>active context</var> to <a>previous context</a> from <var>active context</var>,
25322532
as the scope of a term-scoped <a>context</a> does not apply when processing new <a>node objects</a>.</li>
2533-
<li id="alg-expand-property-scoped-context" class="changed">If <var>property-scoped context</var> is defined,
2533+
<li id="alg-expand-property-scoped-context2" class="changed">If <var>property-scoped context</var> is defined,
25342534
set <var>active context</var> to the result of the
25352535
<a href="#context-processing-algorithm">Context Processing algorithm</a>,
25362536
passing <var>active context</var>, <var>property-scoped context</var> as <var>local context</var>,
@@ -3069,9 +3069,20 @@ <h3>Algorithm</h3>
30693069
<var>nested value</var> expands to <code>@value</code>, an
30703070
<a data-link-for="JsonLdErrorCode">invalid @nest value</a> error
30713071
has been detected and processing is aborted.</li>
3072-
<li>Recursively repeat steps <a href="#alg-expand-each-key-value">13</a>
3072+
<li>Recursively repeat steps
3073+
<a href="#alg-expand-property-scoped-context">3</a>,
3074+
<a href="#alg-expand-property-scoped-context2">8</a>,
3075+
<a href="#alg-expand-each-key-value">13</a>,
30733076
and <a href="#alg-expand-resolve-nest">14</a>
3074-
using <var>nested value</var> for <var>element</var>.
3077+
using <var>nesting-key</var> for <var>active property</var>, and
3078+
<var>nested value</var> for <var>element</var>.
3079+
<div class="note">Steps <a href="#alg-expand-property-scoped-context">3</a>
3080+
and <a href="#alg-expand-property-scoped-context2">8</a>
3081+
may update the <var>active context</var> based on a
3082+
property-scoped context associated with <var>nesting-key</var>.
3083+
Updates to <var>active context</var> are restricted to the
3084+
recursive operation, and do not propogate to subsequent iterations
3085+
on <var>nested values</var> and <var>nesting-key</var>.</div>
30753086
<div class="note">By invoking steps <a href="#alg-expand-each-key-value">13</a>
30763087
and <a href="#alg-expand-resolve-nest">14</a> on <var>nested value</var>
30773088
we are able to unfold arbitrary levels of nesting, with results being merged into

tests/expand-manifest.jsonld

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1266,6 +1266,22 @@
12661266
"input": "expand/c036-in.jsonld",
12671267
"expect": "expand/c036-out.jsonld",
12681268
"option": {"specVersion": "json-ld-1.1"}
1269+
}, {
1270+
"@id": "#tc037",
1271+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
1272+
"name": "property-scoped contexts which are alias of @nest",
1273+
"purpose": "Nesting terms may have property-scoped contexts defined.",
1274+
"input": "expand/c037-in.jsonld",
1275+
"expect": "expand/c037-out.jsonld",
1276+
"option": {"specVersion": "json-ld-1.1"}
1277+
}, {
1278+
"@id": "#tc038",
1279+
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
1280+
"name": "Bibframe example (poor-mans inferrence)",
1281+
"purpose": "Nesting terms may have property-scoped contexts defined.",
1282+
"input": "expand/c038-in.jsonld",
1283+
"expect": "expand/c038-out.jsonld",
1284+
"option": {"specVersion": "json-ld-1.1"}
12691285
}, {
12701286
"@id": "#tdi01",
12711287
"@type": [ "jld:PositiveEvaluationTest", "jld:ExpandTest" ],

tests/expand/c037-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/c037-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/c038-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/c038-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+
}]

0 commit comments

Comments
 (0)