Skip to content

Commit be19a3f

Browse files
committed
Add grammar and algorithm changes to allow @container to be an array including @set along with another container type.
Fixes #269. Fixes #407.
1 parent 0248541 commit be19a3f

12 files changed

+369
-32
lines changed

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

+41-14
Original file line numberDiff line numberDiff line change
@@ -1067,11 +1067,18 @@ <h3>Algorithm</h3>
10671067
<code>@container</code> key, which must be either
10681068
<code>@list</code>, <code>@set</code>, <code>@index</code>,
10691069
<span class="changed"><code>@id</code>, <code>@type</code></span>
1070-
or <code>@language</code>. Otherwise, an
1070+
or <code>@language</code>,
1071+
<span class="changed">
1072+
or an <a>array</a> containing exactly any one of those keyswords,
1073+
or a combination of <code>@set</code> and any of <code>@index</code>,
1074+
<code>@id</code>, <code>@type</code>, <code>@language</code>
1075+
in any order
1076+
</span>.
1077+
Otherwise, an
10711078
<a data-link-for="JsonLdErrorCode">invalid container mapping</a>
10721079
has been detected and processing is aborted.</li>
10731080
<li class="changed">If processingMode is <code>json-ld-1.0</code> and the container value
1074-
is <code>@id</code> or <code>@type</code>, an
1081+
is <code>@id</code> or <code>@type</code>, or is otherwise not a <a>string</a>, an
10751082
<a data-link-for="JsonLdErrorCode">invalid container mapping</a>
10761083
has been detected and processing is aborted.</li>
10771084
<li>Set the <a>container mapping</a> of <em>definition</em> to
@@ -1961,9 +1968,13 @@ <h3>Algorithm</h3>
19611968
</ol>
19621969
</li>
19631970
<li>If <em>result</em> contains only one item (it has a length of
1964-
<code>1</code>), <a>active property</a> has no
1965-
<a>container mapping</a> in <a>active context</a>, and
1966-
<a data-link-for="JsonLdOptions">compactArrays</a>
1971+
<code>1</code>),
1972+
<span class="changed">
1973+
<a>active property</a> is not <code>@graph</code> or <code>@set</code>,
1974+
or the <a>container mapping</a> for <a>active property</a> in
1975+
<a>active context</a> does not include <code>@list</code> or <code>@set</code>,
1976+
</span>
1977+
and <a data-link-for="JsonLdOptions">compactArrays</a>
19671978
is <code>true</code>, set <em>result</em> to its only item.</li>
19681979
<li>Return <em>result</em>.</li>
19691980
</ol>
@@ -2161,7 +2172,13 @@ <h3>Algorithm</h3>
21612172
<li>Initialize <em>container</em> to <code>null</code>. If there
21622173
is a <a>container mapping</a> for
21632174
<em>item active property</em> in <a>active context</a>,
2164-
set <em>container</em> to its value.</li>
2175+
set <em>container</em> to <span class="changed">the first</span>
2176+
such value <span class="changed">other than <code>@set</code></span>.</li>
2177+
<li class="changed">Initialize <em>as array</em> to
2178+
<code>true</code> or <code>false</code> depending on if the <a>container mapping</a> for
2179+
<em>item active property</em> in <a>active context</a>
2180+
includes <code>@set</code> or if <em>item active property</em>
2181+
is <code>@graph</code> or <code>@list</code>.</li>
21652182
<li>Initialize <em>compacted item</em> to the result of using
21662183
this algorithm recursively, passing
21672184
<a>active context</a>, <a>inverse context</a>,
@@ -2204,7 +2221,7 @@ <h3>Algorithm</h3>
22042221
</ol>
22052222
</li>
22062223
<li>
2207-
If <em>container</em> is <code>@language</code>,
2224+
If <em>container</em> <span class="changed">includes</span> <code>@language</code>,
22082225
<code>@index</code>, <span class="changed"><code>@id</code>,
22092226
or <code>@type</code></span>:
22102227
<ol class="algorithm">
@@ -2242,6 +2259,9 @@ <h3>Algorithm</h3>
22422259
<em>compacted container</em> in <em>compacted value</em>
22432260
to those remaining values. Otherwise, remove that
22442261
key-value pair from <em>compacted item</em>.</li>
2262+
<li class="changed">If <em>compacted item</em> is not an
2263+
<a>array</a> and <em>as array</em> is <code>true</code>,
2264+
set <em>compacted item</em> to an <a>array</a> containing that value.</li>
22452265
<li>If <em>map key</em> is not a key in <em>map object</em>,
22462266
then set this key's value in <em>map object</em>
22472267
to <em>compacted item</em>. Otherwise, if the value
@@ -2255,9 +2275,7 @@ <h3>Algorithm</h3>
22552275
<ol class="algorithm">
22562276
<li>If
22572277
<a data-link-for="JsonLdOptions">compactArrays</a>
2258-
is <code>false</code>, <em>container</em> is <code>@set</code> or
2259-
<code>@list</code>, or <em>expanded property</em> is
2260-
<code>@list</code> or <code>@graph</code> and
2278+
is <code>false</code>, <em>as array</em> is <code>true</code> and
22612279
<em>compacted item</em> is not an <a>array</a>,
22622280
set it to a new <a>array</a>
22632281
containing only <em>compacted item</em>.</li>
@@ -2362,10 +2380,14 @@ <h3>Algorithm</h3>
23622380
<li>If the <a>term definition</a> is <code>null</code>,
23632381
<a>term</a> cannot be selected during <a>compaction</a>,
23642382
so continue to the next <a>term</a>.</li>
2365-
<li>Initialize <em>container</em> to <code>@none</code>. If there
2366-
is a <a>container mapping</a> in
2367-
<a>term definition</a>, set <em>container</em> to
2368-
its associated value.</li>
2383+
<li>Initialize <em>container</em> to <code>@none</code>. If
2384+
<span class="changed">
2385+
the <a>container mapping</a> in <a>term definition</a>
2386+
includes <code>@id</code>, <code>@index</code>,
2387+
<code>@language</code>, <code>@list</code>, <code>@type</code>, or
2388+
<code>@set</code> in that order</span>
2389+
set <em>container</em> to
2390+
<span class="changed">the first such value found</span>.</li>
23692391
<li>Initialize <em>iri</em> to the value of the <a>IRI mapping</a>
23702392
for the <a>term definition</a>.</li>
23712393
<li>If <em>iri</em> is not a key in <em>result</em>, add
@@ -4507,6 +4529,11 @@ <h2>Changes since 1.0 Recommendation of 16 January 2014</h2>
45074529
<li>The JSON syntax has been abstracted into an <a>internal representation</a>
45084530
to allow for other seriazation formats that are functionally equivalent
45094531
to JSON.</li>
4532+
<li>The value for <code>@container</code> in an <a>expanded term definition</a>
4533+
can also be an <a>array</a> containing any appropriate container
4534+
keyword along with <code>@set</code> (other than <code>@list</code>).
4535+
This allows a way to ensure that such property values will always
4536+
be expressed in <a>array</a> form.</li>
45104537
</ul>
45114538
</section>
45124539

0 commit comments

Comments
 (0)