Skip to content

Proposed description of sealed contexts #119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Feb 13, 2019
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
GIT
remote: git://github.com/ruby-rdf/json-ld.git
revision: afe7b3b10547b552676d1379a2be4bc34cf83d02
revision: 6bb0c2d269e8cf80152d519ee5fd16696812b1f2
branch: develop
specs:
json-ld (3.0.2)
Expand All @@ -12,7 +12,7 @@ GIT
GEM
remote: https://rubygems.org/
specs:
addressable (2.5.2)
addressable (2.6.0)
public_suffix (>= 2.0.2, < 4.0)
bcp47 (0.3.3)
i18n
Expand All @@ -31,7 +31,7 @@ GEM
hamster (3.0.0)
concurrent-ruby (~> 1.0)
htmlentities (4.3.4)
i18n (1.5.1)
i18n (1.5.3)
concurrent-ruby (~> 1.0)
json-ld-preloaded (3.0.2)
json-ld (~> 3.0)
Expand Down Expand Up @@ -73,14 +73,14 @@ GEM
multi_json (1.13.1)
net-http-persistent (3.0.0)
connection_pool (~> 2.2)
nokogiri (1.10.0)
nokogiri (1.10.1)
mini_portile2 (~> 2.4.0)
nokogumbo (1.5.0)
nokogiri
public_suffix (3.0.3)
rack (2.0.6)
rake (12.3.2)
rdf (3.0.9)
rdf (3.0.10)
hamster (~> 3.0)
link_header (~> 0.0, >= 0.0.8)
rdf-aggregate-repo (2.2.1)
Expand Down Expand Up @@ -126,7 +126,7 @@ GEM
rdf-turtle (~> 3.0, >= 3.0.3)
rdf-trix (2.2.1)
rdf (>= 2.2, < 4.0)
rdf-turtle (3.0.3)
rdf-turtle (3.0.5)
ebnf (~> 1.1)
rdf (~> 3.0)
rdf-vocab (3.0.4)
Expand Down
292 changes: 290 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,14 @@
company: "Spec-Ops",
companyURL: "https://spec-ops.io/",
w3cid: "44770",
note: "v1.0 and v1.1" }
],
note: "v1.0 and v1.1" },
{ name: "Pierre-Antoine Champin",
url: "http://champin.net/",
company: "LIRIS - Université de Lyon",
companyURL: "https://liris.cnrs.fr/",
w3cid: "42931",
note: "v1.1" }
],

// editors, add as many as you like
// only "name" is required
Expand Down Expand Up @@ -3104,6 +3110,288 @@ <h3>Using the Document Base for the Default Vocabulary</h3>
<p class="note">Scoped Contexts are a new feature in JSON-LD 1.1, requiring
<a>processing mode</a> set to <code>json-ld-1.1</code>.</p>
</section>

<section class="informative changed"><h2>Sealed Term Definitions</h2>
<p>JSON-LD is used in many specifications as the specified data format.
However, there is also a desire to allow some JSON-LD contents to be processed as plain JSON,
without using any of the JSON-LD algorithms.
Because JSON-LD is very flexible,
some terms from the original format may be locally overridden
through the use of embedded contexts,
and take a different meaning for JSON-LD based implementations.
On the other hand, "plain JSON" implementations may not be able to interpret these embedded contexts,
and hence will still interpret those terms with their original meaning.
To prevent this divergence of interpretation,
JSON-LD 1.1 allows term definitions to be <em>sealed</em>.
</p>
<p>A <dfn>sealed term definition</dfn> is a term definition with a member <code>@sealed</code> set to <code>true</code>.
It prevents further contexts to override this term definition.
</p>


<aside class="example ds-selector-tabs changed"
title="A sealed term definition can not be overridden">
<div class="selectors">
<button class="selected" data-selects="original">Original</button>
<button data-selects="expanded">Expanded</button>
<button data-selects="statements">Statements</button>
<button data-selects="turtle">Turtle</button>
<a class="playground" target="_blank"></a>
</div>
<pre class="original selected nohighlight" data-transform="updateExample">
<!--
{
"@context": [
{
****"@version": 1.1****,
"Person": "http://schema.org/Person",
"knows": "http://schema.org/knows",
"name": {
"@id": "http://schema.org/name",
****"@sealed": true****
}
},
{
****"name": "this_attempt_to_override_name_will_fail"****
}
],
"@type": "Person",
"name": "Manu Sporny",
"knows": {
"@context": {
****"name": "this_attempt_to_override_name_will_also_fail"****
},
"name": "Gregg Kellogg"
}
}
-->
</pre>
<pre class="expanded nohighlight"
data-transform="updateExample"
data-result-for="A sealed term definition can not be overridden-original">
<!--
[{
"@type": ["http://schema.org/Person"],
"http://schema.org/name": [{"@value": "Manu Sporny"}],
"http://schema.org/knows": [{
"http://schema.org/name": [{"@value": "Gregg Kellogg"}]
}]
}]
-->
</pre>
<table class="statements"
data-result-for="A sealed term definition can not be overridden-expanded"
data-to-rdf>
<thead><tr><th>Subject</th><th>Property</th><th>Value</th></tr></thead>
<tbody>
<tr><td>_:b0</td><td>rdf:type</td><td>schema:Person</td></tr>
<tr><td>_:b0</td><td>schema:name</td><td>Manu Sporny</td></tr>
<tr><td>_:b0</td><td>schema:knows</td><td>_:b1</td></tr>
<tr><td>_:b1</td><td>schema:name</td><td>Gregg Kellogg</td></tr>
</tbody>
</table>
<pre class="turtle"
data-content-type="text/turtle"
data-result-for="A sealed term definition can not be overridden-expanded"
data-transform="updateExample"
data-to-rdf>
<!--
@prefix schema: <http://schema.org/> .

[
a schema:Person;
schema:name "Manu Sporny";
schema:knows [
schema:name "Gregg Kellogg"
]
] .
-->
</pre>
</aside>

<p>When all or most term definitions of a context need to be sealed,
it is possible to add a member <code>@sealed</code> set to <code>true</code>
to the context itself.
It has the same effect as sealing each of its term definitions individually.
Exceptions can be made by adding a member <code>@sealed</code> set to <code>false</code>
in some term definitions.
</p>

<aside class="example ds-selector-tabs changed"
title="A sealed @context with an exception">
<div class="selectors">
<button class="selected" data-selects="original">Original</button>
<button data-selects="expanded">Expanded</button>
<button data-selects="statements">Statements</button>
<button data-selects="turtle">Turtle</button>
<a class="playground" target="_blank"></a>
</div>
<pre class="original selected nohighlight" data-transform="updateExample">
<!--
{
"@context": [
{
****"@version": 1.1****,
****"@sealed": true****,
"name": "http://schema.org/name",
"member": "http://schema.org/member",
"Person": {
"@id": "http://schema.org/Person",
****"@sealed": false****
}
}
],
"name": "Digital Bazaar",
"member": {
"@context": {
"Person": "http://xmlns.com/foaf/0.1/Person",
"name": "this_attempt_to_override_name_will_fail"
},
"@type": "Person",
"name": "Manu Sporny"
}
}
-->
</pre>
<pre class="expanded nohighlight"
data-transform="updateExample"
data-result-for="A sealed @context with an exception-original">
<!--
[{
"http://schema.org/name": [{"@value": "Digital Bazaar"}],
"http://schema.org/member": [
{
"@type": ["http://xmlns.com/foaf/0.1/Person"],
"http://schema.org/name": [{"@value": "Manu Sporny"}]
}
]
}]
-->
</pre>
<table class="statements"
data-result-for="A sealed @context with an exception-expanded"
data-to-rdf>
<thead><tr><th>Subject</th><th>Property</th><th>Value</th></tr></thead>
<tbody>
<tr><td>_:b0</td><td>schema:name</td><td>Digital Bazaar</td></tr>
<tr><td>_:b0</td><td>schema:member</td><td>_:b1</td></tr>
<tr><td>_:b1</td><td>rdf:type</td><td>foaf:Person</td></tr>
<tr><td>_:b1</td><td>schema:name</td><td>Manu Sporny</td></tr>
</tbody>
</table>
<pre class="turtle"
data-content-type="text/turtle"
data-result-for="A sealed @context with an exception-expanded"
data-transform="updateExample"
data-to-rdf>
<!--
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix schema: <http://schema.org/> .

[
schema:name "Digital Bazaar";
schema:member [
a foaf:Person;
schema:name "Manu Sporny"
]
] .
-->
</pre>
</aside>

<p>While sealed term definitions can not be directly overridden,
it is worth noting that setting <code>@context</code> to <code>null</code>
will erase everything from the active context,
<em>including</em> sealed term definitions.
</p>

<aside class="example ds-selector-tabs changed"
title="@context null erases sealed term definitions">
<div class="selectors">
<button class="selected" data-selects="original">Original</button>
<button data-selects="expanded">Expanded</button>
<button data-selects="statements">Statements</button>
<button data-selects="turtle">Turtle</button>
<a class="playground" target="_blank"></a>
</div>
<pre class="original selected nohighlight" data-transform="updateExample">
<!--
{
"@context": [
{
****"@version": 1.1****,
****"@sealed": true****,
"Organization": "http://schema.org/Organization",
"name": "http://schema.org/name",
"employee": {
"@id": "http://schema.org/employee",
****"@context": null****
}
}
],
"@type": "Organization",
"name": "Digital Bazaar",
"employee" : {
#### -- because of "@context": null in the scoped context, ####
#### -- the active context at this point is empty; ####
#### -- so we can (and we must) redefine "name" below ####
"@context": {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that -- inside of <!-- --> is causing the HTML parser problems. Try using a unicode character such add instead.

****"name": "http://xmlns.com/foaf/0.1/name"****
},
"name": "Manu Sporny"
}
}
-->
</pre>
<pre class="expanded nohighlight"
data-transform="updateExample"
data-result-for="@context null erases sealed term definitions-original">
<!--
[{
"@type": ["http://schema.org/Organization"],
"http://schema.org/name": [{"@value": "Digital Bazaar"}],
"http://schema.org/employee": [
{
"http://xmlns.com/foaf/0.1/name": [{"@value": "Manu Sporny"}]
}
]
}]
-->
</pre>
<table class="statements"
data-result-for="@context null erases sealed term definitions-expanded"
data-to-rdf>
<thead><tr><th>Subject</th><th>Property</th><th>Value</th></tr></thead>
<tbody>
<tr><td>_:b0</td><td>rdf:type</td><td>schema:Organization</td></tr>
<tr><td>_:b0</td><td>schema:name</td><td>Digital Bazaar</td></tr>
<tr><td>_:b0</td><td>schema:employee</td><td>_:b1</td></tr>
<tr><td>_:b1</td><td>foaf:name</td><td>Manu Sporny</td></tr>
</tbody>
</table>
<pre class="turtle"
data-content-type="text/turtle"
data-result-for="@context null erases sealed term definitions-expanded"
data-transform="updateExample"
data-to-rdf>
<!--
@prefix foaf: <http://xmlns.com/foaf/0.1/>.
@prefix schema: <http://schema.org/>.

[
a schema:Organization;
schema:name "Digital Bazaar";
schema:employee [
foaf:name "Manu Sporny"
];
] .
-->
</pre>
</aside>

<p class="note">Sealed term definitions are a new feature in JSON-LD 1.1, requiring
<a>processing mode</a> set to <code>json-ld-1.1</code>.</p>
</section>
</section>

<section class="informative"><h2>Describing Values</h2>
Expand Down