Skip to content

Commit ba3af21

Browse files
committed
Further describe the use of an outer array in 4.1, and introduce the use of @graph for describing unrelated nodes.
1 parent 38772eb commit ba3af21

File tree

2 files changed

+116
-7
lines changed

2 files changed

+116
-7
lines changed

common/terms.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@
223223
See <dfn data-cite="RDF-SCHEMA#ch_collectionvocab" data-lt="collection" class="preserve">RDF collection</dfn> in [[RDF-SCHEMA]].</dd>
224224
<dt><dfn>list object</dfn></dt><dd>
225225
A <a>list object</a> is a <a>dictionary</a> that has a <code>@list</code> key.
226-
It may also have an <a>@index</a> key, but no other members.</dd>
226+
It may also have an <code>@index</code> key, but no other members.</dd>
227227
<dt><dfn>literal</dfn></dt><dd>
228228
An <a>object</a> expressed as a value such as a string, number or in expanded form.</dd>
229229
<dt><dfn>local context</dfn></dt><dd>
@@ -306,7 +306,7 @@
306306
not the <a>base IRI</a>.</dd>
307307
<dt><dfn>set object</dfn></dt><dd>
308308
A <a>set object</a> is a <a>dictionary</a> that has an <code>@set</code> <a>member</a>.
309-
It may also have an <a>@index</a> key, but no other members.</dd>
309+
It may also have an <code>@index</code> key, but no other members.</dd>
310310
<dt><dfn>subject</dfn></dt><dd>
311311
A <a data-cite="RDF11-CONCEPTS#dfn-subject" class="externalDFN">subject</a>
312312
is a <a>node</a> in a <a>linked data graph</a>

index.html

Lines changed: 114 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1754,8 +1754,9 @@ <h1>Advanced Concepts</h1>
17541754
<p>In general, contexts may be used any time a
17551755
<a>dictionary</a> is defined.
17561756
The only time that one cannot express a context is as a direct child of another context definition (other than as part of an <a>expanded term definition</a>).
1757-
For example, a <a>JSON-LD document</a> may use more than one context at different
1758-
points in a document:</p>
1757+
For example, a <a>JSON-LD document</a> may
1758+
have the form of an <a>array</a> composed of one or more <a>node objects</a>,
1759+
which use a context definition in each top-level <a>node object</a>:</p>
17591760

17601761
<aside class="example ds-selector-tabs"
17611762
title="Using multiple contexts">
@@ -1774,8 +1775,7 @@ <h1>Advanced Concepts</h1>
17741775
"name": "Manu Sporny",
17751776
"homepage": "http://manu.sporny.org/",
17761777
"depiction": "http://twitter.com/account/profile_image/manusporny"
1777-
},
1778-
{
1778+
}, {
17791779
****"@context": "https://json-ld.org/contexts/place.jsonld",****
17801780
"name": "The Empire State Building",
17811781
"description": "The Empire State Building is a 102-story landmark in New York City.",
@@ -1857,6 +1857,113 @@ <h1>Advanced Concepts</h1>
18571857
</pre>
18581858
</aside>
18591859

1860+
<p>The outer array is standard for a document in
1861+
<a href="expanded-document-form">expanded document form</a>
1862+
and <a href="flattened-document-form">flattened document form</a>,
1863+
and may be necessary when describing a disconnected graph,
1864+
where nodes may not reference each other. In such cases, using
1865+
a top-level dictionary with a @graph property can be useful for saving
1866+
the repetition of @graph. See <a href="#embedding" class="sectionRef"></a>
1867+
for more.</p>
1868+
1869+
<aside class="example ds-selector-tabs"
1870+
title="Describing disconnected nodes with @graph">
1871+
<div class="selectors">
1872+
<button class="selected" data-selects="original">Original</button>
1873+
<button data-selects="expanded">Expanded</button>
1874+
<button data-selects="statements">Statements</button>
1875+
<button data-selects="turtle">Turtle</button>
1876+
<a class="playground" target="_blank"></a>
1877+
</div>
1878+
<pre class="original selected nohighlight" data-transform="updateExample">
1879+
<!--
1880+
{
1881+
****"@context": "https://json-ld.org/contexts/person.jsonld",****
1882+
****"@graph": [****{
1883+
"name": "Manu Sporny",
1884+
"homepage": "http://manu.sporny.org/",
1885+
"depiction": "http://twitter.com/account/profile_image/manusporny"
1886+
}, {
1887+
"name": "The Empire State Building",
1888+
"description": "The Empire State Building is a 102-story landmark in New York City.",
1889+
"geo": {
1890+
"latitude": "40.75",
1891+
"longitude": "73.98"
1892+
}
1893+
}****]****
1894+
}
1895+
-->
1896+
</pre>
1897+
<pre class="expanded nohighlight" data-transform="updateExample"
1898+
data-result-for="Describing disconnected nodes with @graph-original">
1899+
<!--
1900+
[{
1901+
"http://xmlns.com/foaf/0.1/name": [{"@value": "Manu Sporny"}],
1902+
"http://xmlns.com/foaf/0.1/homepage": [{"@id": "http://manu.sporny.org/"}],
1903+
"http://xmlns.com/foaf/0.1/depiction": [{"@id": "http://twitter.com/account/profile_image/manusporny"}]
1904+
}, {
1905+
"http://purl.org/dc/terms/title": [{"@value": "The Empire State Building"}],
1906+
"http://purl.org/dc/terms/description": [{
1907+
"@value": "The Empire State Building is a 102-story landmark in New York City."
1908+
}],
1909+
"http://schema.org/geo": [{
1910+
"http://www.w3.org/2003/01/geo/wgs84_pos#lat": [{
1911+
"@type": "http://www.w3.org/2001/XMLSchema#decimal",
1912+
"@value": "40.75"
1913+
}],
1914+
"http://www.w3.org/2003/01/geo/wgs84_pos#long": [{
1915+
"@type": "http://www.w3.org/2001/XMLSchema#decimal",
1916+
"@value": "73.98"
1917+
}]
1918+
}]
1919+
}]
1920+
-->
1921+
</pre>
1922+
<table class="statements"
1923+
data-result-for="Describing disconnected nodes with @graph-expanded"
1924+
data-to-rdf>
1925+
<thead><tr><th>Subject</th><th>Property</th><th>Value</th><th>Value Type</th></tr></thead>
1926+
<tbody>
1927+
<tr><td>_:b0</td><td>foaf:name</td><td>Manu Sporny</td><td></td></tr>
1928+
<tr><td>_:b0</td><td>foaf:homepage</td><td>http://manu.sporny.org/</td><td></td></tr>
1929+
<tr><td>_:b0</td><td>foaf:depiction</td><td>http://twitter.com/account/profile_image/manusporny</td><td></td></tr>
1930+
<tr><td>_:b1</td><td>dc:title</td><td>The Empire State Building</td><td></td></tr>
1931+
<tr><td>_:b1</td><td>dc:description</td><td>The Empire State Building is a 102-story landmark in New York City.</td><td></td></tr>
1932+
<tr><td>_:b2</td><td>geo:lat</td><td>40.75</td><td>xsd:decimal</td></tr>
1933+
<tr><td>_:b2</td><td>geo:long</td><td>73.98</td><td>xsd:decimal</td></tr>
1934+
<tr><td>_:b1</td><td>schema:geo</td><td>_:b2</td><td></td></tr>
1935+
</tbody>
1936+
</table>
1937+
<pre class="turtle"
1938+
data-content-type="text/turtle"
1939+
data-result-for="Describing disconnected nodes with @graph-expanded"
1940+
data-transform="updateExample"
1941+
data-to-rdf>
1942+
<!--
1943+
@prefix dc: <http://purl.org/dc/terms/> .
1944+
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
1945+
@prefix geo: <http://www.w3.org/2003/01/geo/wgs84_pos#> .
1946+
@prefix schema: <http://schema.org/> .
1947+
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
1948+
1949+
[
1950+
foaf:name "Manu Sporny";
1951+
foaf:homepage <http://manu.sporny.org/>;
1952+
foaf:depiction <http://twitter.com/account/profile_image/manusporny>
1953+
] .
1954+
1955+
[
1956+
dc:title "The Empire State Building";
1957+
dc:description "The Empire State Building is a 102-story landmark in New York City.";
1958+
schema:geo [
1959+
geo:lat 40.75;
1960+
geo:long 73.98
1961+
]
1962+
] .
1963+
-->
1964+
</pre>
1965+
</aside>
1966+
18601967
<p>Duplicate context <a>terms</a> are overridden using a
18611968
most-recently-defined-wins mechanism.</p>
18621969

@@ -1928,7 +2035,9 @@ <h1>Advanced Concepts</h1>
19282035
</aside>
19292036

19302037
<p>In the example above, the <code>name</code> <a>term</a> is overridden
1931-
in the more deeply nested <code>details</code> structure. Note that this is
2038+
in the more deeply nested <code>details</code> structure,
2039+
which uses its own <a>embedded context</a>.
2040+
Note that this is
19322041
rarely a good authoring practice and is typically used when working with
19332042
legacy applications that depend on a specific structure of the
19342043
<a>dictionary</a>. If a <a>term</a> is redefined within a

0 commit comments

Comments
 (0)