Skip to content

Commit a2a9b9f

Browse files
committed
Add term definition and syntactic definition of id maps.
For issue #430.
1 parent 55377aa commit a2a9b9f

File tree

2 files changed

+76
-1
lines changed

2 files changed

+76
-1
lines changed

spec/latest/common/terms.html

+8-1
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,14 @@ <h1>General Terminology</h1>
106106
<a>JSON-LD input</a> using matching and embedding rules.</dd>
107107
<dt><dfn data-lt="graph names">graph name</dfn></dt><dd>
108108
The <a>IRI</a> identifying a <a>named graph</a>.</dd>
109-
<dt><dfn data-lt="index maps">index map</dfn></dt><dd>
109+
<dt><dfn data-lt="id maps">id map</dfn></dt><dd>
110+
An <a>id map</a> is a <a>JSON object</a> value of a <a>term</a> defined with
111+
<code>@container</code> set to <code>@id</code>, who's keys are
112+
interpreted as <a>IRIs</a> representing the <code>@id</code>
113+
of the associated <a>node object</a>; value MUST be a <a>node object</a>.
114+
If the value contains a property expanding to <code>@id</code>, it's value MUST
115+
be equivalent to the referencing key.</dd>
116+
<dt><dfn data-lt="index maps">index map</dfn></dt><dd>
110117
An <a>index map</a> is a <a>JSON object</a> value of a <a>term</a> defined with
111118
<code>@container</code> set to <code>@index</code>, who's values MUST be any of the following types:
112119
<a>string</a>,

spec/latest/json-ld/index.html

+68
Original file line numberDiff line numberDiff line change
@@ -2488,6 +2488,60 @@ <h2>Data Indexing</h2>
24882488
</table>
24892489
</section>
24902490

2491+
<section class="informative">
2492+
<h2>Node Identifier Indexing</h2>
2493+
2494+
<p>In addition to index maps, JSON-LD introduces the notion of <a>id maps</a>
2495+
for structuring data. The id indexing feature allows an author to
2496+
structure data using a simple key-value map where the keys map
2497+
to <a>IRIs</a>. This enables direct access to associated node objects
2498+
instead of having to scan an array in search of a specific item.
2499+
In JSON-LD such data can be specified by associating the
2500+
<code>@id</code> <a>keyword</a> with a
2501+
<code>@container</code> declaration in the context:</p>
2502+
2503+
<pre class="example" data-transform="updateExample"
2504+
title="Indexing data in JSON-LD by node identifiers">
2505+
<!--
2506+
{
2507+
"@context":
2508+
{
2509+
"schema": "http://schema.org/",
2510+
"name": "schema:name",
2511+
"body": "schema:articleBody",
2512+
"words": "schema:wordCount",
2513+
"post": {
2514+
"@id": "schema:blogPost",
2515+
****"@container": "@id"****
2516+
}
2517+
},
2518+
"@id": "http://example.com/",
2519+
"@type": "schema:Blog",
2520+
"name": "World Financial News",
2521+
****"post": {
2522+
"http://example.com/posts/1/en": {
2523+
"body": "World commodities were up today with heavy trading of crude oil...",
2524+
"words": 1539
2525+
},
2526+
"http://example.com/posts/1/de": {
2527+
"body": "Die Werte an Warenbörsen stiegen im Sog eines starken Handels von Rohöl...",
2528+
"words": 1204
2529+
}****
2530+
}
2531+
}
2532+
-->
2533+
</pre>
2534+
2535+
<p>In the example above, the <strong>post</strong> <a>term</a> has
2536+
been marked as an <a>id map</a>. The <strong>http://example.com/posts/1/en</strong> and
2537+
<strong>http://example.com/posts/1/de</strong> keys will be interpreted
2538+
as the <code>@id</code> property of the <a>node object</a> value.</p>
2539+
2540+
<p>The interpretation of the data above is exactly the same
2541+
as that in <a class="sectionRef" href="#data-indexing"></a>
2542+
using a JSON-LD processor:</p>
2543+
</section>
2544+
24912545
<section class="informative">
24922546
<h3>Expanded Document Form</h3>
24932547

@@ -3091,6 +3145,20 @@ <h2>Index Maps</h2>
30913145
<p>See <a class="sectionRef" href="#data-indexing"></a> for further information on this topic.</p>
30923146
</section>
30933147

3148+
<section>
3149+
<h2>Id Maps</h2>
3150+
3151+
<p>An <a>id map</a> is used to associate an <a>IRI</a> with a value that allows easy
3152+
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>
3153+
is defined with <code>@container</code> set to <code>@id</code>. The keys of an <a>id map</a> MUST be <a>IRIs</a>
3154+
(<a>relative IRI</a>, <a>compact IRI</a> (including <a>blank node identifiers</a>), or <a>absolute IRI</a>)
3155+
and the values MUST be <a>node objects</a>.</p>
3156+
3157+
<p>If the value contains a property expanding to <code>@id</code>, it's value MUST
3158+
be equivalent to the referencing key. Otherwise, the key is used as
3159+
the <code>@id</code> of the <a>node object</a> value when expanding.</p>
3160+
</section>
3161+
30943162
<section class="normative">
30953163
<h2>Context Definitions</h2>
30963164

0 commit comments

Comments
 (0)