Skip to content

Commit bc97d88

Browse files
committed
Merge remote-tracking branch 'origin/master' into issue-246-nesting2
# Conflicts: # spec/latest/json-ld-api/index.html # spec/latest/json-ld/index.html # test-suite/tests/compact-manifest.jsonld # test-suite/tests/error-manifest.jsonld # test-suite/tests/expand-manifest.jsonld
2 parents fbae572 + 85bf7dd commit bc97d88

32 files changed

+455
-17
lines changed

spec/latest/common/terms.html

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,14 @@ <h1>General Terminology</h1>
110110
<a>node object</a> or a <a>value object</a> in the input.</dd>
111111
<dt><dfn data-lt="graph names">graph name</dfn></dt><dd>
112112
The <a>IRI</a> identifying a <a>named graph</a>.</dd>
113-
<dt><dfn data-lt="index maps">index map</dfn></dt><dd>
113+
<dt class="changed"><dfn data-lt="id maps">id map</dfn></dt><dd class="changed">
114+
An <a>id map</a> is a <a>JSON object</a> value of a <a>term</a> defined with
115+
<code>@container</code> set to <code>@id</code>, who's keys are
116+
interpreted as <a>IRIs</a> representing the <code>@id</code>
117+
of the associated <a>node object</a>; value MUST be a <a>node object</a>.
118+
If the value contains a property expanding to <code>@id</code>, it's value MUST
119+
be equivalent to the referencing key.</dd>
120+
<dt><dfn data-lt="index maps">index map</dfn></dt><dd>
114121
An <a>index map</a> is a <a>JSON object</a> value of a <a>term</a> defined with
115122
<code>@container</code> set to <code>@index</code>, whose values MUST be any of the following types:
116123
<a>string</a>,
@@ -248,6 +255,14 @@ <h1>General Terminology</h1>
248255
a <a>JSON object</a> as a <a>property</a>, type, or elsewhere that a string is interpreted as a vocabulary item.
249256
Its value is either a string, expanding to an absolute IRI, or an <a>expanded term definition</a>.
250257
</dd>
258+
<dt class="changed"><dfn data-lt="type maps">type map</dfn></dt><dd class="changed">
259+
An <a>type map</a> is a <a>JSON object</a> value of a <a>term</a> defined with
260+
<code>@container</code> set to <code>@type</code>, who's keys are
261+
interpreted as <a>IRIs</a> representing the <code>@type</code>
262+
of the associated <a>node object</a>;
263+
value MUST be a <a>node object</a>, or <a>array</a> of node objects.
264+
If the value contains a property expanding to <code>@type</code>, it's values
265+
are merged with the map value when expanding.</dd>
251266
<dt><dfn>typed literal</dfn></dt><dd>
252267
A <a>typed literal</a> is a <a>literal</a> with an associated <a>IRI</a>
253268
which indicates the literal's datatype. See <cite><a

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

Lines changed: 49 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,7 @@ <h3>Algorithm</h3>
987987
<li>Initialize <em>container</em> to the value associated with the
988988
<code>@container</code> key, which must be either
989989
<code>@list</code>, <code>@set</code>, <code>@index</code>,
990+
<span class="changed"><code>@id</code>, <code>@type</code></span>
990991
or <code>@language</code>. Otherwise, an
991992
<a data-link-for="JsonLdErrorCode">invalid container mapping</a>
992993
has been detected and processing is aborted.</li>
@@ -1483,9 +1484,10 @@ <h3>Algorithm</h3>
14831484
</ol>
14841485
</li>
14851486
<li>Otherwise, if <em>key</em>'s <a>container mapping</a> in
1486-
<em class="changed">term context</em> is <code>@index</code> and
1487+
<em class="changed">term context</em> is <code>@index</code>,
1488+
<span class="changed"><code>@type</code>, or <code>@id</code></span> and
14871489
<em>value</em> is a <a>JSON object</a> then <em>value</em>
1488-
is expanded from an index map as follows:
1490+
is expanded from an map as follows:
14891491
<ol class="algorithm">
14901492
<li>Initialize <em>expanded value</em> to an empty
14911493
<a>array</a>.</li>
@@ -1501,11 +1503,23 @@ <h3>Algorithm</h3>
15011503
<em>key</em> as <a>active property</a>,
15021504
and <em>index value</em> as <em>element</em>.</li>
15031505
<li>For each <em>item</em> in <em>index value</em>:
1504-
<ol class="algorithm">
1505-
<li>If <em>item</em> does not have the key
1506+
<ol class="algorithm changed">
1507+
<li>If <a>container mapping</a> is <code>@index</code>
1508+
and <em>item</em> does not have the key
15061509
<code>@index</code>, add the key-value pair
15071510
(<code>@index</code>-<em>index</em>) to
15081511
<em>item</em>.</li>
1512+
<li>Otherwise, if <a>container mapping</a> is <code>@id</code>
1513+
and <em>item</em> does not have the key
1514+
<code>@id</code>, add the key-value pair
1515+
(<code>@id</code>-<em>index</em>) to
1516+
<em>item</em>.</li>
1517+
<li>Otherwise, if <a>container mapping</a> is <code>@type</code>
1518+
set <em>types</em> to the concatenation of <em>index
1519+
value</em> with any existing values of
1520+
<code>@type</code> in <em>item</em> and add the
1521+
key-value pair (<code>@type</code>-<em>types</em>) to
1522+
<em>item</em>.</li>
15091523
<li>Append <em>item</em> to <em>expanded value</em>.</li>
15101524
</ol>
15111525
</li>
@@ -2048,20 +2062,42 @@ <h3>Algorithm</h3>
20482062
</ol>
20492063
</li>
20502064
<li>
2051-
If <em>container</em> is <code>@language</code> or
2052-
<code>@index</code>:
2065+
If <em>container</em> is <code>@language</code>,
2066+
<code>@index</code>, <span class="changed"><code>@id</code>,
2067+
or <code>@type</code></span>:
20532068
<ol class="algorithm">
20542069
<li>If <em>item active property</em> is not a key in
20552070
<em class="changed">nest result</em>, initialize it to an empty <a>JSON object</a>.
20562071
Initialize <em>map object</em> to the value of <em>item active property</em>
20572072
in <em class="changed">nest result</em>.</li>
2073+
<li>Set <em>compacted container</em> to the result of calling the
2074+
<a href="#iri-compaction">IRI Compaction algorithm</a>
2075+
passing <a>active context</a>,
2076+
<em>container</em> as <em>iri</em>, and <code>true</code>
2077+
for <em>vocab</em>.</li>
2078+
<li>Initialize <em>map key</em> to the value associated with
2079+
with the key that equals <em>container</em> in
2080+
<em>expanded item</em>.</li>
20582081
<li>If <em>container</em> is <code>@language</code> and
20592082
<em>compacted item</em> contains the key
20602083
<code>@value</code>, then set <em>compacted item</em>
20612084
to the value associated with its <code>@value</code> key.</li>
2062-
<li>Initialize <em>map key</em> to the value associated with
2085+
<li>If <em>container</em> is <code>@index</code>,
2086+
set <em>map key</em> to the value associated with
20632087
with the key that equals <em>container</em> in
20642088
<em>expanded item</em>.</li>
2089+
<li class="changed">If <em>container</em> is <code>@id</code>, set
2090+
<em>map key</em> to the value associated with the key that equals
2091+
<em>compacted container</em> in <em>compacted item</em>
2092+
and remove that key-value pair from <em>compacted item</em>.</li>
2093+
<li class="changed">If <em>container</em> is <code>@type</code>,
2094+
set <em>map key</em> to the first value associated with
2095+
the key that equals <em>container</em> in <em>expanded
2096+
item</em>. If there are remaining values in <em>compacted
2097+
item</em> for <em>compacted container</em>, set the value
2098+
of <em>compacted container</em> in <em>compacted
2099+
value</em> to those remaining values. Otherwise, remove
2100+
that key-value pair from <em>compacted item</em>.</li>
20652101
<li>If <em>map key</em> is not a key in <em>map object</em>,
20662102
then set this key's value in <em>map object</em>
20672103
to <em>compacted item</em>. Otherwise, if the value
@@ -2338,9 +2374,10 @@ <h3>Algorithm</h3>
23382374
variables will keep track of the preferred
23392375
<a>type mapping</a> or <a>language mapping</a> for
23402376
a <a>term</a>, based on what is compatible with <em>value</em>.</li>
2341-
<li>If <em>value</em> is a <a>JSON object</a> that contains the
2342-
key <code>@index</code>, then append the value <code>@index</code>
2343-
to <em>containers</em>.</li>
2377+
<li>If <em>value</em> is a <a>JSON object</a>,
2378+
<span class="changed">then for the keywords <code>@index</code>,
2379+
<code>@id</code>, and <code>@type</code>, if <em>value</em>
2380+
contains that <a>keyword</a>, append it to <em>containers</em>.</span></li>
23442381
<li>If <em>reverse</em> is <code>true</code>, set <em>type/language</em>
23452382
to <code>@type</code>, <em>type/language value</em> to
23462383
<code>@reverse</code>, and append <code>@set</code> to <em>containers</em>.</li>
@@ -4271,6 +4308,8 @@ <h2>Changes since 1.0 Recommendation of 16 January 2014</h2>
42714308
<code>@nest</code> mapping. When expanding, the values of a property
42724309
expanding to <code>@nest</code> are treated as if they were contained
42734310
within the enclosing <a>node object</a> directly.</li>
4311+
<li><code>@container</code> values within an <a>expanded term definition</a> may now
4312+
include <code>@id</code> and <code>@type</code>, corresponding to <a>id maps</a> and <a>type maps</a>.</li>
42744313
</ul>
42754314
</section>
42764315

spec/latest/json-ld/index.html

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2585,6 +2585,107 @@ <h2>Data Indexing</h2>
25852585
</table>
25862586
</section>
25872587

2588+
<section class="informative changed">
2589+
<h2>Node Identifier Indexing</h2>
2590+
2591+
<p>In addition to <a>index maps</a>, JSON-LD introduces the notion of <a>id maps</a>
2592+
for structuring data. The id indexing feature allows an author to
2593+
structure data using a simple key-value map where the keys map
2594+
to <a>IRIs</a>. This enables direct access to associated <a>node objects</a>
2595+
instead of having to scan an array in search of a specific item.
2596+
In JSON-LD such data can be specified by associating the
2597+
<code>@id</code> <a>keyword</a> with a
2598+
<code>@container</code> declaration in the context:</p>
2599+
2600+
<pre class="example" data-transform="updateExample"
2601+
title="Indexing data in JSON-LD by node identifiers">
2602+
<!--
2603+
{
2604+
"@context":
2605+
{
2606+
"schema": "http://schema.org/",
2607+
"name": "schema:name",
2608+
"body": "schema:articleBody",
2609+
"words": "schema:wordCount",
2610+
"post": {
2611+
"@id": "schema:blogPost",
2612+
****"@container": "@id"****
2613+
}
2614+
},
2615+
"@id": "http://example.com/",
2616+
"@type": "schema:Blog",
2617+
"name": "World Financial News",
2618+
****"post": {
2619+
"http://example.com/posts/1/en": {
2620+
"body": "World commodities were up today with heavy trading of crude oil...",
2621+
"words": 1539
2622+
},
2623+
"http://example.com/posts/1/de": {
2624+
"body": "Die Werte an Warenbörsen stiegen im Sog eines starken Handels von Rohöl...",
2625+
"words": 1204
2626+
}****
2627+
}
2628+
}
2629+
-->
2630+
</pre>
2631+
2632+
<p>In the example above, the <code>post</code> <a>term</a> has
2633+
been marked as an <a>id map</a>. The <code>http://example.com/posts/1/en</code> and
2634+
<code>http://example.com/posts/1/de</code> keys will be interpreted
2635+
as the <code>@id</code> property of the <a>node object</a> value.</p>
2636+
2637+
<p>The interpretation of the data above is exactly the same
2638+
as that in <a class="sectionRef" href="#data-indexing"></a>
2639+
using a JSON-LD processor.</p>
2640+
</section>
2641+
2642+
<section class="informative changed">
2643+
<h2>Node Type Indexing</h2>
2644+
2645+
<p>In addition to <a data-lt="id map">id</a> and <a>index maps</a>, JSON-LD introduces the notion of <a>type maps</a>
2646+
for structuring data. The type indexing feature allows an author to
2647+
structure data using a simple key-value map where the keys map
2648+
to <a>IRIs</a>. This enables data to be structured based on the <code>@type</code>
2649+
of specific <a>node objects</a>.
2650+
In JSON-LD such data can be specified by associating the
2651+
<code>@type</code> <a>keyword</a> with a
2652+
<code>@container</code> declaration in the context:</p>
2653+
2654+
<pre class="example" data-transform="updateExample"
2655+
title="Indexing data in JSON-LD by node identifiers">
2656+
<!--
2657+
{
2658+
"@context":
2659+
{
2660+
"schema": "http://schema.org/",
2661+
"name": "schema:name",
2662+
"affiliation": {
2663+
"@id": "schema:affiliation",
2664+
****"@container": "@type"****
2665+
}
2666+
},
2667+
"name": "Manu Sporny",
2668+
"affiliation": {
2669+
****"schema:Corporpation"****: {
2670+
"@id": "http://digitalbazaar.com/",
2671+
"name": "Digital Bazaar"
2672+
},
2673+
****"schema:ProfessionalService"****: {
2674+
"@id": "https://spec-ops.io",
2675+
"name": "Spec-Ops"
2676+
}
2677+
2678+
}
2679+
}
2680+
-->
2681+
</pre>
2682+
2683+
<p>In the example above, the <code>affiliation</code> <a>term</a> has
2684+
been marked as an <a>type map</a>. The <code>schema:Corporpation</code> and
2685+
<code>schema:ProfessionalService</code> keys will be interpreted
2686+
as the <code>@type</code> property of the <a>node object</a> value.</p>
2687+
</section>
2688+
25882689
<section class="informative changed">
25892690
<h2>Nested Properties</h2>
25902691

@@ -3274,6 +3375,34 @@ <h2>Index Maps</h2>
32743375
<p>See <a class="sectionRef" href="#data-indexing"></a> for further information on this topic.</p>
32753376
</section>
32763377

3378+
<section class="changed">
3379+
<h2>Id Maps</h2>
3380+
3381+
<p>An <a>id map</a> is used to associate an <a>IRI</a> with a value that allows easy
3382+
programatic access. An <a>id map</a> may be used as a term value within a <a>node object</a> if the <a>term</a>
3383+
is defined with <code>@container</code> set to <code>@id</code>. The keys of an <a>id map</a> MUST be <a>IRIs</a>
3384+
(<a>relative IRI</a>, <a>compact IRI</a> (including <a>blank node identifiers</a>), or <a>absolute IRI</a>)
3385+
and the values MUST be <a>node objects</a>.</p>
3386+
3387+
<p>If the value contains a property expanding to <code>@id</code>, it's value MUST
3388+
be equivalent to the referencing key. Otherwise, the property from the value is used as
3389+
the <code>@id</code> of the <a>node object</a> value when expanding.</p>
3390+
</section>
3391+
3392+
<section class="changed">
3393+
<h2>Type Maps</h2>
3394+
3395+
<p>An <a>type map</a> is used to associate an <a>IRI</a> with a value that allows easy
3396+
programatic access. An <a>id map</a> may be used as a term value within a <a>node object</a> if the <a>term</a>
3397+
is defined with <code>@container</code> set to <code>@id</code>. The keys of an <a>id map</a> MUST be <a>IRIs</a>
3398+
(<a>relative IRI</a>, <a>compact IRI</a> (including <a>blank node identifiers</a>), or <a>absolute IRI</a>)
3399+
and the values MUST be <a>node objects</a>.</p>
3400+
3401+
<p>If the value contains a property expanding to <code>@id</code>, it's value MUST
3402+
be equivalent to the referencing key. Otherwise, the property from the value is used as
3403+
the <code>@id</code> of the <a>node object</a> value when expanding.</p>
3404+
</section>
3405+
32773406
<section class="changed">
32783407
<h2>Property Nesting</h2>
32793408

@@ -3556,6 +3685,8 @@ <h2>Changes since 1.0 Recommendation of 16 January 2014</h2>
35563685
<li>An <a>expanded term definition</a> can now have an
35573686
<code>@context</code> property, which defines a <a>context</a> used for values of
35583687
a <a>property</a> identified with such a <a>term</a>.</li>
3688+
<li><code>@container</code> values within an <a>expanded term definition</a> may now
3689+
include <code>@id</code> and <code>@type</code>, corresponding to <a>id maps</a> and <a>type maps</a>.</li>
35593690
<li>An <a>expanded term definition</a> can now have an
35603691
<code>@nest</code> property, which identifies a term expanding to
35613692
<code>@nest</code> which is used for containing properties using the same

test-suite/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Tests are defined into _compact_, _expand_, _flatten_, _frame_, _normalize_, and
2323
contained within the _sparql_ document using a SPARQL endpoint. The end result is a
2424
yes/no on whether the expected triples were extracted by the JSON-LD processor.
2525

26+
Unless `processingMode` is set explicitly in a test entry, `processingMode` is compatible with both `json-ld-1.0` and `json-ld-1.1`. Otherwise, a JSON-LD 1.0 processor should not run tests marked `json-ld-1.1` and a JSON-LD 1.1 processor should not run tests marked `json-ld-1.0`.
2627

2728
Contributing
2829
------------

test-suite/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,11 @@ <h2 id="design" class="span12" style="text-align: center;">Running the test suit
166166
<p>To run the tests, create a test runner which will run through each test manifest
167167
and execute the tests defined within the manifest using the rules associated with
168168
each <code>@type</code> defined for the test case as defined in <a href="vocab">the test vocabulary</a>.</p>
169+
<p>Unless <code>processingMode</code> is set explicitly in a test entry,
170+
<code>processingMode</code> is compatible with both <code>json-ld-1.0</code> and
171+
<code>json-ld-1.1</code>. Otherwise, a JSON-LD 1.0 processor should not run
172+
tests marked <code>json-ld-1.1</code> and a JSON-LD 1.1 processor should not run
173+
tests marked <code>json-ld-1.0</code>. </p>
169174
<p>Note that property values are typed, and those which are typed as <code>@id</code> must
170175
be treated as IRIs relative to the manifest test base. In particular, this means that
171176
<em>input</em>, </em>context</em>, <em>frame</em>, and <em>expandContext</em> are to be
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example/",
4+
"idmap": {"@container": "@id"}
5+
}
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[{
2+
"http://example/idmap": [
3+
{"http://example/label": [{"@value": "Object with @id _:bar"}], "@id": "_:bar"},
4+
{"http://example/label": [{"@value": "Object with @id <foo>"}], "@id": "http://example.org/foo"}
5+
]
6+
}]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example/",
4+
"idmap": {"@container": "@id"}
5+
},
6+
"idmap": {
7+
"http://example.org/foo": {"label": "Object with @id <foo>"},
8+
"_:bar": {"label": "Object with @id _:bar"}
9+
}
10+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example/",
4+
"idmap": {"@container": "@id"}
5+
}
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[{
2+
"http://example/idmap": [
3+
{"@id": "_:foo", "http://example/label": [{"@value": "Object with @id _:bar"}]},
4+
{"@id": "http://example.org/bar", "http://example/label": [{"@value": "Object with @id <foo>"}]}
5+
]
6+
}]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example/",
4+
"idmap": {"@container": "@id"}
5+
},
6+
"idmap": {
7+
"_:foo": {"label": "Object with @id _:bar"},
8+
"http://example.org/bar": {"label": "Object with @id <foo>"}
9+
}
10+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example/",
4+
"typemap": {"@container": "@type"}
5+
}
6+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[{
2+
"http://example/typemap": [
3+
{"http://example/label": [{"@value": "Object with @type _:bar"}], "@type": ["_:bar"]},
4+
{"http://example/label": [{"@value": "Object with @type <foo>"}], "@type": ["http://example.org/foo"]}
5+
]
6+
}]

0 commit comments

Comments
 (0)