Skip to content

Commit a3bd0f1

Browse files
committed
Add a section on using HTML documents for contexts (and frames).
For w3c/json-ld-api#66.
1 parent 449c65f commit a3bd0f1

File tree

2 files changed

+171
-8
lines changed

2 files changed

+171
-8
lines changed

Gemfile.lock

Lines changed: 7 additions & 5 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: 3ad421e9e0328be7225809012f0091c269e84b5c
3+
revision: 74a05a9f623c5a9e02cbe42f053f9d09181fee97
44
branch: develop
55
specs:
66
json-ld (3.0.2)
@@ -75,14 +75,14 @@ GEM
7575
multi_json (1.13.1)
7676
net-http-persistent (3.0.0)
7777
connection_pool (~> 2.2)
78-
nokogiri (1.10.2)
78+
nokogiri (1.10.3)
7979
mini_portile2 (~> 2.4.0)
8080
nokogumbo (1.5.0)
8181
nokogiri
8282
public_suffix (3.0.3)
8383
rack (2.0.7)
8484
rake (12.3.2)
85-
rdf (3.0.11)
85+
rdf (3.0.12)
8686
hamster (~> 3.0)
8787
link_header (~> 0.0, >= 0.0.8)
8888
rdf-aggregate-repo (2.2.1)
@@ -96,8 +96,10 @@ GEM
9696
nokogiri (~> 1.8)
9797
rdf (>= 2.2.8, < 4.0)
9898
rdf-xsd (>= 2.2, < 4.0)
99-
rdf-n3 (3.0.1)
99+
rdf-n3 (3.1.0)
100100
rdf (~> 3.0)
101+
sparql (~> 3.0)
102+
sxp (~> 1.0)
101103
rdf-normalize (0.3.3)
102104
rdf (>= 2.2, < 4.0)
103105
rdf-rdfa (3.0.1)
@@ -128,7 +130,7 @@ GEM
128130
rdf-turtle (~> 3.0, >= 3.0.3)
129131
rdf-trix (2.2.1)
130132
rdf (>= 2.2, < 4.0)
131-
rdf-turtle (3.0.5)
133+
rdf-turtle (3.0.6)
132134
ebnf (~> 1.1)
133135
rdf (~> 3.0)
134136
rdf-vocab (3.0.5)

index.html

Lines changed: 164 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,7 @@ <h2>The Context</h2>
898898
information located outside of the <code>@context</code> key, such as
899899
documentation about the <a>terms</a> declared in the
900900
document. Information contained outside of the <code>@context</code> value
901-
is ignored when the document is used as an external JSON-LD context document.</p>
901+
is ignored when the document is used as an external <dfn data-lt="context document">JSON-LD context document</dfn>.</p>
902902

903903
<p>JSON documents can be interpreted as JSON-LD without having to be modified by
904904
referencing a <a>context</a> via an <a data-cite="RFC8288#section-3">HTTP Link Header</a>
@@ -9989,6 +9989,16 @@ <h3>Graph Containers</h3>
99899989
<code>profile</code> parameter which can be used to signal or request
99909990
<dfn>framed document form</dfn>. The profile URI identifying
99919991
<a>framed document form</a> is <code>http://www.w3.org/ns/json-ld#framed</code>.</p>
9992+
9993+
<p><a href="#application-ld-json">JSON-LD's media type</a> also defines a
9994+
<code>profile</code> parameter which can be used to identify a
9995+
<a data-cite="HTML/semantics-scripting.html#the-script-element">script element</a> in an HTML document containing a frame.
9996+
The first <a data-cite="HTML/semantics-scripting.html#the-script-element">script element</a>
9997+
of type <code>application/ld+json;profile=http://www.w3.org/ns/json-ld#frame</code>
9998+
will be used to find a <a>frame</a>.
9999+
This is similar to the mechanism described for retrieving contexts
10000+
from HTML documents as described in
10001+
<a href="#using-an-html-document-as-a-context" class="sectionRef"></a>.</p>
999210002
</section>
999310003
</section>
999410004

@@ -10072,7 +10082,7 @@ <h3>Graph Containers</h3>
1007210082

1007310083
<p>
1007410084
JSON-LD content can be easily embedded in HTML [[HTML]] by placing
10075-
it in a <a data-cite="HTML/semantics-scripting.html#the-script-element">Script element</a> with the <code>type</code> attribute set to
10085+
it in a <a data-cite="HTML/semantics-scripting.html#the-script-element">script element</a> with the <code>type</code> attribute set to
1007610086
<code>application/ld+json</code>. Doing so creates a
1007710087
<a data-cite="HTML/semantics-scripting.html#data-block">data block</a>.</p>
1007810088

@@ -10443,6 +10453,147 @@ <h3>Graph Containers</h3>
1044310453
</pre>
1044410454
</aside>
1044510455
</section>
10456+
10457+
<section><h3>Using an HTML document as a Context</h3>
10458+
<p>A JSON-LD document, whether embedded in HTML or otherwise,
10459+
may reference a <a>context document</a> by using a string value to <code>@context</code>.
10460+
This string is interpreted as a URL to an external document from which
10461+
the context is loaded. In JSON-LD 1.1, this external document may also
10462+
be HTML containing a <a data-cite="HTML/semantics-scripting.html#the-script-element">script element</a>
10463+
with the <code>type</code> attribute set to
10464+
<code>application/ld+json;profile=http://www.w3.org/ns/json-ld#context</code>.</p>
10465+
10466+
<p>A processor processing a remote context which results in an HTML document
10467+
MUST locate the first <a data-cite="HTML/semantics-scripting.html#the-script-element">script element</a>
10468+
with the <code>type</code> attribute set to
10469+
<code>application/ld+json;profile=http://www.w3.org/ns/json-ld#context</code>,
10470+
or a specific script element targeted using a fragment identifier,
10471+
or the first script element of type <code>application/ld+json</code>
10472+
if no other is found.</p>
10473+
10474+
<p>Including a context definition within an HTML document provides a means
10475+
of documenting the context content, along with other information
10476+
such as the vocabulary definition.</p>
10477+
10478+
<p>For example, a context may be defined within an HTML file as follows
10479+
(a subset of the <em>Person</em> context published at <code><a href="https://json-ld.org/contexts/person.html">https://json-ld.org/contexts/person.html</a></code>):</p>
10480+
10481+
<pre class="example context"
10482+
title="Context defined in an HTML document"
10483+
data-content-type="text/html"
10484+
data-transform="updateExample">
10485+
<!--
10486+
<!DOCTYPE html>
10487+
<html lang="en">
10488+
<head>
10489+
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
10490+
<title>Context definition of a person</title>
10491+
<script ****type="application/ld+json;profile=http://www.w3.org/ns/json-ld#context"****>
10492+
{
10493+
"@context":
10494+
{
10495+
"foaf": "http://xmlns.com/foaf/0.1/",
10496+
"schema": "http://schema.org/",
10497+
"vcard": "http://www.w3.org/2006/vcard/ns#",
10498+
"xsd": "http://www.w3.org/2001/XMLSchema#",
10499+
"Address": "vcard:Address"####,
10500+
...####
10501+
}
10502+
}
10503+
</script>
10504+
</head>
10505+
<body>
10506+
<h1>The Person context</h1>
10507+
<p>The Person context is based on a combination of <a href="http://xmlns.com/foaf/0.1/">FOAF</a>,
10508+
<a href="http://schema.org/">schema.org </a>,
10509+
and <a href="http://www.w3.org/2006/vcard/ns#">vcard</a> vocabularies. It defines the following terms:</p>
10510+
10511+
<dl>
10512+
<dt>foaf</dt><dd><code>http://xmlns.com/foaf/0.1/</code></dd>
10513+
<dt>schema</dt><dd><code>http://schema.org/</code></dd>
10514+
<dt>vcard</dt><dd><code>http://www.w3.org/2006/vcard/ns#</code></dd>
10515+
<dt>xsd</dt><dd><code>http://www.w3.org/2001/XMLSchema#</code></dd>
10516+
<dt>Address</dt><dd><code>vcard:Address</code></dd>
10517+
####...####
10518+
</dl>
10519+
</body>
10520+
</html>
10521+
-->
10522+
</pre>
10523+
10524+
<p>Using a previous example, we can reference <code>https://json-ld.org/contexts/person.html</code>
10525+
instead of <code>https://json-ld.org/contexts/person.jsonld</code>
10526+
and a JSON-LD processor will look for the context within the referenced HTML file.</p>
10527+
10528+
<aside class="example ds-selector-tabs"
10529+
title="Referencing a Context in an HTML document">
10530+
<div class="selectors">
10531+
<button class="selected" data-selects="original">Original</button>
10532+
<button data-selects="expanded">Expanded</button>
10533+
<button data-selects="statements">Statements</button>
10534+
<button data-selects="turtle">Turtle</button>
10535+
<a class="playground" target="_blank"></a>
10536+
</div>
10537+
<pre class="original selected nohighlight" data-transform="updateExample">
10538+
<!--
10539+
{
10540+
"@context": ****"https://json-ld.org/contexts/person.html"****,
10541+
"@id": "http://dbpedia.org/resource/John_Lennon",
10542+
"name": "John Lennon",
10543+
"born": "1940-10-09",
10544+
"spouse": "http://dbpedia.org/resource/Cynthia_Lennon"
10545+
}
10546+
-->
10547+
</pre>
10548+
<pre class="expanded"
10549+
data-transform="updateExample"
10550+
data-result-for="Referencing a Context in an HTML document-original">
10551+
<!--
10552+
[{
10553+
"@id": "http://dbpedia.org/resource/John_Lennon",
10554+
"http://xmlns.com/foaf/0.1/name": [{"@value": "John Lennon"}],
10555+
"http://schema.org/birthDate": [
10556+
{"@value": "1940-10-09", "@type": "http://www.w3.org/2001/XMLSchema#date"}
10557+
],
10558+
"http://schema.org/spouse": [
10559+
{"@id": "http://dbpedia.org/resource/Cynthia_Lennon"}
10560+
]
10561+
}]
10562+
-->
10563+
</pre>
10564+
<table class="statements"
10565+
data-result-for="Referencing a Context in an HTML document-expanded"
10566+
data-to-rdf>
10567+
<thead><tr><th>Subject</th><th>Property</th><th>Value</th><th>Value Type</th></tr></thead>
10568+
<tbody>
10569+
<tr><td>http://dbpedia.org/resource/John_Lennon</td><td>foaf:name</td><td>John Lennon</td><td>&nbsp;</td></tr>
10570+
<tr><td>http://dbpedia.org/resource/John_Lennon</td><td>schema:birthDate</td><td>1940-10-09</td><td>xsd:date</td></tr>
10571+
<tr><td>http://dbpedia.org/resource/John_Lennon</td><td>schema:spouse</td><td>http://dbpedia.org/resource/Cynthia_Lennon</td><td>&nbsp;</td></tr>
10572+
</tbody>
10573+
</table>
10574+
<pre class="turtle"
10575+
data-content-type="text/turtle"
10576+
data-transform="updateExample"
10577+
data-result-for="Referencing a Context in an HTML document-expanded"
10578+
data-to-rdf>
10579+
<!--
10580+
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
10581+
@prefix schema: <http://schema.org/> .
10582+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
10583+
10584+
<http://dbpedia.org/resource/John_Lennon> foaf:name "John Lennon";
10585+
schema:birthDate "1940-10-09"^^xsd:date;
10586+
schema:spouse <http://dbpedia.org/resource/Cynthia_Lennon> .
10587+
-->
10588+
</pre>
10589+
</aside>
10590+
10591+
<p>In addition to using the type profile above, a context may be referenced using
10592+
a fragment identifier,
10593+
as described in <a href="#locating-a-specific-json-ld-script-element" class="sectionRef"></a>.
10594+
Otherwise, the first <a data-cite="HTML/semantics-scripting.html#the-script-element">script element</a>
10595+
of type <code>application/ld+json</code> will be used to find a context.</p>
10596+
</section>
1044610597
</section>
1044710598

1044810599
<section class="normative">
@@ -12151,14 +12302,18 @@ <h3>application/ld+json</h3>
1215112302
It is RECOMMENDED that profile URIs are dereferenceable and provide
1215212303
useful documentation at that URI. For more information and background
1215312304
please refer to [[RFC6906]].</p>
12154-
<p>This specification defines four values for the <code>profile</code> parameter.</p>
12305+
<p>This specification defines six values for the <code>profile</code> parameter.</p>
1215512306
<dl>
1215612307
<dt><code>http://www.w3.org/ns/json-ld#expanded</code></dt>
1215712308
<dd>To request or specify <a data-lt="expanded document form">expanded JSON-LD document form</a>.</dd>
1215812309
<dt><code>http://www.w3.org/ns/json-ld#compacted</code></dt>
1215912310
<dd>To request or specify <a data-lt="compacted document form">compacted JSON-LD document form</a>.</dd>
12311+
<dt><code>http://www.w3.org/ns/json-ld#context</code></dt>
12312+
<dd>To request or specify a <a data-lt="context document">JSON-LD context document</a>.</dd>
1216012313
<dt><code>http://www.w3.org/ns/json-ld#flattened</code></dt>
1216112314
<dd>To request or specify <a data-lt="flattened document form">flattened JSON-LD document form</a>.</dd>
12315+
<dt><code>http://www.w3.org/ns/json-ld#frame</code></dt>
12316+
<dd>To request or specify a <a data-lt="frame">JSON-LD frame document</a>.</dd>
1216212317
<dt><code>http://www.w3.org/ns/json-ld#framed</code></dt>
1216312318
<dd>To request or specify <a data-lt="framed document form">framed JSON-LD document form</a>.</dd>
1216412319
</dl>
@@ -12378,6 +12533,12 @@ <h2>Changes since JSON-LD Community Group Final Report</h2>
1237812533
Define the <code>rdf:JSON</code> datatype.</li>
1237912534
<li><a>Term definitions</a> with keys which are of the form of a <a>compact IRI</a> or <a>absolute IRI</a> MUST NOT
1238012535
expand to an <a>IRI</a> other than the expansion of the key itself.</li>
12536+
<li>If a retrieved context URL returns an HTML document, the first script element
12537+
of type <code>application/ld+json;profile=http://www.w3.org/ns/json-ld#context</code>,
12538+
or <code>application/ld+json</code> is used as the context for further processing.
12539+
This allows a mechanism for documenting the content of a context using HTML.</li>
12540+
<li>A <a>frame</a> may also be located within an HTML document, identified
12541+
using type <code>application/ld+json;profile=http://www.w3.org/ns/json-ld#frame</code>.</li>
1238112542
</ul>
1238212543
</section>
1238312544

0 commit comments

Comments
 (0)