-
Notifications
You must be signed in to change notification settings - Fork 23
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
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
7f35bee
Proposed description of sealed contexts
pchampin 2e186b3
Improving the rationale for sealed context.
pchampin 9244f6e
Improved example following Ivan's suggestion.
pchampin 5536f20
Update Gemfile.lock with latest json-ld gem.
gkellogg bd6f8ae
Changed text accordingly to the decisions taken during F2F
pchampin 57c8b3d
added myself as an editor
pchampin ca0d4bb
fixed examples related to sealed term definitions
pchampin f947033
added note to warn about the danger of sealing
pchampin 876c194
fixed comment in example
pchampin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|
@@ -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": { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note that |
||
****"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> | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.