Skip to content

Commit 81ee1d0

Browse files
committed
Add section for @propagate and stub for @source.
For #174. (cherry picked from commit f5b8a22)
1 parent 55a5bc8 commit 81ee1d0

File tree

4 files changed

+177
-32
lines changed

4 files changed

+177
-32
lines changed

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
source "https://rubygems.org"
22

33
gem 'json-ld', github: 'ruby-rdf/json-ld', branch: 'develop'
4+
gem 'json-ld-preloaded'
45
gem 'nokogiri'
56
gem 'nokogumbo'
67
gem 'linkeddata'
78
gem 'colorize'
89
gem 'rake'
10+
gem 'byebug'

Gemfile.lock

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
GIT
22
remote: git://github.com/ruby-rdf/json-ld.git
3-
revision: 74a05a9f623c5a9e02cbe42f053f9d09181fee97
3+
revision: 813e1ff914cc1a1025db14de392fd738b4cbb674
44
branch: develop
55
specs:
66
json-ld (3.0.2)
@@ -18,6 +18,7 @@ GEM
1818
bcp47 (0.3.3)
1919
i18n
2020
builder (3.2.3)
21+
byebug (11.0.1)
2122
colorize (0.8.1)
2223
concurrent-ruby (1.1.5)
2324
connection_pool (2.2.2)
@@ -26,7 +27,7 @@ GEM
2627
sxp (~> 1.0)
2728
equivalent-xml (0.6.0)
2829
nokogiri (>= 1.4.3)
29-
haml (5.0.4)
30+
haml (5.1.1)
3031
temple (>= 0.8.0)
3132
tilt
3233
hamster (3.0.0)
@@ -73,13 +74,13 @@ GEM
7374
sparql-client (~> 3.0)
7475
mini_portile2 (2.4.0)
7576
multi_json (1.13.1)
76-
net-http-persistent (3.0.0)
77+
net-http-persistent (3.0.1)
7778
connection_pool (~> 2.2)
7879
nokogiri (1.10.3)
7980
mini_portile2 (~> 2.4.0)
8081
nokogumbo (1.5.0)
8182
nokogiri
82-
public_suffix (3.0.3)
83+
public_suffix (3.1.1)
8384
rack (2.0.7)
8485
rake (12.3.2)
8586
rdf (3.0.12)
@@ -113,17 +114,17 @@ GEM
113114
rdf (>= 2.2, < 4.0)
114115
rdf-rdfa (>= 2.2, < 4.0)
115116
rdf-xsd (>= 2.2, < 4.0)
116-
rdf-reasoner (0.5.1)
117+
rdf-reasoner (0.5.2)
117118
rdf (~> 3.0)
118119
rdf-vocab (~> 3.0)
119120
rdf-xsd (~> 3.0)
120-
rdf-tabular (2.2.1)
121+
rdf-tabular (2.2.2)
121122
addressable (~> 2.3)
122123
bcp47 (~> 0.3, >= 0.3.3)
123124
json-ld (>= 2.1, < 4.0)
124-
rdf (>= 2.2, < 4.0)
125-
rdf-vocab (>= 2.2, < 4.0)
126-
rdf-xsd (>= 2.2, < 4.0)
125+
rdf (~> 3.0)
126+
rdf-vocab (~> 3.0)
127+
rdf-xsd (~> 3.0)
127128
rdf-trig (3.0.1)
128129
ebnf (~> 1.1)
129130
rdf (~> 3.0)
@@ -133,7 +134,7 @@ GEM
133134
rdf-turtle (3.0.6)
134135
ebnf (~> 1.1)
135136
rdf (~> 3.0)
136-
rdf-vocab (3.0.5)
137+
rdf-vocab (3.0.7)
137138
rdf (~> 3.0, >= 3.0.11)
138139
rdf-xsd (3.0.1)
139140
rdf (~> 3.0)
@@ -165,8 +166,10 @@ PLATFORMS
165166
ruby
166167

167168
DEPENDENCIES
169+
byebug
168170
colorize
169171
json-ld!
172+
json-ld-preloaded
170173
linkeddata
171174
nokogiri
172175
nokogumbo

common/extract-examples.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
# - @data-options indicates the comma-separated option/value pairs to pass to the processor
1111
require 'getoptlong'
1212
require 'json'
13+
require 'json/ld/preloaded'
1314
require 'nokogiri'
1415
require 'linkeddata'
1516
require 'fileutils'

index.html

Lines changed: 161 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -596,9 +596,19 @@ <h2>Syntax Tokens and Keywords</h2>
596596
Used as the <code>@type</code> value of a <a>JSON literal</a>.
597597
This keyword is described in <a href="#json-literals" class="sectionRef"></a>.
598598
</dd>
599-
<dt><code>:</code></dt>
600-
<dd>The separator for JSON keys and values that use
601-
<a>compact IRIs</a>.</dd>
599+
<dt class="changed"><code>:</code></dt><dd class="changed">
600+
The separator for JSON keys and values that use <a>compact IRIs</a>.</dd>
601+
<dt class="changed">`@propagate`</dt><dd class="changed">
602+
Used in a <a>context definition</a> to change the sccope of that context.
603+
By default, it is `true`,
604+
meaning that contexts propagate across <a>node objects</a>
605+
(other than for type-<a>scoped contexts</a>, which default to `false`).
606+
Setting this to `false` causes term definitions created within that context
607+
to be removed when entering a new <a>node object</a>.</dd>
608+
<dt class="changed">`@source`</dt><dd class="changed">
609+
Used in a <a>context definition</a> to load an external context
610+
within which the containing <a>context definition</a> is merged.
611+
This can be useful to add JSON-LD 1.1 features to JSON-LD 1.0 contexts.</dd>
602612
</dl>
603613

604614
<p>All keys, <a>keywords</a>, and values in JSON-LD are case-sensitive.</p>
@@ -3413,7 +3423,9 @@ <h3>Using the Document Base for the Default Vocabulary</h3>
34133423
different things depending on the context.
34143424
A <a>context</a> scoped on <code>@type</code> is only in effect for the <a>node object</a> on which
34153425
the type is used; the previous in-scope <a>contexts</a> are placed back into
3416-
effect when traversing into another <a>node object</a>.</p>
3426+
effect when traversing into another <a>node object</a>.
3427+
As described further in <a href="#context-propagation" class="sectionRef"></a>,
3428+
this may be controlled using the `@propagate` keyword.</p>
34173429

34183430
<p class="note">Any property-scoped or local contexts that were introduced in the <a>node object</a>
34193431
would still be in effect when traversing into another <a>node object</a>.</p>
@@ -3525,6 +3537,103 @@ <h3>Using the Document Base for the Default Vocabulary</h3>
35253537
<a>processing mode</a> set to <code>json-ld-1.1</code>.</p>
35263538
</section>
35273539

3540+
<section class="informative changed"><h2>Context Propagation</h2>
3541+
<p>Once introduced, <a>contexts</a> remain in effect until a subsequent
3542+
<a>context</a> removes it by setting `@context` to `null`,
3543+
or by redefining terms,
3544+
with the exception of type-<a>scoped contexts</a>,
3545+
which limits the affect of that context until the next <a>node object</a> is entered.
3546+
This behavior can be changed using the `@propagate` keyword.</p>
3547+
3548+
<p>The following example illustrates how terms defined in a context with `@propagate` set to `false`
3549+
are effectively removed when descending into new <a>node object</a>.</p>
3550+
3551+
<aside class="example ds-selector-tabs"
3552+
title="Marking a context to not propagate">
3553+
<div class="selectors">
3554+
<button class="selected" data-selects="compacted">Compacted (Input)</button>
3555+
<button data-selects="expanded">Expanded (Result)</button>
3556+
<button data-selects="statements">Statements</button>
3557+
<button data-selects="turtle">Turtle</button>
3558+
<a class="playground" target="_blank"></a>
3559+
</div>
3560+
<pre class="compacted input selected nohighlight" data-transform="updateExample">
3561+
<!--
3562+
{
3563+
"@context": {
3564+
"@version": 1.1,
3565+
"term": {
3566+
"@id": "http://example.org/original",
3567+
"@context": {
3568+
"@propagate": false,
3569+
#### ↑ Scoped context only lasts in one node-object####
3570+
"term": "http://example.org/non-propagated-term"
3571+
}
3572+
}
3573+
},
3574+
"term": {
3575+
#### ↑ This term is the original####
3576+
"term": {
3577+
#### ↑ This term is from the scoped context####
3578+
"term": "This term is from the first context"
3579+
#### ↑ This term is the original again####
3580+
}
3581+
}
3582+
}
3583+
-->
3584+
</pre>
3585+
<pre class="expanded result result nohighlight"
3586+
data-transform="updateExample"
3587+
data-result-for="Marking a context to not propagate-compacted">
3588+
<!--
3589+
[{
3590+
"http://example.org/original": [{
3591+
"http://example.org/non-propagated-term": [{
3592+
"http://example.org/original": [
3593+
{"@value": "This term is from the first context"}
3594+
]
3595+
}]
3596+
}]
3597+
}]
3598+
-->
3599+
</pre>
3600+
<table class="statements"
3601+
data-result-for="Marking a context to not propagate-expanded"
3602+
data-to-rdf
3603+
data-no-lint>
3604+
<thead><tr><th>Subject</th><th>Property</th><th>Value</th></tr></thead>
3605+
<tbody>
3606+
<tr><td>_:b2</td><td>http://example.org/original</td><td>This term is from the first context</td></tr>
3607+
<tr><td>_:b1</td><td>http://example.org/non-propagated-term</td><td>_:b2</td></tr>
3608+
<tr><td>_:b0</td><td>http://example.org/original</td><td>_:b1</td></tr>
3609+
</tbody>
3610+
</table>
3611+
<pre class="turtle"
3612+
data-content-type="text/turtle"
3613+
data-result-for="Marking a context to not propagate-expanded"
3614+
data-transform="updateExample"
3615+
data-to-rdf
3616+
data-no-lint>
3617+
<!--
3618+
@prefix ex: <http://example.org/> .
3619+
[
3620+
ex:original [
3621+
ex:non-propagated-term [
3622+
ex:original "This term is from the first context"
3623+
]
3624+
]
3625+
] .
3626+
-->
3627+
</pre>
3628+
</aside>
3629+
3630+
<p class="note">Contexts included within an array must all have the same value for `@propagate`
3631+
due to the way that rollback is defined in [[[JSON-LD11-API]]].</p>
3632+
</section>
3633+
3634+
<section class="informative changed"><h2>Sourced Contexts</h2>
3635+
</section>
3636+
35283637
<section class="informative changed"><h2>Protected Term Definitions</h2>
35293638
<p>JSON-LD is used in many specifications as the specified data format.
35303639
However, there is also a desire to allow some JSON-LD contents to be processed as plain JSON,
@@ -11718,10 +11827,12 @@ <h2>Context Definitions</h2>
1171811827
<code>@reverse</code>,
1171911828
<code>@type</code>,
1172011829
<code>@language</code>,
11830+
<code>@container</code>,
1172111831
<code class="changed">@context</code>,
11722-
<code class="changed">@prefix</code>, or
11723-
<code>@container</code>. An
11724-
<a>expanded term definition</a> SHOULD NOT contain any other keys.</p>
11832+
<code class="changed">@prefix</code>,
11833+
<code class="changed">@propagate</code>, or
11834+
<code class="changed">@source</code>.
11835+
An <a>expanded term definition</a> SHOULD NOT contain any other keys.</p>
1172511836

1172611837
<p>If the term being defined is not a <a>compact IRI</a> or
1172711838
<a>absolute IRI</a> and the <a>active context</a> does not have an
@@ -11787,14 +11898,20 @@ <h2>Context Definitions</h2>
1178711898
<p class="changed">If the <a>expanded term definition</a> contains the <code>@prefix</code>
1178811899
<a>keyword</a>, its value MUST be <code>true</code> or <code>false</code>.</p>
1178911900

11901+
<p class="changed">If the <a>expanded term definition</a> contains the <code>@propagate</code>
11902+
<a>keyword</a>, its value MUST be <code>true</code> or <code>false</code>.</p>
11903+
11904+
<p class="changed">If the <a>expanded term definition</a> contains the <code>@source</code>
11905+
<a>keyword</a>, its value MUST be an <a>absolute IRI</a> or <a>relative IRI</a>.</p>
11906+
1179011907
<p><a>Terms</a> MUST NOT be used in a circular manner. That is,
1179111908
the definition of a term cannot depend on the definition of another term if that other
1179211909
term also depends on the first term.</p>
1179311910

1179411911
<p>See <a class="sectionRef" href="#the-context"></a> for further discussion on contexts.</p>
1179511912
</section>
1179611913

11797-
<section class="normative changed">
11914+
<section class="normative">
1179811915
<h2>Keywords</h2>
1179911916
<p>JSON-LD <a>keywords</a> are described in <a class="sectionRef" href="#syntax-tokens-and-keywords"></a>,
1180011917
this section describes where each <a>keyword</a> may appear within different JSON-LD structures.</p>
@@ -11811,17 +11928,17 @@ <h2>Keywords</h2>
1181111928
<code>@set</code>,
1181211929
<code>@language</code>,
1181311930
<code>@index</code>,
11814-
<span><code>@id</code></span>,
11815-
<span><code>@graph</code></span>,
11816-
<span><code>@type</code></span>, or be
11931+
<code class="changed">@id</code>,
11932+
<code class="changed">@graph</code>,
11933+
<code class="changed">@type</code>, or be
1181711934
<a>null</a>,
11818-
or an <a>array</a> containing exactly any one of those keywords, or a
11819-
combination of <code>@set</code> and any of <code>@index</code>,
11820-
<code>@id</code>, <code>@graph</code>, <code>@type</code>,
11821-
<code>@language</code> in any order.
11822-
The value may also be an array
11823-
containing <code>@graph</code> along with either <code>@id</code> or
11824-
<code>@index</code> and also optionally including <code>@set</code>.
11935+
<span class="changed">or an <a>array</a> containing exactly any one of those keywords, or a
11936+
combination of <code>@set</code> and any of <code>@index</code>,
11937+
<code>@id</code>, <code>@graph</code>, <code>@type</code>,
11938+
<code>@language</code> in any order.
11939+
The value may also be an array
11940+
containing <code>@graph</code> along with either <code>@id</code> or
11941+
<code>@index</code> and also optionally including <code>@set</code></span>.
1182511942
</dd>
1182611943
<dt><code>@context</code></dt><dd>
1182711944
The <code>@context</code> keyword MUST NOT be aliased, and MAY be used as a key in the following objects:
@@ -11841,6 +11958,12 @@ <h2>Keywords</h2>
1184111958
a <a>context definition</a>, or
1184211959
an <a>array</a> composed of any of these.
1184311960
</dd>
11961+
<dt>`@graph`</dt><dd>
11962+
The `@graph` keyword MAY be aliased and MAY be used as a key in a <a>node object</a> or a <a>graph object</a>.
11963+
The unaliased `@graph` MAY be used as the value of the <code>@container</code> key within an <a>expanded term definition</a>.
11964+
The value of the `@graph` key MUST be a <a>value object</a>, <a>node object</a>, or an array of either <a>value objects</a> or <a>node objects</a>.
11965+
See <a class="sectionRef" href="#named-graphs"></a>.
11966+
</dd>
1184411967
<dt><code>@id</code></dt><dd>
1184511968
The <code>@id</code> keyword MAY be aliased and MAY be used as a key in a <a>node object</a> or a <a>graph object</a>.
1184611969
The unaliased <code>@id</code> MAY be used as a key in an <a>expanded term definition</a>,
@@ -11883,7 +12006,7 @@ <h2>Keywords</h2>
1188312006

1188412007
<p>See <a class="sectionRef" href="#sets-and-lists"></a> for further discussion on sets and lists.</p>
1188512008
</dd>
11886-
<dt><code>@nest</code></dt><dd>
12009+
<dt class="changed"><code>@nest</code></dt><dd class="changed">
1188712010
The <code>@nest</code> keyword MAY be aliased and MAY be used as a key in a <a>node object</a>.
1188812011
The unaliased <code>@nest</code> MAY be used as the value of a <a>simple term definition</a>,
1188912012
or as a key in an <a>expanded term definition</a>.
@@ -11892,7 +12015,7 @@ <h2>Keywords</h2>
1189212015
Its value MUST be a <a>string</a>.
1189312016
See <a class="sectionRef" href="#property-nesting"></a> for a further discussion.
1189412017
</dd>
11895-
<dt><code>@none</code></dt><dd>
12018+
<dt class="changed"><code>@none</code></dt><dd class="changed">
1189612019
The <code>@none</code> keyword MAY be aliased and MAY be used as a key in an
1189712020
<a>index map</a>, <a>id map</a>, <a>language map</a>, <a>type map</a>.
1189812021
See <a class="sectionRef" href="#data-indexing"></a>,
@@ -11902,13 +12025,18 @@ <h2>Keywords</h2>
1190212025
<a class="sectionRef" href="#named-graph-indexing"></a>, or
1190312026
<a class="sectionRef" href="#named-graph-data-indexing"></a>
1190412027
for a further discussion.</dd>
11905-
<dt><code>@prefix</code></dt><dd>
12028+
<dt class="changed"><code>@prefix</code></dt><dd class="changed">
1190612029
The <code>@prefix</code> keyword MUST NOT be aliased, and MAY be used as a key in an <a>expanded term definition</a>.
1190712030
Its value MUST be <code>true</code> or <code>false</code>.
1190812031
See <a class="sectionRef" href="#compact-iris"></a>
1190912032
and <a class="sectionRef" href="#context-definitions"></a>
1191012033
for a further discussion.
1191112034
</dd>
12035+
<dt class="changed">`@propagate`</dt><dd class="changed">
12036+
The `@propagate` keyword MUST NOT be aliased, and MAY be used in a <a>context definition</a>.
12037+
Its value MUST be <code>true</code> or <code>false</code>.
12038+
See <a class="sectionRef" href="#context-propagation"></a> for a further discussion.
12039+
</dd>
1191212040
<dt><code>@reverse</code></dt><dd>
1191312041
The <code>@reverse</code> keyword MAY be aliased and MAY be used as a key in a <a>node object</a>.
1191412042
The unaliased <code>@reverse</code> MAY be used as a key in an <a>expanded term definition</a>.
@@ -11934,6 +12062,11 @@ <h2>Keywords</h2>
1193412062

1193512063
<p>See <a class="sectionRef" href="#sets-and-lists"></a> for further discussion on sets and lists.</p>
1193612064
</dd>
12065+
<dt class="changed">`@source`</dt><dd class="changed">
12066+
The `@source` keyword MUST NOT be aliased, and MAY be used in a <a>context definition</a>.
12067+
Its value MUST be an <a>absolute IRI</a> or <a>relative IRI</a>.
12068+
See <a class="sectionRef" href="#sourced-contexts"></a> for a further discussion.
12069+
</dd>
1193712070
<dt><code>@type</code></dt><dd>
1193812071
The <code>@type</code> keyword MAY be aliased and MAY be used as a key in a <a>node object</a> or a <a>value object</a>.
1193912072
The unaliased <code>@type</code> MAY be used as a key in an <a>expanded term definition</a>,
@@ -11949,7 +12082,7 @@ <h2>Keywords</h2>
1194912082
Its value key MUST be either a <a>string</a>, a <a>number</a>, <code>true</code>, <code>false</code> or <a>null</a>.
1195012083
This keyword is described further in <a class="sectionRef" href="#value-objects"></a>.
1195112084
</dd>
11952-
<dt><code>@version</code></dt><dd>
12085+
<dt class="changed"><code>@version</code></dt><dd class="changed">
1195312086
The <code>@version</code> keyword MUST NOT be aliased and MAY be used as a key in a <a>context definition</a>.
1195412087
Its value MUST be a <a>number</a> with the value <code>1.1</code>.
1195512088
This keyword is described further in <a class="sectionRef" href="#context-definitions"></a>.
@@ -12880,6 +13013,12 @@ <h2>Changes since JSON-LD Community Group Final Report</h2>
1288013013
to limit the ability of other contexts to override them.</li>
1288113014
<li>A <a>context</a> defined in an <a>expanded term definition</a> may also be used for values
1288213015
of <code>@type</code>, which defines a <a>context</a> to use for <a>node objects</a> including the associated type.</li>
13016+
<li>By default, all contexts are propagated when traversing <a>node objects</a>, other than
13017+
type-scoped contexts. This can be controlled using the <code>@propagate</code>
13018+
<a>entry</a> in a <a>local context</a>.</li>
13019+
<li>A context may contain a <code>@source</code> <a>entry</a> used to reference a remote context
13020+
within a context, allowing <code>JSON-LD 1.1</code> features to be added to contexts originally
13021+
authored for <code>JSON-LD 1.0</code>.</li>
1288313022
</ul>
1288413023
</section>
1288513024

0 commit comments

Comments
 (0)