Skip to content

Commit 83f6332

Browse files
committed
Add term definition and syntactic definition of id maps.
For issue #430. (cherry picked from commit a2a9b9f)
1 parent 3f78a48 commit 83f6332

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed

spec/latest/common/terms.html

Lines changed: 8 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>, who's values MUST be any of the following types:
116123
<a>string</a>,

spec/latest/json-ld/index.html

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2583,6 +2583,60 @@ <h2>Data Indexing</h2>
25832583
</table>
25842584
</section>
25852585

2586+
<section class="informative changed">
2587+
<h2>Node Identifier Indexing</h2>
2588+
2589+
<p>In addition to index maps, JSON-LD introduces the notion of <a>id maps</a>
2590+
for structuring data. The id indexing feature allows an author to
2591+
structure data using a simple key-value map where the keys map
2592+
to <a>IRIs</a>. This enables direct access to associated node objects
2593+
instead of having to scan an array in search of a specific item.
2594+
In JSON-LD such data can be specified by associating the
2595+
<code>@id</code> <a>keyword</a> with a
2596+
<code>@container</code> declaration in the context:</p>
2597+
2598+
<pre class="example" data-transform="updateExample"
2599+
title="Indexing data in JSON-LD by node identifiers">
2600+
<!--
2601+
{
2602+
"@context":
2603+
{
2604+
"schema": "http://schema.org/",
2605+
"name": "schema:name",
2606+
"body": "schema:articleBody",
2607+
"words": "schema:wordCount",
2608+
"post": {
2609+
"@id": "schema:blogPost",
2610+
****"@container": "@id"****
2611+
}
2612+
},
2613+
"@id": "http://example.com/",
2614+
"@type": "schema:Blog",
2615+
"name": "World Financial News",
2616+
****"post": {
2617+
"http://example.com/posts/1/en": {
2618+
"body": "World commodities were up today with heavy trading of crude oil...",
2619+
"words": 1539
2620+
},
2621+
"http://example.com/posts/1/de": {
2622+
"body": "Die Werte an Warenbörsen stiegen im Sog eines starken Handels von Rohöl...",
2623+
"words": 1204
2624+
}****
2625+
}
2626+
}
2627+
-->
2628+
</pre>
2629+
2630+
<p>In the example above, the <strong>post</strong> <a>term</a> has
2631+
been marked as an <a>id map</a>. The <strong>http://example.com/posts/1/en</strong> and
2632+
<strong>http://example.com/posts/1/de</strong> keys will be interpreted
2633+
as the <code>@id</code> property of the <a>node object</a> value.</p>
2634+
2635+
<p>The interpretation of the data above is exactly the same
2636+
as that in <a class="sectionRef" href="#data-indexing"></a>
2637+
using a JSON-LD processor:</p>
2638+
</section>
2639+
25862640
<section class="informative">
25872641
<h3>Expanded Document Form</h3>
25882642

@@ -3186,6 +3240,20 @@ <h2>Index Maps</h2>
31863240
<p>See <a class="sectionRef" href="#data-indexing"></a> for further information on this topic.</p>
31873241
</section>
31883242

3243+
<section class="changed">
3244+
<h2>Id Maps</h2>
3245+
3246+
<p>An <a>id map</a> is used to associate an <a>IRI</a> with a value that allows easy
3247+
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>
3248+
is defined with <code>@container</code> set to <code>@id</code>. The keys of an <a>id map</a> MUST be <a>IRIs</a>
3249+
(<a>relative IRI</a>, <a>compact IRI</a> (including <a>blank node identifiers</a>), or <a>absolute IRI</a>)
3250+
and the values MUST be <a>node objects</a>.</p>
3251+
3252+
<p>If the value contains a property expanding to <code>@id</code>, it's value MUST
3253+
be equivalent to the referencing key. Otherwise, the key is used as
3254+
the <code>@id</code> of the <a>node object</a> value when expanding.</p>
3255+
</section>
3256+
31893257
<section class="normative">
31903258
<h2>Context Definitions</h2>
31913259

0 commit comments

Comments
 (0)