Skip to content

Commit f5b8a22

Browse files
committed
Add section for @propagate and stub for @source.
For #174.
1 parent f280ee8 commit f5b8a22

File tree

4 files changed

+177
-32
lines changed

4 files changed

+177
-32
lines changed

Gemfile

+2
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

+13-10
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

+1
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

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

599609
<p>All keys, <a>keywords</a>, and values in JSON-LD are case-sensitive.</p>
@@ -3409,7 +3419,9 @@ <h3>Using the Document Base for the Default Vocabulary</h3>
34093419
different things depending on the context.
34103420
A <a>context</a> scoped on <code>@type</code> is only in effect for the <a>node object</a> on which
34113421
the type is used; the previous in-scope <a>contexts</a> are placed back into
3412-
effect when traversing into another <a>node object</a>.</p>
3422+
effect when traversing into another <a>node object</a>.
3423+
As described further in <a href="#context-propagation" class="sectionRef"></a>,
3424+
this may be controlled using the `@propagate` keyword.</p>
34133425

34143426
<p class="note">Any property-scoped or local contexts that were introduced in the <a>node object</a>
34153427
would still be in effect when traversing into another <a>node object</a>.</p>
@@ -3521,6 +3533,103 @@ <h3>Using the Document Base for the Default Vocabulary</h3>
35213533
<a>processing mode</a> set to <code>json-ld-1.1</code>.</p>
35223534
</section>
35233535

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

1172211833
<p>If the term being defined is not a <a>compact IRI</a> or
1172311834
<a>absolute IRI</a> and the <a>active context</a> does not have an
@@ -11783,14 +11894,20 @@ <h2>Context Definitions</h2>
1178311894
<p class="changed">If the <a>expanded term definition</a> contains the <code>@prefix</code>
1178411895
<a>keyword</a>, its value MUST be <code>true</code> or <code>false</code>.</p>
1178511896

11897+
<p class="changed">If the <a>expanded term definition</a> contains the <code>@propagate</code>
11898+
<a>keyword</a>, its value MUST be <code>true</code> or <code>false</code>.</p>
11899+
11900+
<p class="changed">If the <a>expanded term definition</a> contains the <code>@source</code>
11901+
<a>keyword</a>, its value MUST be an <a>absolute IRI</a> or <a>relative IRI</a>.</p>
11902+
1178611903
<p><a>Terms</a> MUST NOT be used in a circular manner. That is,
1178711904
the definition of a term cannot depend on the definition of another term if that other
1178811905
term also depends on the first term.</p>
1178911906

1179011907
<p>See <a class="sectionRef" href="#the-context"></a> for further discussion on contexts.</p>
1179111908
</section>
1179211909

11793-
<section class="normative changed">
11910+
<section class="normative">
1179411911
<h2>Keywords</h2>
1179511912
<p>JSON-LD <a>keywords</a> are described in <a class="sectionRef" href="#syntax-tokens-and-keywords"></a>,
1179611913
this section describes where each <a>keyword</a> may appear within different JSON-LD structures.</p>
@@ -11807,17 +11924,17 @@ <h2>Keywords</h2>
1180711924
<code>@set</code>,
1180811925
<code>@language</code>,
1180911926
<code>@index</code>,
11810-
<span><code>@id</code></span>,
11811-
<span><code>@graph</code></span>,
11812-
<span><code>@type</code></span>, or be
11927+
<code class="changed">@id</code>,
11928+
<code class="changed">@graph</code>,
11929+
<code class="changed">@type</code>, or be
1181311930
<a>null</a>,
11814-
or an <a>array</a> containing exactly any one of those keywords, or a
11815-
combination of <code>@set</code> and any of <code>@index</code>,
11816-
<code>@id</code>, <code>@graph</code>, <code>@type</code>,
11817-
<code>@language</code> in any order.
11818-
The value may also be an array
11819-
containing <code>@graph</code> along with either <code>@id</code> or
11820-
<code>@index</code> and also optionally including <code>@set</code>.
11931+
<span class="changed">or an <a>array</a> containing exactly any one of those keywords, or a
11932+
combination of <code>@set</code> and any of <code>@index</code>,
11933+
<code>@id</code>, <code>@graph</code>, <code>@type</code>,
11934+
<code>@language</code> in any order.
11935+
The value may also be an array
11936+
containing <code>@graph</code> along with either <code>@id</code> or
11937+
<code>@index</code> and also optionally including <code>@set</code></span>.
1182111938
</dd>
1182211939
<dt><code>@context</code></dt><dd>
1182311940
The <code>@context</code> keyword MUST NOT be aliased, and MAY be used as a key in the following objects:
@@ -11837,6 +11954,12 @@ <h2>Keywords</h2>
1183711954
a <a>context definition</a>, or
1183811955
an <a>array</a> composed of any of these.
1183911956
</dd>
11957+
<dt>`@graph`</dt><dd>
11958+
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>.
11959+
The unaliased `@graph` MAY be used as the value of the <code>@container</code> key within an <a>expanded term definition</a>.
11960+
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>.
11961+
See <a class="sectionRef" href="#named-graphs"></a>.
11962+
</dd>
1184011963
<dt><code>@id</code></dt><dd>
1184111964
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>.
1184211965
The unaliased <code>@id</code> MAY be used as a key in an <a>expanded term definition</a>,
@@ -11879,7 +12002,7 @@ <h2>Keywords</h2>
1187912002

1188012003
<p>See <a class="sectionRef" href="#sets-and-lists"></a> for further discussion on sets and lists.</p>
1188112004
</dd>
11882-
<dt><code>@nest</code></dt><dd>
12005+
<dt class="changed"><code>@nest</code></dt><dd class="changed">
1188312006
The <code>@nest</code> keyword MAY be aliased and MAY be used as a key in a <a>node object</a>.
1188412007
The unaliased <code>@nest</code> MAY be used as the value of a <a>simple term definition</a>,
1188512008
or as a key in an <a>expanded term definition</a>.
@@ -11888,7 +12011,7 @@ <h2>Keywords</h2>
1188812011
Its value MUST be a <a>string</a>.
1188912012
See <a class="sectionRef" href="#property-nesting"></a> for a further discussion.
1189012013
</dd>
11891-
<dt><code>@none</code></dt><dd>
12014+
<dt class="changed"><code>@none</code></dt><dd class="changed">
1189212015
The <code>@none</code> keyword MAY be aliased and MAY be used as a key in an
1189312016
<a>index map</a>, <a>id map</a>, <a>language map</a>, <a>type map</a>.
1189412017
See <a class="sectionRef" href="#data-indexing"></a>,
@@ -11898,13 +12021,18 @@ <h2>Keywords</h2>
1189812021
<a class="sectionRef" href="#named-graph-indexing"></a>, or
1189912022
<a class="sectionRef" href="#named-graph-data-indexing"></a>
1190012023
for a further discussion.</dd>
11901-
<dt><code>@prefix</code></dt><dd>
12024+
<dt class="changed"><code>@prefix</code></dt><dd class="changed">
1190212025
The <code>@prefix</code> keyword MUST NOT be aliased, and MAY be used as a key in an <a>expanded term definition</a>.
1190312026
Its value MUST be <code>true</code> or <code>false</code>.
1190412027
See <a class="sectionRef" href="#compact-iris"></a>
1190512028
and <a class="sectionRef" href="#context-definitions"></a>
1190612029
for a further discussion.
1190712030
</dd>
12031+
<dt class="changed">`@propagate`</dt><dd class="changed">
12032+
The `@propagate` keyword MUST NOT be aliased, and MAY be used in a <a>context definition</a>.
12033+
Its value MUST be <code>true</code> or <code>false</code>.
12034+
See <a class="sectionRef" href="#context-propagation"></a> for a further discussion.
12035+
</dd>
1190812036
<dt><code>@reverse</code></dt><dd>
1190912037
The <code>@reverse</code> keyword MAY be aliased and MAY be used as a key in a <a>node object</a>.
1191012038
The unaliased <code>@reverse</code> MAY be used as a key in an <a>expanded term definition</a>.
@@ -11930,6 +12058,11 @@ <h2>Keywords</h2>
1193012058

1193112059
<p>See <a class="sectionRef" href="#sets-and-lists"></a> for further discussion on sets and lists.</p>
1193212060
</dd>
12061+
<dt class="changed">`@source`</dt><dd class="changed">
12062+
The `@source` keyword MUST NOT be aliased, and MAY be used in a <a>context definition</a>.
12063+
Its value MUST be an <a>absolute IRI</a> or <a>relative IRI</a>.
12064+
See <a class="sectionRef" href="#sourced-contexts"></a> for a further discussion.
12065+
</dd>
1193312066
<dt><code>@type</code></dt><dd>
1193412067
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>.
1193512068
The unaliased <code>@type</code> MAY be used as a key in an <a>expanded term definition</a>,
@@ -11945,7 +12078,7 @@ <h2>Keywords</h2>
1194512078
Its value key MUST be either a <a>string</a>, a <a>number</a>, <code>true</code>, <code>false</code> or <a>null</a>.
1194612079
This keyword is described further in <a class="sectionRef" href="#value-objects"></a>.
1194712080
</dd>
11948-
<dt><code>@version</code></dt><dd>
12081+
<dt class="changed"><code>@version</code></dt><dd class="changed">
1194912082
The <code>@version</code> keyword MUST NOT be aliased and MAY be used as a key in a <a>context definition</a>.
1195012083
Its value MUST be a <a>number</a> with the value <code>1.1</code>.
1195112084
This keyword is described further in <a class="sectionRef" href="#context-definitions"></a>.
@@ -12876,6 +13009,12 @@ <h2>Changes since JSON-LD Community Group Final Report</h2>
1287613009
to limit the ability of other contexts to override them.</li>
1287713010
<li>A <a>context</a> defined in an <a>expanded term definition</a> may also be used for values
1287813011
of <code>@type</code>, which defines a <a>context</a> to use for <a>node objects</a> including the associated type.</li>
13012+
<li>By default, all contexts are propagated when traversing <a>node objects</a>, other than
13013+
type-scoped contexts. This can be controlled using the <code>@propagate</code>
13014+
<a>entry</a> in a <a>local context</a>.</li>
13015+
<li>A context may contain a <code>@source</code> <a>entry</a> used to reference a remote context
13016+
within a context, allowing <code>JSON-LD 1.1</code> features to be added to contexts originally
13017+
authored for <code>JSON-LD 1.0</code>.</li>
1287913018
</ul>
1288013019
</section>
1288113020

0 commit comments

Comments
 (0)