Skip to content

Commit 88632b5

Browse files
committed
Added section on Property Generators to resolve issue #142.
1 parent e54949f commit 88632b5

File tree

1 file changed

+77
-7
lines changed

1 file changed

+77
-7
lines changed

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

Lines changed: 77 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,7 +1419,7 @@ <h2>Language Values</h2>
14191419
type with a particular <tref>term</tref> in the <code>@context</code>:</p>
14201420

14211421
<pre class="example" data-transform="updateExample"
1422-
title="Expanded term definition with language coerceion">
1422+
title="Expanded term definition with language coercion">
14231423
<!--
14241424
{
14251425
****"@context":
@@ -1863,12 +1863,82 @@ <h2>Type Coercion</h2>
18631863
great deal of confusion among developers attempting to understand the JSON-LD document.</p>
18641864

18651865
<p>Type coercion is performed using the unexpanded value of the key,
1866-
which MUST have an exact match for an entry in the <tref>active context</tref>.</p>
1866+
which MUST have an exact match for an entry in the
1867+
<tref>active context</tref>.</p>
18671868

18681869
</section>
18691870

1871+
18701872
<section>
1871-
<h3>IRI Expansion Within a Context</h3>
1873+
<h2>Property Generators</h2>
1874+
1875+
<p>At times, an author may find that they need to express the same value for
1876+
multiple properties. The simplest approach to accomplish this goal would be
1877+
to do the following:</p>
1878+
1879+
<pre class="example" data-transform="updateExample"
1880+
title="Verbose expression of multiple properties with the same value">
1881+
<!--
1882+
{
1883+
"@context":
1884+
{
1885+
****"title1": "http://purl.org/dc/terms/title"****,
1886+
****"title2": "http://schema.org/name"****,
1887+
****"title3": "http://www.w3.org/2000/01/rdf-schema#label"****
1888+
},
1889+
"@id": "http://example.com/book",
1890+
****"title1": "The Count of Monte Cristo"****,
1891+
****"title2": "The Count of Monte Cristo"****,
1892+
****"title3": "The Count of Monte Cristo"****
1893+
}
1894+
-->
1895+
</pre>
1896+
1897+
<p>Unfortunately, the approach above produces redundant data and would become a
1898+
publishing burden for large data sets.
1899+
In these situations, the author may use
1900+
a <tdef>property generator</tdef> to express a <tref>term</tref> once, but have
1901+
the JSON-LD processor expand the single statement into multiple statements.
1902+
This method can be accomplished by using the following markup pattern:</p>
1903+
1904+
<pre class="example" data-transform="updateExample"
1905+
title="Generating multiple properties using a single term">
1906+
<!--
1907+
{
1908+
"@context":
1909+
{
1910+
****"title": { "@id": ["http://purl.org/dc/terms/title",
1911+
"http://schema.org/name",
1912+
"http://www.w3.org/2000/01/rdf-schema#label"] }****,
1913+
},
1914+
"@id": "http://example.com/book",
1915+
****"title": "The Count of Monte Cristo"****
1916+
}
1917+
-->
1918+
</pre>
1919+
1920+
<p>While the term above is only used once outside of the <code>@context</code>,
1921+
a JSON-LD processor will internally transform the document above into
1922+
the following set of statements:</p>
1923+
1924+
<pre class="example" data-transform="updateExample">
1925+
<!--
1926+
<http://example.com/book>
1927+
<http://purl.org/dc/terms/title>
1928+
"The Count of Monte Cristo" .
1929+
<http://example.com/book>
1930+
<http://schema.org/name>
1931+
"The Count of Monte Cristo" .
1932+
<http://example.com/book>
1933+
<http://www.w3.org/2000/01/rdf-schema#label>
1934+
"The Count of Monte Cristo" .
1935+
-->
1936+
</pre>
1937+
1938+
</section>
1939+
1940+
<section>
1941+
<h2>IRI Expansion Within a Context</h2>
18721942
<p>In general, normal IRI expansion rules apply
18731943
anywhere an IRI is expected (see <a href="#iris"></a>). Within
18741944
a <tref>context</tref> definition, this can mean that terms defined
@@ -2811,14 +2881,14 @@ <h2>Context Definition</h2>
28112881
<p>An <tdef>expanded term definition</tdef> is composed of zero or more keys from <code>@id</code>,
28122882
<code>@type</code>, <code>@language</code> or <code>@container</code>. An
28132883
<tref>expanded term definition</tref> MUST NOT contain any other keys.
2814-
The value of <code>@id</code> MUST expand to an <tref>absolute IRI</tref>.</p>
2815-
<p>If the <tref>term</tref> definition does not have the form of <tref>compact IRI</tref> or <tref>absolute IRI</tref>,
2884+
All values associated with <code>@id</code> MUST expand to an <tref>absolute IRI</tref>.</p>
2885+
<p>If the <tref>term</tref> definition is not a <tref>compact IRI</tref> or <tref>absolute IRI</tref>,
28162886
the <tref>expanded term
28172887
definition</tref> MUST include the <code>@id</code> key.</p>
28182888
<p>If the <tref>expanded term definition</tref> contains the <code>@id</code> <tref>keyword</tref>,
28192889
it MUST be a <tref>string</tref> having the lexical form of <tref>IRI</tref>,
2820-
<tref>compact IRI</tref>, or a <tref>term</tref> defined in the defining <tref>context
2821-
definition</tref> or the <tref>active context</tref>.</p>
2890+
<tref>compact IRI</tref>, a <tref>term</tref> defined in the defining <tref>context
2891+
definition</tref> or the <tref>active context</tref>, or an <tref>array</tref> composed of any of the previous allowed values.</p>
28222892
<p>If the <tref>expanded term definition</tref> contains the <code>@type</code> <tref>keyword</tref>,
28232893
it MUST be a <tref>string</tref> having the lexical form of <tref>absolute IRI</tref>,
28242894
<tref>compact IRI</tref>, or a <tref>term</tref> defined in the defining <tref>context

0 commit comments

Comments
 (0)