Skip to content

Commit 297d6d7

Browse files
authored
Merge pull request #462 from json-ld/issue-415-scope-on-type
Issue 415 scope on type
2 parents 5644fdd + 4a06154 commit 297d6d7

Some content is hidden

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

48 files changed

+652
-107
lines changed

spec/latest/common/terms.html

Lines changed: 32 additions & 32 deletions
Large diffs are not rendered by default.

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

Lines changed: 94 additions & 41 deletions
Large diffs are not rendered by default.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ <h2>How to Read this Document</h2>
199199

200200
<p>
201201
To understand the basics in this specification you must first be familiar with
202-
<a data-cite="rfc7159">JSON</a>, which is detailed in [[!RFC7159]]. You must also understand the
202+
<a data-cite="RFC7159">JSON</a>, which is detailed in [[!RFC7159]]. You must also understand the
203203
JSON-LD Syntax [[!JSON-LD]], which is the base syntax used by all of the
204204
algorithms in this document,
205205
and the JSON-LD API [[!JSON-LD-API]]. To understand the API and how it is

spec/latest/json-ld/index.html

Lines changed: 55 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ <h2>How to Read this Document</h2>
220220
providing a standard library interface for common JSON-LD operations.</p>
221221

222222
<p>To understand the basics in this specification you must first be familiar with
223-
<a data-cite="rfc7159">JSON</a>, which is detailed in [[!RFC7159]].</p>
223+
<a data-cite="RFC7159">JSON</a>, which is detailed in [[!RFC7159]].</p>
224224

225225
<p>This document almost exclusively uses the term IRI
226226
(<a data-cite="ld-glossary#internationalized-resource-identifier">Internationalized Resource Indicator</a>)
@@ -450,7 +450,7 @@ <h1>Basic Concepts</h1>
450450
tokens such as "name", "homepage", etc.</p>
451451

452452
<p>Linked Data, and the Web in general, uses <a>IRIs</a>
453-
(<a data-cite="rfc3987#section-2">Internationalized Resource Identifiers</a> as described in [[!RFC3987]]) for unambiguous
453+
(<a data-cite="RFC3987#section-2">Internationalized Resource Identifiers</a> as described in [[!RFC3987]]) for unambiguous
454454
identification. The idea is to use <a>IRIs</a>
455455
to assign unambiguous identifiers to data that may be of use to other developers.
456456
It is useful for <a>terms</a>,
@@ -571,7 +571,7 @@ <h2>The Context</h2>
571571
is ignored when the document is used as an external JSON-LD context document.</p>
572572

573573
<p>JSON documents can be interpreted as JSON-LD without having to be modified by
574-
referencing a <a>context</a> via an <a data-cite="rfc5988#section-5">HTTP Link Header</a>
574+
referencing a <a>context</a> via an <a data-cite="RFC5988#section-5">HTTP Link Header</a>
575575
as described in <a class="sectionRef" href="#interpreting-json-as-json-ld"></a>. It is also
576576
possible to apply a custom context using the JSON-LD API [[JSON-LD-API]].</p>
577577

@@ -613,12 +613,12 @@ <h2>The Context</h2>
613613
<section class="informative">
614614
<h2>IRIs</h2>
615615

616-
<p><a>IRIs</a> (<a data-cite="rfc3987#section-2">Internationalized Resource Identifiers</a>
616+
<p><a>IRIs</a> (<a data-cite="RFC3987#section-2">Internationalized Resource Identifiers</a>
617617
[[!RFC3987]]) are fundamental to Linked Data as that is how most
618618
<a>nodes</a> and <a>properties</a>
619619
are identified. In JSON-LD, IRIs may be represented as an
620620
<a>absolute IRI</a> or a <a>relative IRI</a>. An
621-
<a data-cite="rfc3987#section-1.3">absolute IRI</a> is defined in [[!RFC3987]] as containing a
621+
<a data-cite="RFC3987#section-1.3">absolute IRI</a> is defined in [[!RFC3987]] as containing a
622622
<em>scheme</em> along with <em>path</em> and optional <em>query</em> and
623623
<em>fragment</em> segments. A <a>relative IRI</a> is an IRI
624624
that is relative to some other <a>absolute IRI</a>.
@@ -863,7 +863,7 @@ <h2>Base IRI</h2>
863863

864864
<p>JSON-LD allows <a>IRI</a>s to be specified in a relative form which is
865865
resolved against the document base according
866-
<a data-cite="rfc3986#section-5.1">section 5.1 Establishing a Base URI</a>
866+
<a data-cite="RFC3986#section-5.1">section 5.1 Establishing a Base URI</a>
867867
of [[RFC3986]]. The <a>base IRI</a> may be explicitly set with a <a>context</a>
868868
using the <code>@base</code> keyword.</p>
869869

@@ -1491,7 +1491,7 @@ <h2>Advanced Context Usage</h2>
14911491
<h2>Interpreting JSON as JSON-LD</h2>
14921492

14931493
<p>Ordinary JSON documents can be interpreted as JSON-LD by referencing a JSON-LD
1494-
<a>context</a> document in an <a data-cite="rfc5988#section-5">HTTP Link Header</a>. Doing so allows JSON to
1494+
<a>context</a> document in an <a data-cite="RFC5988#section-5">HTTP Link Header</a>. Doing so allows JSON to
14951495
be unambiguously machine-readable without requiring developers to drastically
14961496
change their documents and provides an upgrade path for existing infrastructure
14971497
without breaking existing clients that rely on the <code>application/json</code>
@@ -1500,7 +1500,7 @@ <h2>Interpreting JSON as JSON-LD</h2>
15001500

15011501
<p>In order to use an external context with an ordinary JSON document, an author
15021502
MUST specify an <a>IRI</a> to a valid <a>JSON-LD document</a> in
1503-
an <a data-cite="rfc5988#section-5">HTTP Link Header</a> [[!RFC5988]] using the <code>http://www.w3.org/ns/json-ld#context</code>
1503+
an <a data-cite="RFC5988#section-5">HTTP Link Header</a> [[!RFC5988]] using the <code>http://www.w3.org/ns/json-ld#context</code>
15041504
link relation. The referenced document MUST have a top-level <a>JSON object</a>.
15051505
The <code>@context</code> subtree within that object is added to the top-level
15061506
<a>JSON object</a> of the referencing document. If an <a>array</a>
@@ -1510,7 +1510,7 @@ <h2>Interpreting JSON as JSON-LD</h2>
15101510
of the <code>@context</code> subtree in the referenced document MUST be
15111511
discarded. Effectively this means that the <a>active context</a> is
15121512
initialized with the referenced external <a>context</a>. A response MUST NOT
1513-
contain more than one <a data-cite="rfc5988#section-5">HTTP Link Header</a> [[!RFC5988]] using the
1513+
contain more than one <a data-cite="RFC5988#section-5">HTTP Link Header</a> [[!RFC5988]] using the
15141514
<code>http://www.w3.org/ns/json-ld#context</code> link relation.</p>
15151515

15161516
<p>The following example demonstrates the use of an external context with an
@@ -1542,7 +1542,7 @@ <h2>Interpreting JSON as JSON-LD</h2>
15421542
served with the <code>application/ld+json</code>
15431543
media type MUST have all context information, including references to external
15441544
contexts, within the body of the document. Contexts linked via a
1545-
<code>http://www.w3.org/ns/json-ld#context</code> <a data-cite="rfc5988#section-5">HTTP Link Header</a> MUST be
1545+
<code>http://www.w3.org/ns/json-ld#context</code> <a data-cite="RFC5988#section-5">HTTP Link Header</a> MUST be
15461546
ignored for such documents.</p>
15471547
</section>
15481548

@@ -1571,7 +1571,7 @@ <h2>String Internationalization</h2>
15711571

15721572
<p>The example above would associate the <code>ja</code> language
15731573
code with the two <a>strings</a> <em>花澄</em> and <em>科学者</em>.
1574-
<a data-cite="bcp47#section-2">Languages codes</a> are defined in [[!BCP47]]. The <a>default language</a> applies to all
1574+
<a data-cite="BCP47#section-2">Languages codes</a> are defined in [[!BCP47]]. The <a>default language</a> applies to all
15751575
<a>string</a> values that are not <a href="#type-coercion">type coerced</a>.</p>
15761576

15771577
<p>To clear the <a>default language</a> for a subtree, <code>@language</code> can
@@ -2150,7 +2150,7 @@ <h2>Scoped Contexts</h2>
21502150
{
21512151
"name": "http://schema.org/name",
21522152
"interest": {
2153-
"@id":"http://xmlns.com/foaf/0.1/interest",
2153+
"@id": "http://xmlns.com/foaf/0.1/interest",
21542154
****"@context": {"@vocab": "http://xmlns.com/foaf/0.1/"}****
21552155
}
21562156
},
@@ -2186,7 +2186,6 @@ <h2>Scoped Contexts</h2>
21862186
<a>expanded term definitions</a>
21872187
to create reverse properties as shown in the following example:</p>
21882188

2189-
21902189
<pre class="example" data-transform="updateExample"
21912190
title="Using @reverse to define reverse properties">
21922191
<!--
@@ -2210,6 +2209,35 @@ <h2>Scoped Contexts</h2>
22102209
}
22112210
-->
22122211
</pre>
2212+
2213+
<p>Scoping can also be performed using a term used as a value of <code>@type</code>:</p>
2214+
2215+
<pre class="example" data-transform="updateExample"
2216+
title="Defining an @context within a term definition used on @type">
2217+
<!--
2218+
{
2219+
"@context":
2220+
{
2221+
"name": "http://schema.org/name",
2222+
"interest": "http://xmlns.com/foaf/0.1/interest",
2223+
****"Document"****: {
2224+
"@id": "http://xmlns.com/foaf/0.1/Document",
2225+
****"@context": {"@vocab": "http://xmlns.com/foaf/0.1/"}****
2226+
}
2227+
},
2228+
"@type": "Person",
2229+
"name": "Manu Sporny",
2230+
"interest": {
2231+
"@id": "https://www.w3.org/TR/json-ld/",
2232+
****"@type": "Document"****,
2233+
"name": "JSON-LD",
2234+
"topic": "Linking Data"
2235+
}
2236+
}
2237+
-->
2238+
</pre>
2239+
2240+
<p>Scoping on <code>@type</code> is useful when common properties are used to relate things of different types, where the vocabularies in use within different entities calls for different context scoping. For example, `hasPart`/`partOf` may be common terms used in a document, but mean different things depending on the context.</p>
22132241
</section>
22142242

22152243

@@ -3017,7 +3045,7 @@ <h1>Data Model</h1>
30173045
<p>JSON-LD is a serialization format for Linked Data based on JSON.
30183046
It is therefore important to distinguish between the syntax, which is
30193047
defined by JSON in [[!RFC7159]], and the <dfn>data model</dfn> which is
3020-
an extension of the <a data-cite="rdf11-concepts#data-model">RDF data model</a> [[!RDF11-CONCEPTS]]. The precise
3048+
an extension of the <a data-cite="RDF11-CONCEPTS#data-model">RDF data model</a> [[!RDF11-CONCEPTS]]. The precise
30213049
details of how JSON-LD relates to the RDF data model are given in
30223050
<a class="sectionRef" href="#relationship-to-rdf"></a>.</p>
30233051

@@ -3071,14 +3099,14 @@ <h1>Data Model</h1>
30713099
<li>A <a>typed value</a> consists of a value, which is a string, and a type, which is an
30723100
<a>IRI</a>.</li>
30733101
<li>A <a>language-tagged string</a>
3074-
consists of a string and a non-empty <a data-cite="bcp47#section-2">language tag</a> as defined by [[BCP47]].
3102+
consists of a string and a non-empty <a data-cite="BCP47#section-2">language tag</a> as defined by [[BCP47]].
30753103
The language tag MUST be well-formed according to section
3076-
<a data-cite="bcp47#section-2.2.9">2.2.9 Classes of Conformance</a>
3104+
<a data-cite="BCP47#section-2.2.9">2.2.9 Classes of Conformance</a>
30773105
of [[BCP47]].</li>
30783106
<li>A <a>list</a> is a sequence of zero or more <a>IRIs</a>,
30793107
<a>blank nodes</a>, and <a>JSON-LD values</a>.
30803108
<a>Lists</a> are interpreted as
3081-
<dfn data-cite="rdf11-mt#rdf-collections">RDF list structures</dfn> [[RDF11-MT]].</li>
3109+
<dfn data-cite="RDF11-MT#rdf-collections">RDF list structures</dfn> [[RDF11-MT]].</li>
30823110
</ul>
30833111

30843112
<p><a>JSON-LD documents</a> MAY contain data
@@ -3098,7 +3126,7 @@ <h1>JSON-LD Grammar</h1>
30983126
<p>This appendix restates the syntactic conventions described in the
30993127
previous sections more formally.</p>
31003128

3101-
<p>A <a>JSON-LD document</a> MUST be valid <a data-cite="rfc7159#section-2">JSON text</a> as described
3129+
<p>A <a>JSON-LD document</a> MUST be valid <a data-cite="RFC7159#section-2">JSON text</a> as described
31023130
in [[!RFC7159]].</p>
31033131

31043132
<p>A <a>JSON-LD document</a> MUST be a single <a>node object</a>
@@ -3277,7 +3305,7 @@ <h2>Value Objects</h2>
32773305
an <a>absolute IRI</a>, a <a>relative IRI</a>, or <a>null</a>.</p>
32783306

32793307
<p>The value associated with the <code>@language</code> key MUST have the
3280-
<a data-cite="bcp47#section-2.1.1">lexical form</a> described in [[!BCP47]], or be <a>null</a>.</p>
3308+
<a data-cite="BCP47#section-2.1.1">lexical form</a> described in [[!BCP47]], or be <a>null</a>.</p>
32813309

32823310
<p>The value associated with the <code>@index</code> key MUST be a
32833311
<a>string</a>.</p>
@@ -3429,7 +3457,7 @@ <h2>Context Definitions</h2>
34293457
and <code>@vocab</code>.</p>
34303458

34313459
<p>If the <a>context definition</a> has an <code>@language</code> key,
3432-
its value MUST have the <a data-cite="bcp47#section-2.1.1">lexical form</a> described in [[!BCP47]] or be <a>null</a>.</p>
3460+
its value MUST have the <a data-cite="BCP47#section-2.1.1">lexical form</a> described in [[!BCP47]] or be <a>null</a>.</p>
34333461

34343462
<p>If the <a>context definition</a> has an <code>@base</code> key,
34353463
its value MUST be an <a>absolute IRI</a>, a <a>relative IRI</a>,
@@ -3475,7 +3503,7 @@ <h2>Context Definitions</h2>
34753503
<a>keyword</a> <code>@id</code> or <code>@vocab</code>.</p>
34763504

34773505
<p>If the <a>expanded term definition</a> contains the <code>@language</code> <a>keyword</a>,
3478-
its value MUST have the <a data-cite="bcp47#section-2.1.1">lexical form</a> described in [[!BCP47]] or be <a>null</a>.</p>
3506+
its value MUST have the <a data-cite="BCP47#section-2.1.1">lexical form</a> described in [[!BCP47]] or be <a>null</a>.</p>
34793507

34803508
<p>If the <a>expanded term definition</a> contains the <code>@container</code>
34813509
<a>keyword</a>, its value MUST be either <code>@list</code>, <code>@set</code>,
@@ -3506,12 +3534,12 @@ <h2>Context Definitions</h2>
35063534
<h2>Relationship to RDF</h2>
35073535

35083536
<p>JSON-LD is a
3509-
<dfn data-cite="rdf11-concepts#dfn-concrete-rdf-syntax">concrete RDF syntax</dfn>
3537+
<dfn data-cite="RDF11-CONCEPTS#dfn-concrete-rdf-syntax">concrete RDF syntax</dfn>
35103538
as described in [[RDF11-CONCEPTS]]. Hence, a JSON-LD document is both an
35113539
RDF document <em>and</em> a JSON document and correspondingly represents an
35123540
instance of an RDF data model. However, JSON-LD also extends the RDF data
35133541
model to optionally allow JSON-LD to serialize
3514-
<dfn data-cite="rdf11-concepts#dfn-generalized-rdf-dataset" data-lt="generalized rdf dataset">generalized RDF Datasets</dfn>.
3542+
<dfn data-cite="RDF11-CONCEPTS#dfn-generalized-rdf-dataset" data-lt="generalized rdf dataset">generalized RDF Datasets</dfn>.
35153543
The JSON-LD extensions to the RDF data model are:</p>
35163544

35173545
<ul>
@@ -3559,7 +3587,7 @@ <h2>Relationship to RDF</h2>
35593587
<a>blank nodes</a> used as
35603588
<a>properties</a> to <a>IRIs</a>,
35613589
by minting new "Skolem IRIs" as per
3562-
<a data-cite="rdf11-concepts#section-skolemization">Replacing Blank Nodes with IRIs</a>
3590+
<a data-cite="RDF11-CONCEPTS#section-skolemization">Replacing Blank Nodes with IRIs</a>
35633591
of [[RDF11-CONCEPTS]].</li>
35643592
</ul>
35653593

@@ -3569,7 +3597,7 @@ <h2>Relationship to RDF</h2>
35693597

35703598
<p>Even though JSON-LD serializes
35713599
<a>generalized RDF Datasets</a>, it can
3572-
also be used as a <dfn data-cite="rdf11-concepts#dfn-rdf-source">RDF graph source</dfn>.
3600+
also be used as a <dfn data-cite="RDF11-CONCEPTS#dfn-rdf-source">RDF graph source</dfn>.
35733601
In that case, a consumer MUST only use the default graph and ignore all named graphs.
35743602
This allows servers to expose data in languages such as Turtle and JSON-LD
35753603
using content negotiation.</p>
@@ -4101,7 +4129,7 @@ <h3>application/ld+json</h3>
41014129
<p>When processing the "profile" media type parameter, it is important to
41024130
note that its value contains one or more URIs and not IRIs. In some cases
41034131
it might therefore be necessary to convert between IRIs and URIs as specified in
4104-
<a data-cite="rfc3986#section-5.1">section 3 Relationship between IRIs and URIs</a>
4132+
<a data-cite="RFC3986#section-5.1">section 3 Relationship between IRIs and URIs</a>
41054133
of [[RFC3987]].</p>
41064134
</dd>
41074135
</dl>
@@ -4169,7 +4197,7 @@ <h3>application/ld+json</h3>
41694197

41704198
<p>Fragment identifiers used with <a href="#application-ld-json">application/ld+json</a>
41714199
are treated as in RDF syntaxes, as per
4172-
<a data-cite="rdf11-concepts#section-fragID">RDF 1.1 Concepts and Abstract Syntax</a>
4200+
<a data-cite="RDF11-CONCEPTS#section-fragID">RDF 1.1 Concepts and Abstract Syntax</a>
41734201
[[RDF11-CONCEPTS]].</p>
41744202
</section>
41754203

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example/",
4+
"ex": "http://example.org/",
5+
"idmap": {"@container": "@id"}
6+
}
7+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[{
2+
"http://example/idmap": [
3+
{"http://example/label": [{"@value": "Object with @id <foo>"}], "@id": "http://example.org/foo"}
4+
]
5+
}]
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example/",
4+
"ex": "http://example.org/",
5+
"idmap": {"@container": "@id"}
6+
},
7+
"idmap": {
8+
"ex:foo": {"label": "Object with @id <foo>"}
9+
}
10+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example/",
4+
"typemap": {"@container": "@type"}
5+
}
6+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[{
2+
"http://example/typemap": [
3+
{"http://example/label": [{"@value": "Object with @type <foo>"}], "@type": ["http://example/Foo"]}
4+
]
5+
}]
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example/",
4+
"typemap": {"@container": "@type"}
5+
},
6+
"typemap": {
7+
"Foo": {"label": "Object with @type <foo>"}
8+
}
9+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example/",
4+
"Foo": {"@context": {"bar": "http://example.org/bar"}}
5+
}
6+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[
2+
{
3+
"http://example/a": [{
4+
"@type": ["http://example/Foo"],
5+
"http://example.org/bar": [{"@value": "baz"}]
6+
}]
7+
}
8+
]
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example/",
4+
"Foo": {"@context": {"bar": "http://example.org/bar"}}
5+
},
6+
"a": {"@type": "Foo", "bar": "baz"}
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example/",
4+
"Foo": {"@context": {"bar": {"@type": "@id"}}},
5+
"bar": {"@type": "http://www.w3.org/2001/XMLSchema#string"}
6+
}
7+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[
2+
{
3+
"http://example/a": [{
4+
"@type": ["http://example/Foo"],
5+
"http://example/bar": [{"@id": "http://example/baz"}]
6+
}]
7+
}
8+
]
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example/",
4+
"Foo": {"@context": {"bar": {"@type": "@id"}}},
5+
"bar": {"@type": "http://www.w3.org/2001/XMLSchema#string"}
6+
},
7+
"a": {"@type": "Foo", "bar": "http://example/baz"}
8+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"@context": {
3+
"@vocab": "http://example/",
4+
"type": "@type",
5+
"Foo": {"@context": {"bar": "http://example.org/bar"}}
6+
}
7+
}

0 commit comments

Comments
 (0)