Skip to content

Commit 1812ed9

Browse files
committed
Wrap multiple object values of a term which is a graph container using @included, to make sure they are all contained in a single graph.
Fixes #143.
1 parent e1e989c commit 1812ed9

8 files changed

+99
-17
lines changed

index.html

Lines changed: 25 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2954,13 +2954,13 @@ <h3>Algorithm</h3>
29542954
<li>If <var>container</var> includes <code>@graph</code> and <code>@id</code>:
29552955
<ol>
29562956
<li>Initialize <var>map object</var> to the value of <var>item active property</var>
2957-
in <var class="changed">nest result</var>.</li>
2957+
in <var>nest result</var>.</li>
29582958
<li>Initialize <var>map key</var> to the result of calling the
29592959
<a href="#iri-compaction">IRI Compaction algorithm</a>
29602960
passing <var>active context</var>, <var>inverse context</var>, and the value of <code>@id</code> in <var>expanded item</var>
29612961
or <code>@none</code> if no such value exists as <var>var</var>, with <var>vocab</var> set to <code>true</code>
29622962
if there is no <code>@id</code> <a>entry</a> in <var>expanded item</var>.</li>
2963-
<li class="changed">If <var>compacted item</var> is not an
2963+
<li>If <var>compacted item</var> is not an
29642964
<a>array</a> and <var>as array</var> is <code>true</code>,
29652965
set <var>compacted item</var> to an <a>array</a> containing that value.</li>
29662966
<li>If <var>map key</var> is not an <a>entry</a> in <var>map object</var>,
@@ -2975,11 +2975,11 @@ <h3>Algorithm</h3>
29752975
and <var>expanded item</var> is a <a>simple graph object</a>:
29762976
<ol>
29772977
<li>Initialize <var>map object</var> to the value of <var>item active property</var>
2978-
in <var class="changed">nest result</var>.</li>
2978+
in <var>nest result</var>.</li>
29792979
<li>Initialize <var>map key</var> the value of <code>@index</code> in
29802980
<var>expanded item</var> or <code>@none</code>, if no such
29812981
value exists.</li>
2982-
<li class="changed">If <var>compacted item</var> is not an
2982+
<li>If <var>compacted item</var> is not an
29832983
<a>array</a> and <var>as array</var> is <code>true</code>,
29842984
set <var>compacted item</var> to an <a>array</a> containing that value.</li>
29852985
<li>If <var>map key</var> is not an <a>entry</a> in <var>map object</var>,
@@ -2991,17 +2991,27 @@ <h3>Algorithm</h3>
29912991
</ol>
29922992
</li>
29932993
<li>Otherwise, if <var>container</var> includes <code>@graph</code>
2994-
and <var>expanded item</var> is a <a>simple graph
2995-
object</a> the value cannot be represented as a map
2996-
object. If <var>compacted item</var> is not an <a>array</a>
2997-
and <var>as array</var> is <code>true</code>, set
2998-
<var>compacted item</var> to an <a>array</a> containing
2999-
that value. If the value of an <var>item active property</var> <a>entry</a> in
3000-
<var class="changed">nest result</var> is not an <a>array</a>,
3001-
set it to a new <a>array</a> containing only the value.
3002-
Then append <var>compacted item</var> to the value if
3003-
<var>compacted item</var> is not an <a>array</a>,
3004-
otherwise, concatenate it.
2994+
and <var>expanded item</var> is a <a>simple graph object</a>
2995+
the value cannot be represented as a map object.
2996+
<ol>
2997+
<li>If <var>compacted item</var> is not an <a>array</a>
2998+
and <var>as array</var> is <code>true</code>,
2999+
set <var>compacted item</var> to an <a>array</a> containing that value.</li>
3000+
<li>If <var>compacted item</var> is an <a>array</a>
3001+
with more than one value, it cannot be directly represented,
3002+
as multiple objects would be interpreted as different named graphs.
3003+
Set <var>compacted item</var> to a new <a>map</a>,
3004+
containing the key created by calling the <a href="#iri-compaction">IRI Compaction algorithm</a>
3005+
passing <var>active context</var>, <var>inverse context</var>, `@included` as
3006+
<var>var</var>, and `true` for
3007+
<var>vocab</var> and the original <var>compacted item</var> as the value. </li>
3008+
<li>If the value of an <var>item active property</var> <a>entry</a> in <var>nest result</var>
3009+
is not an <a>array</a>,
3010+
set it to a new <a>array</a> containing only the value.</li>
3011+
<li>Then append <var>compacted item</var> to the value if
3012+
<var>compacted item</var> is not an <a>array</a>,
3013+
otherwise, concatenate it.</li>
3014+
</ol>
30053015
</li>
30063016
<li>Otherwise, <var>container</var> does not include <code>@graph</code>
30073017
or otherwise does not match one of the previous cases, redo <var>compacted item</var>.

tests/compact-manifest.jsonld

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@
800800
}, {
801801
"@id": "#t0096",
802802
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
803-
"name": "Compact @graph container (multiple objects)",
803+
"name": "Compact @graph container (multiple graphs)",
804804
"purpose": "Ensure @graph appears properly in output",
805805
"input": "compact/0096-in.jsonld",
806806
"context": "compact/0096-context.jsonld",
@@ -809,7 +809,7 @@
809809
}, {
810810
"@id": "#t0097",
811811
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
812-
"name": "Compact [@graph, @set] container (multiple objects)",
812+
"name": "Compact [@graph, @set] container (multiple graphs)",
813813
"purpose": "Ensure @graph appears properly in output",
814814
"input": "compact/0097-in.jsonld",
815815
"context": "compact/0097-context.jsonld",
@@ -914,6 +914,24 @@
914914
"input": "compact/0108-in.jsonld",
915915
"context": "compact/0108-context.jsonld",
916916
"expect": "compact/0108-out.jsonld"
917+
}, {
918+
"@id": "#t0109",
919+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
920+
"name": "Compact @graph container (multiple objects)",
921+
"purpose": "Multiple objects in a simple graph with a graph container need to use @included",
922+
"input": "compact/0109-in.jsonld",
923+
"context": "compact/0109-context.jsonld",
924+
"expect": "compact/0109-out.jsonld",
925+
"option": {"processingMode": "json-ld-1.1", "specVersion": "json-ld-1.1"}
926+
}, {
927+
"@id": "#t0110",
928+
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],
929+
"name": "Compact [@graph, @set] container (multiple objects)",
930+
"purpose": "Multiple objects in a simple graph with a graph container need to use @included",
931+
"input": "compact/0110-in.jsonld",
932+
"context": "compact/0110-context.jsonld",
933+
"expect": "compact/0110-out.jsonld",
934+
"option": {"processingMode": "json-ld-1.1", "specVersion": "json-ld-1.1"}
917935
}, {
918936
"@id": "#tc001",
919937
"@type": ["jld:PositiveEvaluationTest", "jld:CompactTest"],

tests/compact/0109-context.jsonld

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"@context": {
3+
"input": {"@id": "foo:input", "@container": "@graph"},
4+
"value": "foo:value"
5+
}
6+
}

tests/compact/0109-in.jsonld

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[{
2+
"foo:input": [{
3+
"@graph": [
4+
{"foo:value": "x"},
5+
{"foo:value": "y"}
6+
]
7+
}]
8+
}]

tests/compact/0109-out.jsonld

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"@context": {
3+
"input": {"@id": "foo:input", "@container": "@graph"},
4+
"value": "foo:value"
5+
},
6+
"input": {
7+
"@included": [{
8+
"value": "x"
9+
}, {
10+
"value": "y"
11+
}]
12+
}
13+
}

tests/compact/0110-context.jsonld

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"@context": {
3+
"input": {"@id": "foo:input", "@container": ["@graph", "@set"]},
4+
"value": "foo:value"
5+
}
6+
}

tests/compact/0110-in.jsonld

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[{
2+
"foo:input": [{
3+
"@graph": [
4+
{"foo:value": "x"},
5+
{"foo:value": "y"}
6+
]
7+
}]
8+
}]

tests/compact/0110-out.jsonld

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"@context": {
3+
"input": {"@id": "foo:input", "@container": ["@graph", "@set"]},
4+
"value": "foo:value"
5+
},
6+
"input": [{
7+
"@included": [{
8+
"value": "x"
9+
}, {
10+
"value": "y"
11+
}]
12+
}]
13+
}

0 commit comments

Comments
 (0)