Skip to content

Commit 9885ffe

Browse files
committed
Introduction to named graphs in the syntax document, with advisory.
1 parent ca499ba commit 9885ffe

File tree

2 files changed

+102
-4
lines changed

2 files changed

+102
-4
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -826,7 +826,7 @@ <h2>Syntax Tokens and Keywords</h2>
826826
<dt><code>@container</code></dt><dd>Used to set the container of a particular value.</dd>
827827
<dt><code>@list</code></dt><dd>Used to express an ordered set of data.</dd>
828828
<dt><code>@set</code></dt><dd>Used to express an unordered set of data.</dd>
829-
<dt><code>@graph</code></dt><dd>Used to explicitely express a <tref>linked data graph</tref>.</dd>
829+
<dt><code>@graph</code></dt><dd>Used to explicitly express a <tref>linked data graph</tref>.</dd>
830830
<dt><code>:</code></dt><dd>The separator for JSON keys and values that use <tref title="compact_iri">compact IRIs</tref>.</dd>
831831
</dl>
832832

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

Lines changed: 101 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,7 @@ <h2>Syntax Tokens and Keywords</h2>
407407
developers express specific identifiers in a compact manner. The
408408
<code>@context</code> keyword is described in detail in the section titled
409409
<a href="#the-context">The Context</a>.</dd>
410+
<dt><code>@graph</code></dt><dd>Used to explicitly express a <tref>linked data graph</tref>.</dd>
410411
<dt><code>@id</code></dt>
411412
<dd>Used to uniquely identify things that are being described in the document.
412413
This keyword is described in the section titled
@@ -678,7 +679,7 @@ <h3>The Context</h3>
678679
<p>
679680
The set of contexts defined within a specific <tref>JSON Object</tref> are
680681
referred to as <tdef>local context</tdef>s. Setting the context to <code>null</code>
681-
effectively sets the <tdef>local context</tdef> to it's initial state. The
682+
effectively sets the <tref>local context</tref> to it's initial state. The
682683
<tdef>active context</tdef> refers to the accumulation of
683684
<tref>local context</tref>s that are in scope at a specific point within
684685
the document. The following example specifies an external context and then
@@ -1928,12 +1929,109 @@ <h2>Embedding</h2>
19281929
</p>
19291930
</section>
19301931

1932+
<section>
1933+
<h2>Named Graphs</h2>
1934+
<p class="issue">This section is provisional, as the group has not yet decided to include
1935+
support for named graphs. However, the use of the <code>@graph</code> keyword does have
1936+
meaning for a top-level object definition.</p>
1937+
<p>The <code>@graph</code> is used to identify a set of JSON-LD object definitions that may not be directly
1938+
related through a property, or where <tref>embedding</tref> is not appropriate. For example:</p>
1939+
1940+
<pre class="example" data-transform="updateExample">
1941+
<!--
1942+
{
1943+
"@context": ...,
1944+
"@graph":
1945+
[
1946+
{
1947+
"@id": "http://manu.sporny.org/i/public",
1948+
"@type": "foaf:Person",
1949+
"name": "Manu Sporny",
1950+
"knows" "http://greggkellogg.net/foaf#me"
1951+
},
1952+
{
1953+
"@id": "http://greggkellogg.net/foaf#me",
1954+
"@type": "foaf:Person",
1955+
"name": "Gregg Kellogg",
1956+
"knows" "http://manu.sporny.org/i/public"
1957+
}
1958+
]
1959+
}
1960+
-->
1961+
</pre>
1962+
1963+
<p>In this case, embedding doesn't work as each JSON-LD object references the other.
1964+
Using the <code>@graph</code>
1965+
keyword allows multiple resources to be defined within an <tref>array</tref>, and allows the use
1966+
of a shared <tref>context</tref>. This is equivalent to using multiple <tref>JSON Object</tref>
1967+
definitions in array and defining the <code>@context</code> within each object:</p>
1968+
1969+
<pre class="example" data-transform="updateExample">
1970+
<!--
1971+
****[****
1972+
{
1973+
****"@context": ...,****
1974+
"@id": "http://manu.sporny.org/i/public",
1975+
"@type": "foaf:Person",
1976+
"name": "Manu Sporny",
1977+
"knows" "http://greggkellogg.net/foaf#me"
1978+
},
1979+
{
1980+
****"@context": ...,****
1981+
"@id": "http://greggkellogg.net/foaf#me",
1982+
"@type": "foaf:Person",
1983+
"name": "Gregg Kellogg",
1984+
"knows" "http://manu.sporny.org/i/public"
1985+
}
1986+
****]****
1987+
-->
1988+
</pre>
1989+
1990+
<p>The <code>@graph</code> keyword takes on additional meaning when it is used along with
1991+
other properties, or is used within an embedded JSON-LD object. In this case, the set
1992+
of JSON-LD objects contained within a <code>@graph</code> is given a <em>name</em>, based
1993+
on the label of the JSON-LD object containing a <code>@graph</code> property, either an
1994+
<tref>IRI</tref>, or an <tref>unlabeled node</tref>. This allows statements to be
1995+
made about an entire <tref>linked data graph</tref>, rather than just a single JSON-LD object.</p>
1996+
1997+
<pre class="example" data-transform="updateExample">
1998+
<!--
1999+
{
2000+
"@context": ...,
2001+
****"@id": "http://example.org/linked-data-graph",
2002+
"@type": "Graph",
2003+
"asOf": {"@value": "2012-04-09", "@type": "xsd:date"},****
2004+
"@graph":
2005+
[
2006+
{
2007+
"@id": "http://manu.sporny.org/i/public",
2008+
"@type": "foaf:Person",
2009+
"name": "Manu Sporny",
2010+
"knows" "http://greggkellogg.net/foaf#me"
2011+
},
2012+
{
2013+
"@id": "http://greggkellogg.net/foaf#me",
2014+
"@type": "foaf:Person",
2015+
"name": "Gregg Kellogg",
2016+
"knows" "http://manu.sporny.org/i/public"
2017+
}
2018+
]
2019+
}
2020+
-->
2021+
</pre>
2022+
2023+
<p>This example says that there is a <tref>linked data graph</tref> identified by
2024+
<code>http://example.org/linked-data-graph</code> which is composed of the statements
2025+
about Manu and Gregg. Additionally, there is information about the graph itself, which
2026+
indicates a time at which this information as asserted to be true.</p>
2027+
</section>
2028+
19312029
<section>
19322030
<h2>Identifying Unlabeled Nodes</h2>
19332031

19342032
<p>At times, it becomes necessary to be able to express information without
19352033
being able to specify the subject. Typically, this type of node is called
1936-
an unlabeled node or a blank node. In JSON-LD, unlabeled node identifiers are
2034+
an <tref>unlabeled node</tref> or a blank node. In JSON-LD, <tref>unlabeled node</tref> identifiers are
19372035
automatically created if a subject is not specified using the
19382036
<code>@id</code> keyword. However, authors may provide identifiers for
19392037
unlabeled nodes by using the special <code>_</code> (underscore)
@@ -1952,7 +2050,7 @@ <h2>Identifying Unlabeled Nodes</h2>
19522050

19532051
<p>The example above would set the subject to <code>_:foo</code>, which can
19542052
then be used later on in the JSON-LD markup to refer back to the
1955-
unlabeled node. This practice, however, is usually frowned upon when
2053+
<tref>unlabeled node</tref>. This practice, however, is usually frowned upon when
19562054
generating <tref>Linked Data</tref>. If a developer finds that they refer to the unlabeled
19572055
node more than once, they should consider naming the node using a resolve-able
19582056
<tref>IRI</tref>.

0 commit comments

Comments
 (0)