Skip to content

Commit 3f035c7

Browse files
committed
This adds a @nest member to term definitions used for _transparent properties_.
1 parent 327a188 commit 3f035c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+792
-15
lines changed

spec/latest/common/terms.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,10 @@ <h1>General Terminology</h1>
173173
specified via the <code>@context</code> <a>keyword</a>.</dd>
174174
<dt><dfn data-lt="named graphs">named graph</dfn></dt><dd>
175175
A <a>linked data graph</a> that is identified by an <a>IRI</a> or <a>blank node</a>
176+
<dt><dfn data-lt="nested properties">nested property</dfn></dt><dd>
177+
A <a>nested property</a> is a <a>property</a> which is contained within an object referenced by
178+
a semantically meaningless <em>nesting property</em>.
179+
</dd>
176180
(the <a>graph name</a>) and a <a>graph</a>.</dd>
177181
<dt><dfn data-lt="nodes">node</dfn></dt><dd>
178182
Every <a>node</a> is an <a>IRI</a>, a <a>blank node</a>,

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

Lines changed: 72 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ <h3>Algorithm</h3>
903903
</li>
904904
<li>If <em>value</em> contains the key <code>@reverse</code>:
905905
<ol class="algorithm">
906-
<li>If <em>value</em> contains an <code>@id</code>, member, an
906+
<li>If <em>value</em> contains <code>@id</code> or <code>@nest</code>, members, an
907907
<a data-link-for="JsonLdErrorCode">invalid reverse property</a>
908908
error has been detected and processing is aborted.</li>
909909
<li>If the value associated with the <code>@reverse</code> key
@@ -1019,9 +1019,18 @@ <h3>Algorithm</h3>
10191019
of <em>definition</em> to <em>language</em>.</li>
10201020
</ol>
10211021
</li>
1022+
<li class="changed">If <em>value</em> contains the key <code>@nest</code>:
1023+
<ol class="algorithm">
1024+
<li>Initialize <em>nest</em> to the value associated with the
1025+
<code>@nest</code> key, which must be a <a>string</a> and
1026+
must not be a keyword other than <code>@nest</code>. Otherwise, an
1027+
<a data-link-for="JsonLdErrorCode">invalid @nest value</a>
1028+
error has been detected and processing is aborted.</li>
1029+
</ol>
1030+
</li>
10221031
<li>If the value contains any key other than <code>@id</code>,
10231032
<code>@reverse</code>, <code>@container</code>,
1024-
<code>@context</code>, or <code>@type</code>, an
1033+
<code>@context</code>, <code class="changed">@nest</code>, or <code>@type</code>, an
10251034
<a data-link-for="JsonLdErrorCode">invalid term definition</a> error has
10261035
been detected and processing is aborted.</li>
10271036
<li>Set the <a>term definition</a> of <em>term</em> in
@@ -1269,7 +1278,7 @@ <h3>Algorithm</h3>
12691278
passing <a>active context</a> and the value of the
12701279
<code>@context</code> key as <a>local context</a>.</li>
12711280
<li>Initialize an empty <a>JSON object</a>, <em>result</em>.</li>
1272-
<li>For each <em>key</em> and <em>value</em> in <em>element</em>,
1281+
<li id="alg-expand-each-key-value">For each <em>key</em> and <em>value</em> in <em>element</em>,
12731282
ordered lexicographically by <em>key</em>:
12741283
<ol class="algorithm">
12751284
<li>If <em>key</em> is <code>@context</code>, continue to
@@ -1417,6 +1426,10 @@ <h3>Algorithm</h3>
14171426
<li>Continue with the next <em>key</em> from <em>element</em>.</li>
14181427
</ol>
14191428
</li>
1429+
<li class="changed">If <em>expanded property</em> is <code>@nest</code>,
1430+
add <em>key</em> to <em>nests</em>, initializing it to an empty <a>array</a>,
1431+
if necessary.
1432+
Continue with the next <em>key</em> from <em>element</em>.</li>
14201433
<li class="changed">When the <code>frame expansion</code> flag is set,
14211434
if <em>expanded property</em> is any other
14221435
framing keyword (<code>@explicit</code>, <code>@default</code>,
@@ -1545,6 +1558,22 @@ <h3>Algorithm</h3>
15451558
member of <em>result</em>.</li>
15461559
</ol>
15471560
</li>
1561+
<li class="changed">For each key <em>nesting-key</em> in <em>nests</em>
1562+
<ol class="algorithm">
1563+
<li>Set <em>nested values</em> to the value of <em>nesting-key</em>
1564+
in <em>element</em>, ensuring that it is an <a>array</a>.</li>
1565+
<li>For each <em>nested value</em> in <em>nested values</em>:
1566+
<ol class="algorithm">
1567+
<li>If <em>nested value</em> is not a <a>JSON object</a>, or any key within
1568+
<em>nested value</em> expands to <code>@value</code>, an
1569+
<a data-link-for="JsonLdErrorCode">invalid @nest value</a> error
1570+
has been detected and processing is aborted.</li>
1571+
<li>Recursively repeat <a href="#alg-expand-each-key-value">step 7</a>
1572+
using <em>nested value</em> for <em>element</em>.</li>
1573+
</ol>
1574+
</li>
1575+
</ol>
1576+
</li>
15481577
</ol>
15491578
</li>
15501579
<li>If <em>result</em> contains the key <code>@value</code>:
@@ -1928,7 +1957,22 @@ <h3>Algorithm</h3>
19281957
<em>expanded value</em> for <em>value</em>,
19291958
<code>true</code> for <em>vocab</em>, and
19301959
<em>inside reverse</em>.</li>
1931-
<li>If <em>result</em> does not have the key that equals
1960+
<li class="changed">If the <a>term definition</a> for <em>item active property</em>
1961+
in the <em>active context</em> has a <code>@nest</code>
1962+
member, that value (<em>nest term</em>) must be
1963+
<code>@nest</code>, or a <a>term definition</a> in the
1964+
<em>active context</em> that expands to <code>@nest</code>,
1965+
otherwise an <a data-link-for="JsonLdErrorCode">invalid @nest
1966+
value</a> error has been detected, and processing is aborted.
1967+
If <em>result</em> does not have the key that equals <em>nest
1968+
term</em>, initialize it to an empty JSON object (<em>nest
1969+
object</em>). If <em>nest object</em> does not have the key
1970+
that equals <em>item active property</em>, set this key's
1971+
value in <em>nest object</em> to an empty
1972+
<a>array</a>.Otherwise, if the key's value is not an
1973+
<a>array</a>, then set it to one containing only the
1974+
value.</li>
1975+
<li>Otherwise, if <em>result</em> does not have the key that equals
19321976
<em>item active property</em>, set this key's value in
19331977
<em>result</em> to an empty <a>array</a>. Otherwise, if
19341978
the key's value is not an <a>array</a>, then set it
@@ -1948,6 +1992,16 @@ <h3>Algorithm</h3>
19481992
<em>expanded item</em> for <em>value</em>,
19491993
<code>true</code> for <em>vocab</em>, and
19501994
<em>inside reverse</em>.</li>
1995+
<li class="changed">If the <a>term definition</a> for <em>item active property</em>
1996+
in the <em>active context</em> has a <code>@nest</code>
1997+
member, that value (<em>nest term</em>) must be
1998+
<code>@nest</code>, or a <a>term definition</a> in the
1999+
<em>active context</em> that expands to <code>@nest</code>,
2000+
otherwise an <a data-link-for="JsonLdErrorCode">invalid @nest
2001+
value</a> error has been detected, and processing is aborted.
2002+
Set <em>nest result</em> to the value of <em>nest term</em> in <em>result</em>,
2003+
initializing it to a new <a>JSON object</a>, if necessary; otherwise
2004+
set <em>nest result</em> to <em>result</em>.</li>
19512005
<li>Initialize <em>container</em> to <code>null</code>. If there
19522006
is a <a>container mapping</a> for
19532007
<em>item active property</em> in <a>active context</a>,
@@ -1985,7 +2039,7 @@ <h3>Algorithm</h3>
19852039
</ol>
19862040
</li>
19872041
<li>Otherwise, <em>item active property</em> must not be a key
1988-
in <em>result</em> because there cannot be two
2042+
in <em class="changed">nest result</em> because there cannot be two
19892043
<a>list objects</a> associated
19902044
with an <a>active property</a> that has a
19912045
<a>container mapping</a>; a
@@ -1998,9 +2052,9 @@ <h3>Algorithm</h3>
19982052
<code>@index</code>:
19992053
<ol class="algorithm">
20002054
<li>If <em>item active property</em> is not a key in
2001-
<em>result</em>, initialize it to an empty <a>JSON object</a>.
2055+
<em class="changed">nest result</em>, initialize it to an empty <a>JSON object</a>.
20022056
Initialize <em>map object</em> to the value of <em>item active property</em>
2003-
in <em>result</em>.</li>
2057+
in <em class="changed">nest result</em>.</li>
20042058
<li>If <em>container</em> is <code>@language</code> and
20052059
<em>compacted item</em> contains the key
20062060
<code>@value</code>, then set <em>compacted item</em>
@@ -2030,9 +2084,9 @@ <h3>Algorithm</h3>
20302084
<li>If <em>item active property</em> is not a key in
20312085
<em>result</em> then add the key-value pair,
20322086
(<em>item active property</em>-<em>compacted item</em>),
2033-
to <em>result</em>.</li>
2087+
to <em class="changed">nest result</em>.</li>
20342088
<li>Otherwise, if the value associated with the key that
2035-
equals <em>item active property</em> in <em>result</em>
2089+
equals <em>item active property</em> in <em class="changed">nest result</em>
20362090
is not an <a>array</a>, set it to a new
20372091
<a>array</a> containing only the value. Then
20382092
append <em>compacted item</em> to the value if
@@ -4058,6 +4112,7 @@ <h4>JsonLdErrorCode</h4>
40584112
"invalid language mapping",
40594113
"invalid language-tagged string",
40604114
"invalid language-tagged value",
4115+
"invalid @nest value",
40614116
"invalid local context",
40624117
"invalid remote context",
40634118
"invalid reverse property",
@@ -4134,6 +4189,8 @@ <h4>JsonLdErrorCode</h4>
41344189
associated language tag was detected.</dd>
41354190
<dt><dfn>invalid local context</dfn></dt>
41364191
<dd>In invalid <a>local context</a> was detected.</dd>
4192+
<dt class="changed"><dfn>invalid @nest value</dfn></dt>
4193+
<dd class="changed">An invalid value for <code>@nest</code> has been found.</dd>
41374194
<dt><dfn>invalid remote context</dfn></dt>
41384195
<dd>No valid context document has been found for a referenced,
41394196
remote context.</dd>
@@ -4208,6 +4265,12 @@ <h2>Changes since 1.0 Recommendation of 16 January 2014</h2>
42084265
<li>A new <a href="#merge-node-maps" class="sectionRef"></a> is required
42094266
for framing, to create a single graph from the <a data-lt="default graph">default</a>
42104267
and <a>named graphs</a>.</li>
4268+
<li>An <a>expanded term definition</a> can now have an
4269+
<code>@nest</code> property, which identifies a term expanding to
4270+
<code>@nest</code> which is used for containing properties using the same
4271+
<code>@nest</code> mapping. When expanding, the values of a property
4272+
expanding to <code>@nest</code> are treated as if they were contained
4273+
within the enclosing <a>node object</a> directly.</li>
42114274
</ul>
42124275
</section>
42134276

spec/latest/json-ld/index.html

Lines changed: 112 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,8 @@ <h2>Syntax Tokens and Keywords</h2>
395395
<a>IRI</a>. This keyword is described in <a class="sectionRef" href="#default-vocabulary"></a>.</dd>
396396
<dt><code>@graph</code></dt><dd>Used to express a <a>graph</a>.
397397
This keyword is described in <a class="sectionRef" href="#named-graphs"></a>.</dd>
398+
<dt class="changed"><code>@nest</code></dt><dd class="changed">Collects a set of <a>nested properties</a> within
399+
a <a>node object</a>.</dd>
398400
<dt><code>:</code></dt>
399401
<dd>The separator for JSON keys and values that use
400402
<a>compact IRIs</a>.</dd>
@@ -2583,6 +2585,85 @@ <h2>Data Indexing</h2>
25832585
</table>
25842586
</section>
25852587

2588+
<section class="informative changed">
2589+
<h2>Nested Properties</h2>
2590+
2591+
<p>Many JSON APIs separate properties from their entities using an
2592+
intermediate object; in JSON-LD these are called <a>nested properties</a>.
2593+
For example, a set of possible labels may be grouped
2594+
under a common property:</p>
2595+
<pre class="example" data-transform="updateExample"
2596+
title="Nested properties">
2597+
<!--
2598+
{
2599+
"@context": {
2600+
"skos": "http://www.w3.org/2004/02/skos/core#",
2601+
****"labels": "@nest"****,
2602+
"main_label": {"@id": "skos:prefLabel"},
2603+
"other_label": {"@id": "skos:altLabel"},
2604+
"homepage": {"@id": "http://schema.org/description", "@type": "@id"}
2605+
},
2606+
"@id": "http://example.org/myresource",
2607+
"homepage": "http://example.org",
2608+
"labels": {
2609+
"main_label": "This is the main label for my resource",
2610+
"other_label": "This is the other label"
2611+
}
2612+
}
2613+
-->
2614+
</pre>
2615+
2616+
<p>By defining <em>labels</em> using the <a>keyword</a> <code>@nest</code>,
2617+
a <a>JSON-LD processor</a> will ignore the nesting created by using the
2618+
<em>labels</em> property and process the contents as if it were declared
2619+
directly within containing object. In this case, the <em>labels</em>
2620+
property is semantically meaningless. Defining it as equivalent to
2621+
<code>@nest</code> causes it to be ignored when expanding, making it
2622+
equivalent to the following:</p>
2623+
2624+
<pre class="example" data-transform="updateExample"
2625+
title="Nested properties folded into containing object">
2626+
<!--
2627+
{
2628+
"@context": {
2629+
"skos": "http://www.w3.org/2004/02/skos/core#",
2630+
"main_label": {"@id": "skos:prefLabel"},
2631+
"other_label": {"@id": "skos:altLabel"},
2632+
"homepage": {"@id": "http://schema.org/description", "@type": "@id"}
2633+
},
2634+
"@id": "http://example.org/myresource",
2635+
"homepage": "http://example.org",
2636+
****"main_label": "This is the main label for my resource",
2637+
"other_label": "This is the other label"****
2638+
}
2639+
-->
2640+
</pre>
2641+
2642+
<p>Similarly, node definitions may contain a <code>@nest</code> property to
2643+
reference a term aliased to <code>@nest</code> which causes such
2644+
values to be nested under that aliased term.</p>
2645+
<pre class="example" data-transform="updateExample"
2646+
title="Defining property nesting">
2647+
<!--
2648+
{
2649+
"@context": {
2650+
"skos": "http://www.w3.org/2004/02/skos/core#",
2651+
****"labels": "@nest"****,
2652+
"main_label": {"@id": "skos:prefLabel", ****"@nest": "labels"****},
2653+
"other_label": {"@id": "skos:altLabel", ****"@nest": "labels"****},
2654+
"homepage": {"@id": "http://schema.org/description", "@type": "@id"}
2655+
},
2656+
"@id": "http://example.org/myresource",
2657+
"homepage": "http://example.org",
2658+
"labels": {
2659+
"main_label": "This is the main label for my resource",
2660+
"other_label": "This is the other label"
2661+
}
2662+
}
2663+
-->
2664+
</pre>
2665+
</section>
2666+
25862667
<section class="informative">
25872668
<h3>Expanded Document Form</h3>
25882669

@@ -2989,6 +3070,7 @@ <h2>Node Objects</h2>
29893070
<li><code>@context</code>,</li>
29903071
<li><code>@id</code>,</li>
29913072
<li><code>@graph</code>,</li>
3073+
<li class="changed"><code>@nest</code>,</li>
29923074
<li><code>@type</code>,</li>
29933075
<li><code>@reverse</code>, or</li>
29943076
<li><code>@index</code></li>
@@ -3044,6 +3126,12 @@ <h2>Node Objects</h2>
30443126
<a class="sectionRef" href="#data-indexing"></a> for further discussion
30453127
on <code>@index</code> values.</p>
30463128

3129+
<p class="changed">If the <a>node object</a> contains the <code>@nest</code> key,
3130+
its value MUST be an <a>JSON object</a> or an <a>array</a> of <a>JSON objects</a>
3131+
which MUST NOT include a <a>value object</a>. See
3132+
<a class="sectionRef" href="#property-nesting"></a> for further discussion
3133+
on <code>@nest</code> values.</p>
3134+
30473135
<p>Keys in a <a>node object</a> that are not
30483136
<a>keyword</a> MAY expand to an <a>absolute IRI</a>
30493137
using the <a>active context</a>. The values associated with keys that expand
@@ -3186,6 +3274,19 @@ <h2>Index Maps</h2>
31863274
<p>See <a class="sectionRef" href="#data-indexing"></a> for further information on this topic.</p>
31873275
</section>
31883276

3277+
<section class="changed">
3278+
<h2>Property Nesting</h2>
3279+
3280+
<p>A <a>nested property</a> is used to gather <a>properties</a> of a <a>node object</a> in a separate
3281+
<a>JSON object</a>, or <a>array</a> of <a>JSON objects</a> which are not
3282+
<a>value objects</a>. It is semantically transparent and is removed
3283+
during the process of expansion. Property nesting is recursive, and
3284+
collections of nested properties may contain further nesting.</p>
3285+
3286+
<p>Semantically, nesting is treated as if the properties and values were declared directly
3287+
within the containing <a>node object</a>.</p>
3288+
</section>
3289+
31893290
<section class="normative">
31903291
<h2>Context Definitions</h2>
31913292

@@ -3225,7 +3326,7 @@ <h2>Context Definitions</h2>
32253326
<a>expanded term definition</a> SHOULD NOT contain any other keys.</p>
32263327

32273328
<p>If an <a>expanded term definition</a> has an <code>@reverse</code> member,
3228-
it MUST NOT have an <code>@id</code> member at the same time. If an
3329+
it MUST NOT have <code>@id</code> or <code>@nest</code> members at the same time. If an
32293330
<code>@container</code> member exists, its value MUST be <a>null</a>,
32303331
<code>@set</code>, or <code>@index</code>.</p>
32313332

@@ -3263,6 +3364,10 @@ <h2>Context Definitions</h2>
32633364
the definition of a term cannot depend on the definition of another term if that other
32643365
term also depends on the first term.</p>
32653366

3367+
<p>If the <a>expanded term definition</a> contains the <code>@nest</code>
3368+
<a>keyword</a>, its value MUST be either <code>@nest</code>, or a term
3369+
which expands to <code>@nest</code>.</p>
3370+
32663371
<p>See <a class="sectionRef" href="#the-context"></a> for further discussion on contexts.</p>
32673372
</section>
32683373

@@ -3451,17 +3556,20 @@ <h2>Changes since 1.0 Recommendation of 16 January 2014</h2>
34513556
<li>An <a>expanded term definition</a> can now have an
34523557
<code>@context</code> property, which defines a <a>context</a> used for values of
34533558
a <a>property</a> identified with such a <a>term</a>.</li>
3559+
<li>An <a>expanded term definition</a> can now have an
3560+
<code>@nest</code> property, which identifies a term expanding to
3561+
<code>@nest</code> which is used for containing properties using the same
3562+
<code>@nest</code> mapping. When expanding, the values of a property
3563+
expanding to <code>@nest</code> are treated as if they were contained
3564+
within the enclosing <a>node object</a> directly.</li>
34543565
</ul>
34553566
</section>
34563567

34573568
<section class="appendix informative">
34583569
<h4>Open Issues</h4>
34593570
<p>The following is a list of open issues being worked on for the next release.</p>
3460-
<p class="issue" data-number="12"></p>
34613571
<p class="issue" data-number="195"></p>
34623572
<p class="issue" data-number="246"></p>
3463-
<p class="issue" data-number="247"></p>
3464-
<p class="issue" data-number="262"></p>
34653573
<p class="issue" data-number="269"></p>
34663574
<p class="issue" data-number="271"></p>
34673575
<p class="issue" data-number="272"></p>

0 commit comments

Comments
 (0)