Skip to content

Commit abdaf09

Browse files
committed
Treat reverse term definitions more like regular definitions
This addresses #253
1 parent e9458db commit abdaf09

16 files changed

+149
-35
lines changed

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

Lines changed: 26 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1079,10 +1079,27 @@ <h3>Algorithm</h3>
10791079
<code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-term-definition">invalid term definition</a></code>
10801080
error has been detected and processing is aborted.</li>
10811081
<li>Create a new <tref>term definition</tref>, <i>definition</i>.</li>
1082+
<li>If <i>value</i> contains the key <code>@type</code>:
1083+
<ol class="algorithm">
1084+
<li>Initialize <i>type</i> to the value associated with the
1085+
<code>@type</code> key, which must be a <tref>string</tref>. Otherwise, an
1086+
<code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-type-mapping">invalid type mapping</a></code>
1087+
error has been detected and processing is aborted.</li>
1088+
<li>Set <i>type</i> to the result of using the
1089+
<a href="#iri-expansion">IRI Expansion algorithm</a>, passing
1090+
<tref>active context</tref>, <i>type</i> for <i>value</i>,
1091+
<tref>true</tref> for <i>vocab</i>,
1092+
<tref>false</tref> for <i>document relative</i>,
1093+
<tref>local context</tref>, and <i>defined</i>. If the expanded <i>type</i> is
1094+
neither <code>@id</code>, nor <code>@vocab</code>, nor an <tref>absolute IRI</tref>, an
1095+
<code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-type-mapping">invalid type mapping</a></code>
1096+
error has been detected and processing is aborted.</li>
1097+
<li>Set the <tref>type mapping</tref> for <i>definition</i> to <i>type</i>.</li>
1098+
</ol>
1099+
</li>
10821100
<li>If <i>value</i> contains the key <code>@reverse</code>:
10831101
<ol class="algorithm">
1084-
<li>If <i>value</i> contains an <code>@id</code>, an
1085-
<code>@type</code>, or an <code>@language</code>, member, an
1102+
<li>If <i>value</i> contains an <code>@id</code>, member, an
10861103
<code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-reverse-property">invalid reverse property</a></code>
10871104
error has been detected and processing is aborted.</li>
10881105
<li>If the value associated with the <code>@reverse</code> key
@@ -1099,14 +1116,12 @@ <h3>Algorithm</h3>
10991116
colon (<code>:</code>), an
11001117
<code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-IRI-mapping">invalid IRI mapping</a></code>
11011118
error has been detected and processing is aborted.</li>
1102-
<li>Set the <tref>type mapping</tref> of <i>definition</i> to
1103-
<code>@id</code>.</li>
11041119
<li>If <i>value</i> contains an <code>@container</code> member,
11051120
set the <tref>container mapping</tref> of <i>definition</i>
1106-
to <code>@index</code> if that is the value of the
1107-
<code>@container</code> member; otherwise an
1121+
to its value; if its value is neither <code>@set</code>, nor
1122+
<code>@index</code>, nor <tref>null</tref>, an
11081123
<code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-reverse-property">invalid reverse property</a></code>
1109-
error has been detected (reverse properties only support
1124+
error has been detected (reverse properties only support set- and
11101125
index-containers) and processing is aborted.</li>
11111126
<li>Set the <tref>reverse property</tref> flag of <i>definition</i>
11121127
to <tref>true</tref>.</li>
@@ -1159,24 +1174,6 @@ <h3>Algorithm</h3>
11591174
If it does not have a <tref>vocabulary mapping</tref>, an
11601175
<code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-IRI-mapping">invalid IRI mapping</a></code>
11611176
error been detected and processing is aborted.</li>
1162-
<li>If <i>value</i> contains the key <code>@type</code>:
1163-
<ol class="algorithm">
1164-
<li>Initialize <i>type</i> to the value associated with the
1165-
<code>@type</code> key, which must be a <tref>string</tref>. Otherwise, an
1166-
<code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-type-mapping">invalid type mapping</a></code>
1167-
error has been detected and processing is aborted.</li>
1168-
<li>Set <i>type</i> to the result of using the
1169-
<a href="#iri-expansion">IRI Expansion algorithm</a>, passing
1170-
<tref>active context</tref>, <i>type</i> for <i>value</i>,
1171-
<tref>true</tref> for <i>vocab</i>,
1172-
<tref>false</tref> for <i>document relative</i>,
1173-
<tref>local context</tref>, and <i>defined</i>. If the expanded <i>type</i> is
1174-
neither <code>@id</code>, nor <code>@vocab</code>, nor an <tref>absolute IRI</tref>, an
1175-
<code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-type-mapping">invalid type mapping</a></code>
1176-
error has been detected and processing is aborted.</li>
1177-
<li>Set the <tref>type mapping</tref> for <i>definition</i> to <i>type</i>.</li>
1178-
</ol>
1179-
</li>
11801177
<li>If <i>value</i> contains the key <code>@container</code>:
11811178
<ol class="algorithm">
11821179
<li>Initialize <i>container</i> to the value associated with the
@@ -1986,9 +1983,11 @@ <h3>Algorithm</h3>
19861983
<tref>active context</tref> indicates that <i>property</i> is
19871984
a <tref>reverse property</tref>
19881985
<ol class="algorithm">
1989-
<li>If
1986+
<li>If the <tref>term definition</tref> for <i>property</i> in
1987+
the <tref>active context</tref> does not have a
1988+
<tref>container mapping</tref> of <code>@set</code>,
19901989
<code class="idlMemberName"><a href="#widl-JsonLdOptions-compactArrays">compactArrays</a></code>
1991-
is <tref>false</tref> and <i>value</i> is not an
1990+
is <tref>false</tref>, and <i>value</i> is not an
19921991
<tref>array</tref>, set <i>value</i> to a new
19931992
<tref>array</tref> containing only <i>value</i>.</li>
19941993
<li>If <i>property</i> is not a member of

spec/latest/json-ld/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3085,9 +3085,9 @@ <h2>Context Definitions</h2>
30853085
<tref>expanded term definition</tref> SHOULD NOT contain any other keys.</p>
30863086

30873087
<p>If an <tref>expanded term definition</tref> has an <code>@reverse</code> member,
3088-
<code>@id</code>, <code>@type</code>, and <code>@language</code> are not allowed.
3089-
If an <code>@container</code> member exists, its value MUST be <tref>null</tref>
3090-
or <code>@index</code>.</p>
3088+
it MUST NOT have an <code>@id</code> member at the same time. If an
3089+
<code>@container</code> member exists, its value MUST be <tref>null</tref>,
3090+
<code>@set</code>, or <code>@index</code>.</p>
30913091

30923092
<p>If the term being defined is not a <tref>compact IRI</tref> or
30933093
<tref>absolute IRI</tref> and the <tref>active context</tref> does not have an
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"@context": {
33
"name": "http://xmlns.com/foaf/0.1/name",
4-
"isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows" }
4+
"isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows", "@type": "@id" }
55
}
66
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"@context": {
33
"name": "http://xmlns.com/foaf/0.1/name",
4-
"isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows" }
4+
"isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows", "@type": "@id" }
55
},
66
"@id": "http://example.com/people/markus",
77
"name": "Markus Lanthaler",
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"@context": {
3+
"name": "http://xmlns.com/foaf/0.1/name",
4+
"isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows" }
5+
}
6+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
[
2+
{
3+
"@id": "http://example.com/people/markus",
4+
"@reverse": {
5+
"http://xmlns.com/foaf/0.1/knows": [
6+
{
7+
"@id": "http://example.com/people/dave"
8+
},
9+
{
10+
"@id": "http://example.com/people/gregg"
11+
}
12+
]
13+
},
14+
"http://xmlns.com/foaf/0.1/name": [ { "@value": "Markus Lanthaler" } ]
15+
}
16+
]
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"@context": {
3+
"name": "http://xmlns.com/foaf/0.1/name",
4+
"isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows" }
5+
},
6+
"@id": "http://example.com/people/markus",
7+
"name": "Markus Lanthaler",
8+
"isKnownBy": [
9+
{ "@id": "http://example.com/people/dave" },
10+
{ "@id": "http://example.com/people/gregg" }
11+
]
12+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"@context": {
3+
"name": "http://xmlns.com/foaf/0.1/name",
4+
"isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows", "@container": "@set" }
5+
}
6+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[
2+
{
3+
"@id": "http://example.com/people/markus",
4+
"@reverse": {
5+
"http://xmlns.com/foaf/0.1/knows": [
6+
{
7+
"@id": "http://example.com/people/dave"
8+
}
9+
]
10+
},
11+
"http://xmlns.com/foaf/0.1/name": [ { "@value": "Markus Lanthaler" } ]
12+
}
13+
]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"@context": {
3+
"name": "http://xmlns.com/foaf/0.1/name",
4+
"isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows", "@container": "@set" }
5+
},
6+
"@id": "http://example.com/people/markus",
7+
"name": "Markus Lanthaler",
8+
"isKnownBy": [
9+
{ "@id": "http://example.com/people/dave" }
10+
]
11+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"@context": {
3+
"name": "http://xmlns.com/foaf/0.1/name",
4+
"isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows", "@container": "@set" }
5+
}
6+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[
2+
{
3+
"@id": "http://example.com/people/markus",
4+
"@reverse": {
5+
"http://xmlns.com/foaf/0.1/knows": [
6+
{
7+
"@id": "http://example.com/people/dave"
8+
}
9+
]
10+
},
11+
"http://xmlns.com/foaf/0.1/name": [ { "@value": "Markus Lanthaler" } ]
12+
}
13+
]
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"@context": {
3+
"name": "http://xmlns.com/foaf/0.1/name",
4+
"isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows", "@container": "@set" }
5+
},
6+
"@id": "http://example.com/people/markus",
7+
"name": "Markus Lanthaler",
8+
"isKnownBy": [
9+
{ "@id": "http://example.com/people/dave" }
10+
]
11+
}

test-suite/tests/compact-manifest.jsonld

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@
247247
}, {
248248
"@id": "#t0035",
249249
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
250-
"name": "Compact pure node references to strings for reverse properties",
250+
"name": "Compact node references to strings for reverse properties using @type: @id",
251251
"input": "compact-0035-in.jsonld",
252252
"context": "compact-0035-context.jsonld",
253253
"expect": "compact-0035-out.jsonld"
@@ -349,6 +349,13 @@
349349
"input": "compact-0049-in.jsonld",
350350
"context": "compact-0049-context.jsonld",
351351
"expect": "compact-0049-out.jsonld"
352+
}, {
353+
"@id": "#t0050",
354+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
355+
"name": "Node references in reverse properties are not compacted to strings without explicit type-coercion",
356+
"input": "compact-0050-in.jsonld",
357+
"context": "compact-0050-context.jsonld",
358+
"expect": "compact-0050-out.jsonld"
352359
}, {
353360
"@id": "#t0051",
354361
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
@@ -468,6 +475,20 @@
468475
"input": "compact-0067-in.jsonld",
469476
"context": "compact-0067-context.jsonld",
470477
"expect": "compact-0067-out.jsonld"
478+
}, {
479+
"@id": "#t0068",
480+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
481+
"name": "Single values of reverse properties are compacted as values of ordinary properties",
482+
"input": "compact-0068-in.jsonld",
483+
"context": "compact-0068-context.jsonld",
484+
"expect": "compact-0068-out.jsonld"
485+
}, {
486+
"@id": "#t0069",
487+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
488+
"name": "Single values are kept in array form for reverse properties if the container is to @set",
489+
"input": "compact-0069-in.jsonld",
490+
"context": "compact-0069-context.jsonld",
491+
"expect": "compact-0069-out.jsonld"
471492
}
472493
]
473494
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"@context": {
33
"name": "http://xmlns.com/foaf/0.1/name",
4-
"isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows" }
4+
"isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows", "@type": "@id" }
55
},
66
"@id": "http://example.com/people/markus",
77
"name": "Markus Lanthaler",

test-suite/tests/toRdf-0089-in.jsonld

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"@context": {
33
"name": "http://xmlns.com/foaf/0.1/name",
4-
"isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows" }
4+
"isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows", "@type": "@id" }
55
},
66
"@id": "http://example.com/people/markus",
77
"name": "Markus Lanthaler",

0 commit comments

Comments
 (0)