Skip to content

Commit

Permalink
Treat reverse term definitions more like regular definitions
Browse files Browse the repository at this point in the history
This addresses #253
  • Loading branch information
lanthaler committed Jun 11, 2013
1 parent e9458db commit abdaf09
Show file tree
Hide file tree
Showing 16 changed files with 149 additions and 35 deletions.
53 changes: 26 additions & 27 deletions spec/latest/json-ld-api/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1079,10 +1079,27 @@ <h3>Algorithm</h3>
<code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-term-definition">invalid term definition</a></code>
error has been detected and processing is aborted.</li>
<li>Create a new <tref>term definition</tref>, <i>definition</i>.</li>
<li>If <i>value</i> contains the key <code>@type</code>:
<ol class="algorithm">
<li>Initialize <i>type</i> to the value associated with the
<code>@type</code> key, which must be a <tref>string</tref>. Otherwise, an
<code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-type-mapping">invalid type mapping</a></code>
error has been detected and processing is aborted.</li>
<li>Set <i>type</i> to the result of using the
<a href="#iri-expansion">IRI Expansion algorithm</a>, passing
<tref>active context</tref>, <i>type</i> for <i>value</i>,
<tref>true</tref> for <i>vocab</i>,
<tref>false</tref> for <i>document relative</i>,
<tref>local context</tref>, and <i>defined</i>. If the expanded <i>type</i> is
neither <code>@id</code>, nor <code>@vocab</code>, nor an <tref>absolute IRI</tref>, an
<code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-type-mapping">invalid type mapping</a></code>
error has been detected and processing is aborted.</li>
<li>Set the <tref>type mapping</tref> for <i>definition</i> to <i>type</i>.</li>
</ol>
</li>
<li>If <i>value</i> contains the key <code>@reverse</code>:
<ol class="algorithm">
<li>If <i>value</i> contains an <code>@id</code>, an
<code>@type</code>, or an <code>@language</code>, member, an
<li>If <i>value</i> contains an <code>@id</code>, member, an
<code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-reverse-property">invalid reverse property</a></code>
error has been detected and processing is aborted.</li>
<li>If the value associated with the <code>@reverse</code> key
Expand All @@ -1099,14 +1116,12 @@ <h3>Algorithm</h3>
colon (<code>:</code>), an
<code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-IRI-mapping">invalid IRI mapping</a></code>
error has been detected and processing is aborted.</li>
<li>Set the <tref>type mapping</tref> of <i>definition</i> to
<code>@id</code>.</li>
<li>If <i>value</i> contains an <code>@container</code> member,
set the <tref>container mapping</tref> of <i>definition</i>
to <code>@index</code> if that is the value of the
<code>@container</code> member; otherwise an
to its value; if its value is neither <code>@set</code>, nor
<code>@index</code>, nor <tref>null</tref>, an
<code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-reverse-property">invalid reverse property</a></code>
error has been detected (reverse properties only support
error has been detected (reverse properties only support set- and
index-containers) and processing is aborted.</li>
<li>Set the <tref>reverse property</tref> flag of <i>definition</i>
to <tref>true</tref>.</li>
Expand Down Expand Up @@ -1159,24 +1174,6 @@ <h3>Algorithm</h3>
If it does not have a <tref>vocabulary mapping</tref>, an
<code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-IRI-mapping">invalid IRI mapping</a></code>
error been detected and processing is aborted.</li>
<li>If <i>value</i> contains the key <code>@type</code>:
<ol class="algorithm">
<li>Initialize <i>type</i> to the value associated with the
<code>@type</code> key, which must be a <tref>string</tref>. Otherwise, an
<code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-type-mapping">invalid type mapping</a></code>
error has been detected and processing is aborted.</li>
<li>Set <i>type</i> to the result of using the
<a href="#iri-expansion">IRI Expansion algorithm</a>, passing
<tref>active context</tref>, <i>type</i> for <i>value</i>,
<tref>true</tref> for <i>vocab</i>,
<tref>false</tref> for <i>document relative</i>,
<tref>local context</tref>, and <i>defined</i>. If the expanded <i>type</i> is
neither <code>@id</code>, nor <code>@vocab</code>, nor an <tref>absolute IRI</tref>, an
<code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-type-mapping">invalid type mapping</a></code>
error has been detected and processing is aborted.</li>
<li>Set the <tref>type mapping</tref> for <i>definition</i> to <i>type</i>.</li>
</ol>
</li>
<li>If <i>value</i> contains the key <code>@container</code>:
<ol class="algorithm">
<li>Initialize <i>container</i> to the value associated with the
Expand Down Expand Up @@ -1986,9 +1983,11 @@ <h3>Algorithm</h3>
<tref>active context</tref> indicates that <i>property</i> is
a <tref>reverse property</tref>
<ol class="algorithm">
<li>If
<li>If the <tref>term definition</tref> for <i>property</i> in
the <tref>active context</tref> does not have a
<tref>container mapping</tref> of <code>@set</code>,

This comment has been minimized.

Copy link
@dlongley

dlongley Jun 18, 2013

Member

Should this be "has a container mapping of @set OR" ... (instead of "does not have...")?

This comment has been minimized.

Copy link
@lanthaler

lanthaler via email Jun 18, 2013

Author Member
<code class="idlMemberName"><a href="#widl-JsonLdOptions-compactArrays">compactArrays</a></code>
is <tref>false</tref> and <i>value</i> is not an
is <tref>false</tref>, and <i>value</i> is not an
<tref>array</tref>, set <i>value</i> to a new
<tref>array</tref> containing only <i>value</i>.</li>
<li>If <i>property</i> is not a member of
Expand Down
6 changes: 3 additions & 3 deletions spec/latest/json-ld/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3085,9 +3085,9 @@ <h2>Context Definitions</h2>
<tref>expanded term definition</tref> SHOULD NOT contain any other keys.</p>

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

<p>If the term being defined is not a <tref>compact IRI</tref> or
<tref>absolute IRI</tref> and the <tref>active context</tref> does not have an
Expand Down
2 changes: 1 addition & 1 deletion test-suite/tests/compact-0035-context.jsonld
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"@context": {
"name": "http://xmlns.com/foaf/0.1/name",
"isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows" }
"isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows", "@type": "@id" }
}
}
2 changes: 1 addition & 1 deletion test-suite/tests/compact-0035-out.jsonld
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"@context": {
"name": "http://xmlns.com/foaf/0.1/name",
"isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows" }
"isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows", "@type": "@id" }
},
"@id": "http://example.com/people/markus",
"name": "Markus Lanthaler",
Expand Down
6 changes: 6 additions & 0 deletions test-suite/tests/compact-0050-context.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"@context": {
"name": "http://xmlns.com/foaf/0.1/name",
"isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows" }
}
}
16 changes: 16 additions & 0 deletions test-suite/tests/compact-0050-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[
{
"@id": "http://example.com/people/markus",
"@reverse": {
"http://xmlns.com/foaf/0.1/knows": [
{
"@id": "http://example.com/people/dave"
},
{
"@id": "http://example.com/people/gregg"
}
]
},
"http://xmlns.com/foaf/0.1/name": [ { "@value": "Markus Lanthaler" } ]
}
]
12 changes: 12 additions & 0 deletions test-suite/tests/compact-0050-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"@context": {
"name": "http://xmlns.com/foaf/0.1/name",
"isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows" }
},
"@id": "http://example.com/people/markus",
"name": "Markus Lanthaler",
"isKnownBy": [
{ "@id": "http://example.com/people/dave" },
{ "@id": "http://example.com/people/gregg" }
]
}
6 changes: 6 additions & 0 deletions test-suite/tests/compact-0068-context.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"@context": {
"name": "http://xmlns.com/foaf/0.1/name",
"isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows", "@container": "@set" }
}
}
13 changes: 13 additions & 0 deletions test-suite/tests/compact-0068-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{
"@id": "http://example.com/people/markus",
"@reverse": {
"http://xmlns.com/foaf/0.1/knows": [
{
"@id": "http://example.com/people/dave"
}
]
},
"http://xmlns.com/foaf/0.1/name": [ { "@value": "Markus Lanthaler" } ]
}
]
11 changes: 11 additions & 0 deletions test-suite/tests/compact-0068-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"@context": {
"name": "http://xmlns.com/foaf/0.1/name",
"isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows", "@container": "@set" }
},
"@id": "http://example.com/people/markus",
"name": "Markus Lanthaler",
"isKnownBy": [
{ "@id": "http://example.com/people/dave" }
]
}
6 changes: 6 additions & 0 deletions test-suite/tests/compact-0069-context.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"@context": {
"name": "http://xmlns.com/foaf/0.1/name",
"isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows", "@container": "@set" }
}
}
13 changes: 13 additions & 0 deletions test-suite/tests/compact-0069-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[
{
"@id": "http://example.com/people/markus",
"@reverse": {
"http://xmlns.com/foaf/0.1/knows": [
{
"@id": "http://example.com/people/dave"
}
]
},
"http://xmlns.com/foaf/0.1/name": [ { "@value": "Markus Lanthaler" } ]
}
]
11 changes: 11 additions & 0 deletions test-suite/tests/compact-0069-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"@context": {
"name": "http://xmlns.com/foaf/0.1/name",
"isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows", "@container": "@set" }
},
"@id": "http://example.com/people/markus",
"name": "Markus Lanthaler",
"isKnownBy": [
{ "@id": "http://example.com/people/dave" }
]
}
23 changes: 22 additions & 1 deletion test-suite/tests/compact-manifest.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@
}, {
"@id": "#t0035",
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
"name": "Compact pure node references to strings for reverse properties",
"name": "Compact node references to strings for reverse properties using @type: @id",
"input": "compact-0035-in.jsonld",
"context": "compact-0035-context.jsonld",
"expect": "compact-0035-out.jsonld"
Expand Down Expand Up @@ -349,6 +349,13 @@
"input": "compact-0049-in.jsonld",
"context": "compact-0049-context.jsonld",
"expect": "compact-0049-out.jsonld"
}, {
"@id": "#t0050",
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
"name": "Node references in reverse properties are not compacted to strings without explicit type-coercion",
"input": "compact-0050-in.jsonld",
"context": "compact-0050-context.jsonld",
"expect": "compact-0050-out.jsonld"
}, {
"@id": "#t0051",
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
Expand Down Expand Up @@ -468,6 +475,20 @@
"input": "compact-0067-in.jsonld",
"context": "compact-0067-context.jsonld",
"expect": "compact-0067-out.jsonld"
}, {
"@id": "#t0068",
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
"name": "Single values of reverse properties are compacted as values of ordinary properties",
"input": "compact-0068-in.jsonld",
"context": "compact-0068-context.jsonld",
"expect": "compact-0068-out.jsonld"
}, {
"@id": "#t0069",
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
"name": "Single values are kept in array form for reverse properties if the container is to @set",
"input": "compact-0069-in.jsonld",
"context": "compact-0069-context.jsonld",
"expect": "compact-0069-out.jsonld"
}
]
}
2 changes: 1 addition & 1 deletion test-suite/tests/expand-0049-in.jsonld
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"@context": {
"name": "http://xmlns.com/foaf/0.1/name",
"isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows" }
"isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows", "@type": "@id" }
},
"@id": "http://example.com/people/markus",
"name": "Markus Lanthaler",
Expand Down
2 changes: 1 addition & 1 deletion test-suite/tests/toRdf-0089-in.jsonld
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"@context": {
"name": "http://xmlns.com/foaf/0.1/name",
"isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows" }
"isKnownBy": { "@reverse": "http://xmlns.com/foaf/0.1/knows", "@type": "@id" }
},
"@id": "http://example.com/people/markus",
"name": "Markus Lanthaler",
Expand Down

0 comments on commit abdaf09

Please sign in to comment.