Skip to content

Commit d07e5b8

Browse files
committed
Transform IRIs in @id to relative IRIs, ignore terms in @id
This addresses #204
1 parent 92161f9 commit d07e5b8

24 files changed

+152
-55
lines changed

spec/latest/json-ld-api/index.html

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,9 +1133,9 @@ <h2>IRI Expansion</h2>
11331133
<code class="error">property generator in term definition</code> error.</li>
11341134
</ol>
11351135
</li>
1136-
<li>If an <tref>IRI mapping</tref> exists for <em>value</em> in the <tref>active context</tref>
1137-
that is not a <tref>property generator</tref> return the value of the
1138-
<tref>IRI mapping</tref>.</li>
1136+
<li>If the <em>vocabRelative</em> flag is set to <code>true</code> and an <tref>IRI mapping</tref>
1137+
exists for <em>value</em> in the <tref>active context</tref> that is not a
1138+
<tref>property generator</tref>, return the value of the <tref>IRI mapping</tref>.</li>
11391139
<li>If <em>value</em> contains a colon (<code>:</code>), perform the following steps:
11401140
<ol class="algorithm">
11411141
<li>Split <em>value</em> into a <em>prefix</em> and <em>suffix</em> at the first occurrence of
@@ -1415,8 +1415,8 @@ <h2>IRI Compaction Algorithm</h2>
14151415

14161416
<ol class="algorithm">
14171417
<li>Initialize a variable <em>result</em> to <tref>null</tref>.</li>
1418-
<li>If an entry for <em>iri</em> exists in the <tref>inverse context</tref>,
1419-
perform the following steps:
1418+
<li>If the <em>vocabRelative</em> flag is set to <code>true</code> and an entry for
1419+
<em>iri</em> exists in the <tref>inverse context</tref>, perform the following steps:
14201420
<ol class="algorithm">
14211421
<li>If a <em>value</em> has been passed, perform the following steps:
14221422
<ol class="algorithm">
@@ -1506,15 +1506,18 @@ <h2>IRI Compaction Algorithm</h2>
15061506
<em>termIri</em>, generate a <tref>compact IRI</tref> by concatenating the value
15071507
of the <code>term</code> member of <em>termDefinition</em> with a colon
15081508
(<code>:</code>) character and the unmatched part of <em>iri</em>.</li>
1509-
<li>If the resulting <tref>compact IRI</tref> has an entry in the <tref>active context</tref>,
1510-
continue with the next <em>termIri</em>-<em>termDefinition</em> pair from
1511-
<tref>inverse context</tref> as the <tref>compact IRI</tref> cannot be used.</li>
1509+
<li>If the resulting <tref>compact IRI</tref> has an entry in the <tref>active context</tref>
1510+
and the <em>vocabRelative</em> flag is set to <code>true</code> or the <tref>IRI mapping</tref>
1511+
does not correspond to <em>iri</em>, continue with the next <em>termIri</em>-<em>termDefinition</em>
1512+
pair from <tref>inverse context</tref> as the <tref>compact IRI</tref> cannot be used.</li>
15121513
<li>Otherwise, if result is <tref>null</tref>, return the <tref>compact IRI</tref>; if it is
15131514
not null, set the <code>term</code> member of <em>result</em> to the <tref>compact IRI</tref>
15141515
and return <em>result</em>.</li>
15151516
</ol>
15161517
</li>
1517-
<li>If the <em>vocabRelative</em> flag is set to <code>true</code>, the
1518+
<li>If the <em>vocabRelative</em> flag is set to <code>false</code>, transform <em>iri</em> to an
1519+
IRI relative to the base IRI and return it.</li>
1520+
<li>Otherwise, if the <em>vocabRelative</em> flag is set to <code>true</code>, the
15181521
<tref>active context</tref> has a <tref>vocabulary mapping</tref>, and <em>iri</em>
15191522
begins with the IRI of the <tref>vocabulary mapping</tref> but is longer
15201523
<ol class="algorithm">
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"@context": {
3-
"id1": "http://example.com/id1",
43
"t1": "http://example.com/t1",
54
"t2": "http://example.com/t2",
65
"term1": "http://example.com/term1",
@@ -9,4 +8,4 @@
98
"term4": "http://example.com/term4",
109
"term5": "http://example.com/term5"
1110
}
12-
}
11+
}
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"@context": {
3-
"id1": "http://example.com/id1",
43
"t1": "http://example.com/t1",
54
"t2": "http://example.com/t2",
65
"term1": "http://example.com/term1",
@@ -9,11 +8,11 @@
98
"term4": "http://example.com/term4",
109
"term5": "http://example.com/term5"
1110
},
12-
"@id": "id1",
11+
"@id": "http://example.com/id1",
1312
"@type": "t1",
1413
"term1": "v1",
1514
"term2": {"@value": "v2", "@type": "t2"},
1615
"term3": {"@value": "v3", "@language": "en"},
1716
"term4": 4,
1817
"term5": [50, 51]
19-
}
18+
}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"@context": {
3-
"id1": "http://example.com/id1",
43
"t1": "http://example.com/t1",
54
"t2": "http://example.com/t2",
65
"term1": "http://example.com/term",
@@ -10,4 +9,4 @@
109
"term5": {"@id": "http://example.com/term", "@language": null},
1110
"@language": "de"
1211
}
13-
}
12+
}

test-suite/tests/compact-0015-out.jsonld

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"@context": {
3-
"id1": "http://example.com/id1",
43
"t1": "http://example.com/t1",
54
"t2": "http://example.com/t2",
65
"term1": "http://example.com/term",
@@ -10,7 +9,7 @@
109
"term5": {"@id": "http://example.com/term", "@language": null},
1110
"@language": "de"
1211
},
13-
"@id": "id1",
12+
"@id": "http://example.com/id1",
1413
"@type": "t1",
1514
"term1": "v1",
1615
"term2": "v2",

test-suite/tests/compact-0018-context.jsonld

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"@context": {
3-
"id1": "http://example.com/id1",
43
"type1": "http://example.com/t1",
54
"type2": "http://example.com/t2",
65
"@language": "de",

test-suite/tests/compact-0018-out.jsonld

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"@context": {
3-
"id1": "http://example.com/id1",
43
"type1": "http://example.com/t1",
54
"type2": "http://example.com/t2",
65
"@language": "de",
@@ -11,7 +10,7 @@
1110
"term4": { "@id": "http://example.com/term", "@container": "@list", "@type": "type1" },
1211
"term5": { "@id": "http://example.com/term", "@container": "@list", "@type": "type2" }
1312
},
14-
"@id": "id1",
13+
"@id": "http://example.com/id1",
1514
"term": [
1615
"v0.1",
1716
{ "@value": "v0.2", "@language": "en" },

test-suite/tests/compact-0024-context.jsonld

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"@context": {
3-
"id1": "http://example.com/id1",
43
"type1": "http://example.com/t1",
54
"type2": "http://example.com/t2",
65
"@language": "de",

test-suite/tests/compact-0024-out.jsonld

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"@context": {
3-
"id1": "http://example.com/id1",
43
"type1": "http://example.com/t1",
54
"type2": "http://example.com/t2",
65
"@language": "de",
@@ -13,7 +12,7 @@
1312
"termTL1": { "@id": "http://example.com/termType", "@container": "@list", "@type": "type1" },
1413
"termTL2": { "@id": "http://example.com/termType", "@container": "@list", "@type": "type2" }
1514
},
16-
"@id": "id1",
15+
"@id": "http://example.com/id1",
1716
"termLL0": [
1817
"termLL0.1",
1918
"termLL0.2"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"@context": {
3+
"term": "http://example.com/terms-are-not-considered-in-id",
4+
"compact-iris": "http://example.com/compact-iris-",
5+
"property": "http://example.com/property",
6+
"@vocab": "http://example.org/vocab-is-not-considered-for-id"
7+
},
8+
"@id": "term",
9+
"property": [
10+
{
11+
"@id": "compact-iris:are-considered",
12+
"property": "@id supports the following values: relative, absolute, and compact IRIs"
13+
},
14+
{
15+
"@id": "../parent-node",
16+
"property": "relative IRIs get resolved against the document's base IRI"
17+
}
18+
]
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[
2+
{
3+
"@id": "http://json-ld.org/test-suite/tests/term",
4+
"http://example.com/property": [
5+
{
6+
"@id": "http://example.com/compact-iris-are-considered",
7+
"http://example.com/property": [
8+
{ "@value": "@id supports the following values: relative, absolute, and compact IRIs" }
9+
]
10+
},
11+
{
12+
"@id": "http://json-ld.org/test-suite/parent-node",
13+
"http://example.com/property": [
14+
{ "@value": "relative IRIs get resolved against the document's base IRI" }
15+
]
16+
}
17+
]
18+
}
19+
]
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"@context": {
3+
"term": "http://example.com/terms-are-not-considered-in-id",
4+
"compact-iris": "http://example.com/compact-iris-",
5+
"property": "http://example.com/property",
6+
"@vocab": "http://example.org/vocab-is-not-considered-for-id"
7+
},
8+
"@id": "term",
9+
"property": [
10+
{
11+
"@id": "compact-iris:are-considered",
12+
"property": "@id supports the following values: relative, absolute, and compact IRIs"
13+
},
14+
{
15+
"@id": "../parent-node",
16+
"property": "relative IRIs get resolved against the document's base IRI"
17+
}
18+
]
19+
}

test-suite/tests/compact-manifest.jsonld

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,12 @@
277277
"input": "compact-0045-in.jsonld",
278278
"context": "compact-0045-context.jsonld",
279279
"expect": "compact-0045-out.jsonld"
280+
}, {
281+
"@type": ["test:TestCase", "jld:CompactTest"],
282+
"name": "Values of @id are transformed to relative IRIs, terms are ignored",
283+
"input": "compact-0046-in.jsonld",
284+
"context": "compact-0046-context.jsonld",
285+
"expect": "compact-0046-out.jsonld"
280286
}
281287
]
282288
}
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"@context": {
3-
"id1": "http://example.com/id1",
43
"t1": "http://example.com/t1",
54
"t2": "http://example.com/t2",
65
"term1": "http://example.com/term1",
@@ -9,11 +8,11 @@
98
"term4": "http://example.com/term4",
109
"term5": "http://example.com/term5"
1110
},
12-
"@id": "id1",
11+
"@id": "http://example.com/id1",
1312
"@type": "t1",
1413
"term1": "v1",
1514
"term2": {"@value": "v2", "@type": "t2"},
1615
"term3": {"@value": "v3", "@language": "en"},
1716
"term4": 4,
1817
"term5": [50, 51]
19-
}
18+
}

test-suite/tests/expand-0025-in.jsonld

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@
55
"bar": {"@id": "foo:bar", "@type": "@id"},
66
"_": "http://example.com/underscore/"
77
},
8-
"@id": "_",
9-
"bar": ["foo", "foo:bar"]
8+
"@type": [ "foo", "foo:bar", "_" ]
109
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[{
2-
"@id": "http://example.com/underscore/",
3-
"http://example.com/bar": [
4-
{"@id": "http://example.com/foo/"},
5-
{"@id": "http://example.com/bar"}
2+
"@type": [
3+
"http://example.com/foo/",
4+
"http://example.com/bar",
5+
"http://example.com/underscore/"
66
]
7-
}]
7+
}]

test-suite/tests/expand-0038-in.jsonld

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"termId": { "@id": "term", "@type": "@id" },
55
"termTyped": { "@id": "term", "@type": "_:term" }
66
},
7-
"@id": "term",
7+
"@id": "_:term",
88
"@type": "_:term",
99
"term": [
1010
{
11-
"@id": "term",
11+
"@id": "_:term",
1212
"@type": "term",
1313
"termTyped": "typed value term"
1414
},
@@ -31,7 +31,7 @@
3131
],
3232
"termId": [
3333
{
34-
"@id": "term",
34+
"@id": "_:term",
3535
"@type": "term",
3636
"termTyped": "typed value termId"
3737
},
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"@context": {
3+
"term": "http://example.com/terms-are-not-considered-in-id",
4+
"compact-iris": "http://example.com/compact-iris-",
5+
"property": "http://example.com/property",
6+
"@vocab": "http://example.org/vocab-is-not-considered-for-id"
7+
},
8+
"@id": "term",
9+
"property": [
10+
{
11+
"@id": "compact-iris:are-considered",
12+
"property": "@id supports the following values: relative, absolute, and compact IRIs"
13+
},
14+
{
15+
"@id": "../parent-node",
16+
"property": "relative IRIs get resolved against the document's base IRI"
17+
}
18+
]
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
[
2+
{
3+
"@id": "http://json-ld.org/test-suite/tests/term",
4+
"http://example.com/property": [
5+
{
6+
"@id": "http://example.com/compact-iris-are-considered",
7+
"http://example.com/property": [
8+
{ "@value": "@id supports the following values: relative, absolute, and compact IRIs" }
9+
]
10+
},
11+
{
12+
"@id": "http://json-ld.org/test-suite/parent-node",
13+
"http://example.com/property": [
14+
{ "@value": "relative IRIs get resolved against the document's base IRI" }
15+
]
16+
}
17+
]
18+
}
19+
]

test-suite/tests/expand-manifest.jsonld

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,11 @@
241241
"name": "Free-floating values in sets are removed, free-floating lists are kept",
242242
"input": "expand-0047-in.jsonld",
243243
"expect": "expand-0047-out.jsonld"
244+
}, {
245+
"@type": ["test:TestCase", "jld:ExpandTest"],
246+
"name": "Terms are ignored in @id",
247+
"input": "expand-0048-in.jsonld",
248+
"expect": "expand-0048-out.jsonld"
244249
}
245250
]
246251
}
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"@context": {
3-
"id1": "http://example.com/id1",
43
"t1": "http://example.com/t1",
54
"t2": "http://example.com/t2",
65
"term1": "http://example.com/term1",
@@ -9,11 +8,11 @@
98
"term4": "http://example.com/term4",
109
"term5": "http://example.com/term5"
1110
},
12-
"@id": "id1",
11+
"@id": "http://example.com/id1",
1312
"@type": "t1",
1413
"term1": "v1",
1514
"term2": {"@value": "v2", "@type": "t2"},
1615
"term3": {"@value": "v3", "@language": "en"},
1716
"term4": 4,
1817
"term5": [50, 51]
19-
}
18+
}

test-suite/tests/flatten-0025-in.jsonld

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,5 @@
55
"bar": {"@id": "foo:bar", "@type": "@id"},
66
"_": "http://example.com/underscore/"
77
},
8-
"@id": "_",
9-
"bar": ["foo", "foo:bar"]
8+
"@type": ["foo", "foo:bar", "_"]
109
}

0 commit comments

Comments
 (0)