Skip to content

Commit 978e69e

Browse files
committed
Describe included blocks.
For #19.
1 parent ab5050d commit 978e69e

File tree

3 files changed

+194
-0
lines changed

3 files changed

+194
-0
lines changed

common/jsonld.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ const jsonld = {
4040
status: 'unofficial',
4141
date: 'January 2014'
4242
},
43+
"JSON.API": {
44+
title: "JSON API",
45+
href: "https://jsonapi.org/format/",
46+
authors: [
47+
'Steve Klabnik',
48+
'Yehuda Katz',
49+
'Dan Gebhardt',
50+
'Tyler Kellen',
51+
'Ethan Resnick'
52+
],
53+
status: 'unofficial',
54+
date: '29 May 2015'
55+
},
4356
"JCS": {
4457
title: "JSON Canonicalization Scheme (JCS)",
4558
href: 'https://tools.ietf.org/html/draft-rundgren-json-canonicalization-scheme-05',

common/terms.html

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,9 @@
225225
A <a>named graph</a> created from the value of a <a>map entry</a>
226226
having an <a>expanded term definition</a>
227227
where <code>@container</code> is set to <code>@graph</code>.</dd>
228+
<dt class="changed"><dfn data-cite="JSON-LD11#dfn-included-block">included block</dfn></dt><dd class="changed">
229+
An <a>included block</a> is an <a>entry</a> in a <a>node object</a> where the key is `@included` or an alias
230+
and the value is one ore more <a>node objects</a>.</dd>
228231
<dt><dfn data-cite="JSON-LD11#dfn-index-map">index map</dfn></dt><dd>
229232
An <a>index map</a> is a <a>map</a> value of a <a>term</a>
230233
defined with <code>@container</code> set to <code>@index</code>,

index.html

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,10 @@ <h2>Syntax Tokens and Keywords</h2>
608608
Used in a <a>context definition</a> to load an external context
609609
within which the containing <a>context definition</a> is merged.
610610
This can be useful to add JSON-LD 1.1 features to JSON-LD 1.0 contexts.</dd>
611+
<dt class="changed">`@included`</dt><dd class="changed">
612+
Used in in a top-level <a>node object</a> to define an <a>included block</a>,
613+
for including secondary <a>node objects</a> within another <a>node object</a>.
614+
</dd>
611615
</dl>
612616

613617
<p>All keys, <a>keywords</a>, and values in JSON-LD are case-sensitive.</p>
@@ -8272,6 +8276,150 @@ <h3>Using the Document Base for the Default Vocabulary</h3>
82728276
</section>
82738277
</section>
82748278

8279+
<section class="informative changed"><h3>Included Nodes</h3>
8280+
<p>Sometimes it is useful to list node objects as part of another node object.
8281+
For instance, to represent a set of resources which are used by some other
8282+
resource.
8283+
In JSON-LD. these resources could all be contained as members of an array,
8284+
but this does not conveniently allow them to share a common context.</p>
8285+
8286+
<p>Included resources are described in
8287+
<a data-cite="JSON.API#fetching-includes">Inclusion of Related Resources</a> of [[[JSON.API]]] [[JSON.API]]
8288+
as a way to include related resources associated with some primary resource.</p>
8289+
8290+
<p>In JSON-LD, <a>included blocks</a> may be used to collect such secondary <a>node objects</a>
8291+
which can be referenced from a primary <a>node object</a>.
8292+
Semantically, this is the same as if the node objects were embedded, or were contained
8293+
in some enclosing <a>array</a>.</p>
8294+
8295+
<p>For an example, consider a node object containing a list of different items,
8296+
some of which share some common elements:</p>
8297+
8298+
<pre class="example input"
8299+
id="included-blocks-to-be-flattened"
8300+
title="Included Blocks"
8301+
data-transform="updateExample">
8302+
<!--
8303+
{
8304+
"@context": {
8305+
"@version": 1.1,
8306+
"@vocab": "http://example.org/",
8307+
"@base": "http://example.org/base/",
8308+
"id": "@id",
8309+
"type": "@type",
8310+
"included": "@included",
8311+
"enum": "http://example.org/enum#",
8312+
"classification": {"@type": "@id"},
8313+
"service": {"@type": "@id"},
8314+
"included": "@included"
8315+
},
8316+
"id": "http://example.org/base/1",
8317+
"type": "Thing-with-Items",
8318+
"items": [{
8319+
"id":"http://example.org/base/2",
8320+
"classification": "enum:c6",
8321+
"service": "enum:s2"
8322+
},####
8323+
3...26 go here####
8324+
{
8325+
"id": "http://example.org/base/27",
8326+
"classification": "enum:c6"
8327+
}],
8328+
"included": [
8329+
{"id": "enum:c6", "type": "Type", "label": "Classification 6"},
8330+
{"id": "enum:s2", "type": "Service", "label": "Login Service"}
8331+
]
8332+
}
8333+
-->
8334+
</pre>
8335+
8336+
<p>When <a>flattened</a>, this will move the `enum:c6` and `enum:s2` elements
8337+
from the <a>included block</a> into the outer <a>array</a>.</p>
8338+
8339+
<aside class="example ds-selector-tabs"
8340+
title="Flattened form for included blocks">
8341+
<div class="selectors">
8342+
<button class="selected" data-selects="flattened">Flattened (Result)</button>
8343+
<button data-selects="statements">Statements</button>
8344+
<button data-selects="turtle">Turtle</button>
8345+
<a class="playground" target="_blank"
8346+
data-result-for="#included-blocks-to-be-flattened"></a>
8347+
</div>
8348+
<pre class="flattened result selected" data-transform="updateExample"
8349+
data-flatten
8350+
data-result-for="Included Blocks">
8351+
<!--
8352+
[{
8353+
"@id": "http://example.org/base/1",
8354+
"@type": ["http://example.org/Thing-with-Items"],
8355+
"http://example.org/items": [
8356+
{"@id": "http://example.org/base/2"},
8357+
{"@id": "http://example.org/base/27"}
8358+
]
8359+
}, {
8360+
"@id": "http://example.org/enum#c6",
8361+
"@type": ["http://example.org/Type"],
8362+
"http://example.org/label": [{"@value": "Classification 6"}]
8363+
}, {
8364+
"@id": "http://example.org/enum#s2",
8365+
"@type": ["http://example.org/Service"],
8366+
"http://example.org/label": [{"@value": "Login Service"}]
8367+
}, {
8368+
"@id": "http://example.org/base/2",
8369+
"http://example.org/classification": [{"@id": "http://example.org/enum#c6"}],
8370+
"http://example.org/service": [{"@id": "http://example.org/enum#s2"}]
8371+
}, {
8372+
"@id": "http://example.org/base/27",
8373+
"http://example.org/classification": [{"@id": "http://example.org/enum#c6"}]
8374+
}
8375+
]
8376+
-->
8377+
</pre>
8378+
<table class="statements"
8379+
data-result-for="Flattened form for included blocks-flattened"
8380+
data-to-rdf>
8381+
<thead><tr><th>Subject</th><th>Property</th><th>Value</th></tr></thead>
8382+
<tbody>
8383+
<tr><td>http://example.org/base/1</td><td>rdf:type</td><td>http://example.org/Thing-with-Items</td></tr>
8384+
<tr><td>http://example.org/base/1</td><td>http://example.org/items</td><td>http://example.org/base/2</td></tr>
8385+
<tr><td>http://example.org/base/1</td><td>http://example.org/items</td><td>http://example.org/base/27</td></tr>
8386+
<tr><td>http://example.org/base/2</td><td>http://example.org/classification</td><td>http://example.org/enum#c6</td></tr>
8387+
<tr><td>http://example.org/base/2</td><td>http://example.org/service</td><td>http://example.org/enum#s2</td></tr>
8388+
<tr><td>http://example.org/base/27</td><td>http://example.org/classification</td><td>http://example.org/enum#c6</td></tr>
8389+
<tr><td>http://example.org/enum#c6</td><td>rdf:type</td><td>http://example.org/Type</td></tr>
8390+
<tr><td>http://example.org/enum#c6</td><td>http://example.org/label</td><td>Classification 6</td></tr>
8391+
<tr><td>http://example.org/enum#s2</td><td>rdf:type</td><td>http://example.org/Service</td></tr>
8392+
<tr><td>http://example.org/enum#s2</td><td>http://example.org/label</td><td>Login Service</td></tr>
8393+
</tbody>
8394+
</table>
8395+
<pre class="turtle"
8396+
data-content-type="text/turtle"
8397+
data-result-for="Flattened form for included blocks-flattened"
8398+
data-transform="updateExample"
8399+
data-to-rdf>
8400+
<!--
8401+
@base <http://example.org/base/> .
8402+
@prefix ex: <http://example.org/> .
8403+
@prefix enum: <http://example.org/enum#> .
8404+
8405+
<1> a ex:Thing-with-Items;
8406+
ex:items <2>, <27> .
8407+
8408+
<2> ex:classification enum:c6;
8409+
ex:service enum:s2 .
8410+
8411+
<27> ex:classification enum:c6 .
8412+
8413+
enum:c6 a ex:Type;
8414+
ex:label "Classification 6" .
8415+
8416+
enum:s2 a ex:Service;
8417+
ex:label "Login Service" .
8418+
-->
8419+
</pre>
8420+
</aside>
8421+
</section>
8422+
82758423
<section class="informative"><h2>Reverse Properties</h2>
82768424

82778425
<p>JSON-LD serializes directed <a>graphs</a>. That means that
@@ -11535,6 +11683,7 @@ <h2>Node Objects</h2>
1153511683
<ul>
1153611684
<li><code>@context</code>,</li>
1153711685
<li><code>@id</code>,</li>
11686+
<li class="changed"><code>@included</code>,</li>
1153811687
<li><code>@graph</code>,</li>
1153911688
<li class="changed"><code>@nest</code>,</li>
1154011689
<li><code>@type</code>,</li>
@@ -11587,6 +11736,11 @@ <h2>Node Objects</h2>
1158711736
a <a>relative IRI</a>, a <a>compact IRI</a>, a <a>blank node identifier</a>,
1158811737
a <a>node object</a> or an <a>array</a> containing a combination of these.</p>
1158911738

11739+
<p class="changed">If the <a>node object</a> contains the <code>@included</code> key,
11740+
its value MUST be an <a>included block</a>.
11741+
See <a class="sectionRef" href="#included-blocks"></a> for further discussion
11742+
on <a>included blocks</a>.</p>
11743+
1159011744
<p>If the <a>node object</a> contains the <code>@index</code> key,
1159111745
its value MUST be a <a>string</a>. See
1159211746
<a class="sectionRef" href="#data-indexing"></a> for further discussion
@@ -11617,6 +11771,7 @@ <h2>Node Objects</h2>
1161711771
<li>an <a>array</a> of zero or more of any of the possibilities above,</li>
1161811772
<li>a <a>language map</a>,</li>
1161911773
<li>an <a>index map</a>,</li>
11774+
<li class="changed">an <a>included block</a></li>
1162011775
<li class="changed">an <a>id map</a>, or</li>
1162111776
<li class="changed">a <a>type map</a></li>
1162211777
</ul>
@@ -11918,6 +12073,16 @@ <h2>Type Maps</h2>
1191812073
added as a <code>@type</code> of the <a>node object</a> value when expanding.</p>
1191912074
</section>
1192012075

12076+
<section class="changed">
12077+
<h2>Included Blocks</h2>
12078+
12079+
<p>An <a>included block</a> is used to provide a set of <a>node objects</a>.
12080+
An <a>included block</a> MAY appear as the value of a member of a node object with the key of `@included`, or an alias.
12081+
An <a>included block</a> is either a <a>node object</a> or an array of <a>node objects</a>.</p>
12082+
12083+
<p>When <a data-lt="expansion">expanding</a>, multiple <a>included blocks</a> will be coalesced into a single <a>included block</a>.</p>
12084+
</section>
12085+
1192112086
<section class="changed">
1192212087
<h2>Property Nesting</h2>
1192312088

@@ -12246,6 +12411,12 @@ <h2>Keywords</h2>
1224612411
This keyword is described further in <a class="sectionRef" href="#context-definitions"></a>,
1224712412
and <a class="sectionRef" href="#default-vocabulary"></a>.
1224812413
</dd>
12414+
<dt><code>@included</code></dt><dd>
12415+
The `@included` keyword MAY be aliased,
12416+
its value MUST be an <a>included block</a>.
12417+
This keyword is described further in <a class="sectionRef" href="#included-nodes"></a>,
12418+
and <a class="sectionRef" href="#included-blocks"></a>.
12419+
</dd>
1224912420
</dl>
1225012421
</section>
1225112422
</section>
@@ -13171,6 +13342,13 @@ <h2>Changes since JSON-LD Community Group Final Report</h2>
1317113342
<li>A context may contain an <code>@import</code> <a>entry</a> used to reference a remote context
1317213343
within a context, allowing <code>JSON-LD 1.1</code> features to be added to contexts originally
1317313344
authored for <code>JSON-LD 1.0</code>.</li>
13345+
<li>A <a>node object</a> may include an <a>included block</a>,
13346+
which is used to contain a set of <a>node objects</a> which are treated
13347+
exactly as if they were <a>node objects</a> defined in an <a>array</a> including the containing
13348+
<a>node object</a>.
13349+
This allows the use of the object form of a JSON-LD document when there is more
13350+
than one <a>node object</a> being defined, and where those <a>node objects</a>
13351+
are not embedded as values of the containing <a>node object</a>.</li>
1317413352
</ul>
1317513353
</section>
1317613354

0 commit comments

Comments
 (0)