Skip to content

Fix context processing for reverse terms #566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 20, 2023
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -1664,10 +1664,10 @@ <h3>Algorithm</h3>
<li>Set the <a>term definition</a> of <var>term</var> in
<var>active context</var> to <var>definition</var> and the
value associated with <var>defined</var>'s <a>entry</a> <var>term</var> to
<code>true</code> and return.</li>
<code>true</code>.</li>
</ol>
</li>
<li>If <var>value</var> contains the <a>entry</a> <code>@id</code> and its value
<li>Otherwise if <var>value</var> contains the <a>entry</a> <code>@id</code> and its value
does not equal <var>term</var>:
<ol>
<li id="ctd-id-null">If the <code>@id</code> <a>entry</a> of <var>value</var>
Expand Down Expand Up @@ -7109,6 +7109,12 @@ <h2>Changes since Recommendation of 16 July 2020</h2>
<a href="#compaction-algorithm">Compaction Algorithm</a>
step <a href="#alg-compact-12_8_9_6_1">12.8.9.6.1</a> to first expand
<var>container key</var> before compacting it.</li>
<li>
Changed the <a href="#create-term-definition">Create Term Definition</a>
in section 4.2 of the Context Processing Algorithms, to ensure that all
possible features for reverse term definitions are processed. The change
was to remove <q>and return</q> from the end of step 13, and revise step
14 to begin with <q>Otherwise</q>.</li>
</ul>
</section>
<section id="ack"
Expand Down
34 changes: 34 additions & 0 deletions tests/compact-manifest.html
Original file line number Diff line number Diff line change
Expand Up @@ -3212,6 +3212,40 @@ <h2>
</dd>
</dl>
</dd>
<dt id='t0114'>
Test t0114 Reverse term with property based indexed container
</dt>
<dd>
<dl class='entry'>
<dt>id</dt>
<dd>#t0114</dd>
<dt>Type</dt>
<dd>jld:PositiveEvaluationTest, jld:CompactTest</dd>
<dt>Purpose</dt>
<dd>Compaction using a reverse term with @container indexed on a property (round-trip test of expand#t0131)</dd>
<dt>input</dt>
<dd>
<a href='compact/0114-in.jsonld'>compact/0114-in.jsonld</a>
</dd>
<dt>context</dt>
<dd>
<a href='compact/0114-context.jsonld'>compact/0114-context.jsonld</a>
</dd>
<dt>expect</dt>
<dd>
<a href='compact/0114-out.jsonld'>compact/0114-out.jsonld</a>
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>base</dt>
<dd>https://example.org/</dd>
<dt>specVersion</dt>
<dd>json-ld-1.1</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='tc001'>
Test tc001 adding new term
</dt>
Expand Down
9 changes: 9 additions & 0 deletions tests/compact-manifest.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -957,6 +957,15 @@
"input": "compact/0113-in.jsonld",
"context": "compact/0113-context.jsonld",
"expect": "compact/0113-out.jsonld"
}, {
"@id": "#t0114",
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
"name": "Reverse term with property based indexed container",
"purpose": "Compaction using a reverse term with @container indexed on a property (round-trip test of expand#t0131)",
"input": "compact/0114-in.jsonld",
"context": "compact/0114-context.jsonld",
"expect": "compact/0114-out.jsonld",
"option": {"base": "https://example.org/", "specVersion": "json-ld-1.1"}
}, {
"@id": "#tc001",
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
Expand Down
12 changes: 12 additions & 0 deletions tests/compact/0114-context.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"@context": {
"@version": 1.1,
"@base": "https://example.org/",
"@vocab": "https://example.net/ns#",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"statement": {"@reverse": "rdf:subject", "@container": "@index", "@index": "predicate"},
"predicate": {"@id": "rdf:predicate", "@type": "@vocab"},
"term": {"@id": "rdf:object", "@type": "@vocab"},
"addedIn": {"@type": "@id"}
}
}
26 changes: 26 additions & 0 deletions tests/compact/0114-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[
{
"@id": "https://example.org/item/1",
"@reverse": {
"http://www.w3.org/1999/02/22-rdf-syntax-ns#subject": [
{
"https://example.net/ns#addedIn": [
{
"@id": "https://example.org/v1"
}
],
"http://www.w3.org/1999/02/22-rdf-syntax-ns#object": [
{
"@id": "https://example.net/ns#A"
}
],
"http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate": [
{
"@id": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
}
]
}
]
}
}
]
16 changes: 16 additions & 0 deletions tests/compact/0114-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"@context": {
"@version": 1.1,
"@base": "https://example.org/",
"@vocab": "https://example.net/ns#",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"statement": {"@reverse": "rdf:subject", "@container": "@index", "@index": "predicate"},
"predicate": {"@id": "rdf:predicate", "@type": "@vocab"},
"term": {"@id": "rdf:object", "@type": "@vocab"},
"addedIn": {"@type": "@id"}
},
"@id": "item/1",
"statement": {
"rdf:type": {"term": "A", "addedIn": "v1"}
}
}
28 changes: 28 additions & 0 deletions tests/expand-manifest.html
Original file line number Diff line number Diff line change
Expand Up @@ -3215,6 +3215,34 @@ <h2>
</dd>
</dl>
</dd>
<dt id='t0131'>
Test t0131 Reverse term with property based indexed container
</dt>
<dd>
<dl class='entry'>
<dt>id</dt>
<dd>#t0131</dd>
<dt>Type</dt>
<dd>jld:PositiveEvaluationTest, jld:ExpandTest</dd>
<dt>Purpose</dt>
<dd>Expanding a reverse term using @container: @index and @index set to a property</dd>
<dt>input</dt>
<dd>
<a href='expand/0131-in.jsonld'>expand/0131-in.jsonld</a>
</dd>
<dt>expect</dt>
<dd>
<a href='expand/0131-out.jsonld'>expand/0131-out.jsonld</a>
</dd>
<dt>Options</dt>
<dd>
<dl class='options'>
<dt>specVersion</dt>
<dd>json-ld-1.1</dd>
</dl>
</dd>
</dl>
</dd>
<dt id='tc001'>
Test tc001 adding new term
</dt>
Expand Down
8 changes: 8 additions & 0 deletions tests/expand-manifest.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -978,6 +978,14 @@
"purpose": "Verify URI resolution relative to base (without trailing slash, with path) according to RFC 3986",
"input": "expand/0130-in.jsonld",
"expect": "expand/0130-out.jsonld"
}, {
"@id": "#t0131",
"@type": [ "jld:PositiveEvaluationTest", "jld:ExpandTest" ],
"name": "Reverse term with property based indexed container",
"purpose": "Expanding a reverse term using @container: @index and @index set to a property",
"input": "expand/0131-in.jsonld",
"expect": "expand/0131-out.jsonld",
"option": {"specVersion": "json-ld-1.1"}
}, {
"@id": "#tc001",
"@type": ["jld:PositiveEvaluationTest", "jld:ExpandTest"],
Expand Down
16 changes: 16 additions & 0 deletions tests/expand/0131-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"@context": {
"@version": 1.1,
"@base": "https://example.org/",
"@vocab": "https://example.net/ns#",
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
"statement": {"@reverse": "rdf:subject", "@container": "@index", "@index": "predicate"},
"predicate": {"@id": "rdf:predicate", "@type": "@vocab"},
"term": {"@id": "rdf:object", "@type": "@vocab"},
"addedIn": {"@type": "@id"}
},
"@id": "item/1",
"statement": {
"rdf:type": {"term": "A", "addedIn": "v1"}
}
}
26 changes: 26 additions & 0 deletions tests/expand/0131-out.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[
{
"@id": "https://example.org/item/1",
"@reverse": {
"http://www.w3.org/1999/02/22-rdf-syntax-ns#subject": [
{
"https://example.net/ns#addedIn": [
{
"@id": "https://example.org/v1"
}
],
"http://www.w3.org/1999/02/22-rdf-syntax-ns#object": [
{
"@id": "https://example.net/ns#A"
}
],
"http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate": [
{
"@id": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
}
]
}
]
}
}
]
21 changes: 21 additions & 0 deletions tests/toRdf-manifest.html
Original file line number Diff line number Diff line change
Expand Up @@ -1270,6 +1270,27 @@ <h2>
</dd>
</dl>
</dd>
<dt id='t0133'>
Test t0133 Reverse term with property based indexed container
</dt>
<dd>
<dl class='entry'>
<dt>id</dt>
<dd>#t0133</dd>
<dt>Type</dt>
<dd>jld:PositiveEvaluationTest, jld:ToRDFTest</dd>
<dt>Purpose</dt>
<dd>Expanding a reverse term using @container: @index and @index set to a property (from expand#t0131)</dd>
<dt>input</dt>
<dd>
<a href='toRdf/0133-in.jsonld'>toRdf/0133-in.jsonld</a>
</dd>
<dt>expect</dt>
<dd>
<a href='toRdf/0133-out.nq'>toRdf/0133-out.nq</a>
</dd>
</dl>
</dd>
<dt id='tc001'>
Test tc001 adding new term
</dt>
Expand Down
7 changes: 7 additions & 0 deletions tests/toRdf-manifest.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,13 @@
"purpose": "IRI resolution according to RFC3986.",
"input": "toRdf/0132-in.jsonld",
"expect": "toRdf/0132-out.nq"
}, {
"@id": "#t0133",
"@type": ["jld:PositiveEvaluationTest", "jld:ToRDFTest"],
"name": "Reverse term with property based indexed container",
"purpose": "Expanding a reverse term using @container: @index and @index set to a property (from expand#t0131)",
"input": "toRdf/0133-in.jsonld",
"expect": "toRdf/0133-out.nq"
}, {
"@id": "#tc001",
"@type": ["jld:PositiveEvaluationTest", "jld:ToRDFTest"],
Expand Down
26 changes: 26 additions & 0 deletions tests/toRdf/0133-in.jsonld
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
[
{
"@id": "https://example.org/item/1",
"@reverse": {
"http://www.w3.org/1999/02/22-rdf-syntax-ns#subject": [
{
"https://example.net/ns#addedIn": [
{
"@id": "https://example.org/v1"
}
],
"http://www.w3.org/1999/02/22-rdf-syntax-ns#object": [
{
"@id": "https://example.net/ns#A"
}
],
"http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate": [
{
"@id": "http://www.w3.org/1999/02/22-rdf-syntax-ns#type"
}
]
}
]
}
}
]
4 changes: 4 additions & 0 deletions tests/toRdf/0133-out.nq
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
_:b0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#object> <https://example.net/ns#A> .
_:b0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#predicate> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> .
_:b0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#subject> <https://example.org/item/1> .
_:b0 <https://example.net/ns#addedIn> <https://example.org/v1> .