Skip to content

Commit c791991

Browse files
authored
Merge pull request #17 from w3c/fix-15-restructuring
Fix 15 - Restructuring
2 parents 778732e + 4a3a9f1 commit c791991

File tree

1 file changed

+79
-69
lines changed

1 file changed

+79
-69
lines changed

index.html

Lines changed: 79 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,11 @@ <h2>Terminology</h2>
8787
</dl>
8888
</section>
8989

90+
91+
9092
<section>
91-
<h2>Resource Representation</h2>
93+
<h2>Data Documents</h2>
94+
9295
<section>
9396
<h3 id="use-json">Publish data using developer friendly JSON</h3>
9497
<p class="practicedesc">JSON [[json]] is the most popular format for publishing data through APIs; developers like it, it is easy to parse, and it is supported natively in most programming languages.</p>
@@ -102,6 +105,21 @@ <h3 id="use-json">Publish data using developer friendly JSON</h3>
102105
</pre>
103106
</section>
104107

108+
<section>
109+
<h3 id="top-level-object">Use a top-level object</h3>
110+
<p class="practicedesc">JSON documents may be in the form of a object, or an array of objects. For most purposes, developers need a single entry point, so the JSON SHOULD be in the form of a single top-level object</p>
111+
</section>
112+
113+
<section>
114+
<h3 id="native-values">Use native values</h3>
115+
<p class="practicedesc">When possible, property values SHOULD use native JSON datatypes such as numbers (<em>integer</em>, <em>decimal</em> and <em>floating point</em>) and booleans (<code>true</code> and <code>false</code>).</p>
116+
</section>
117+
118+
<section>
119+
<h3 id="unordered-values">Assume arrays are unordered</h3>
120+
<p class="practicedesc">JSON specifies that the values in an array are ordered, however in many cases arrays are also used for values which are unordered. Unless specified within the <a>JSON-LD Context</a>, multiple array values SHOULD be presumed to be unordered. (See <cite><a href="http://www.w3.org/TR/json-ld/#lists-and-sets">Lists and Sets</a></cite> in [[JSON-LD]]).</p>
121+
</section>
122+
105123
<section>
106124
<h3 id="use-json-ld">Use well-known identifiers when describing data</h3>
107125
<p class="practicedesc">By sticking to basic JSON data expression, and providing a <a>JSON-LD Context</a>, all keys used within a JSON document can have unambigious meaning, as they bind to URLs which describe their meaning.</p>
@@ -130,26 +148,6 @@ <h3 id="use-json-ld">Use well-known identifiers when describing data</h3>
130148
</div>
131149
</section>
132150

133-
<section>
134-
<h3 id="cache-context">Cache JSON-LD Contexts</h3>
135-
<p class="practicedesc">While most use of JSON-LD should not require a client to change the data representation, JSON-LD does allow the use of various algorithms to re-shape a JSON-LD document. These require the use of the <a>JSON-LD Context</a>, which is typically represented using a link to a remote document. Because it is remote, processing time can be severely impacted by the time it takes to retrieve this context. Services providing a <a>JSON-LD Context</a> SHOULD set HTTP cache-control headers to allow liberal caching of such contexts, and clients SHOULD attempt to use a locally cached version of these documents. Typically, libraries used to process JSON-LD documents should do this for you. (See also [[json-ld-best-practice-caching]]).</p>
136-
</section>
137-
138-
<section>
139-
<h3 id="top-level-object">Use a top-level object</h3>
140-
<p class="practicedesc">JSON documents may be in the form of a object, or an array of objects. For most purposes, developers need a single entry point, so the JSON SHOULD be in the form of a single top-level object</p>
141-
</section>
142-
143-
<section>
144-
<h3 id="native-values">Use native values</h3>
145-
<p class="practicedesc">When possible, property values SHOULD use native JSON datatypes such as numbers (<em>integer</em>, <em>decimal</em> and <em>floating point</em>) and booleans (<code>true</code> and <code>false</code>).</p>
146-
</section>
147-
148-
<section>
149-
<h3 id="unordered-values">Assume arrays are unordered</h3>
150-
<p class="practicedesc">JSON specifies that the values in an array are ordered, however in many cases arrays are also used for values which are unordered. Unless specified within the <a>JSON-LD Context</a>, multiple array values SHOULD be presumed to be unordered. (See <cite><a href="http://www.w3.org/TR/json-ld/#lists-and-sets">Lists and Sets</a></cite> in [[JSON-LD]]).</p>
151-
</section>
152-
153151
<section>
154152
<h3 id="typed-objects">Provide one or more types for JSON objects</h3>
155153
<p class="practicedesc">Principles of <a>Linked Data</a> dictate that messages SHOULD be self describing, which includes adding a <code>type</code> to such messages.</p>
@@ -213,54 +211,27 @@ <h3 id="use-ids">Identify objects with a unique identifier</h3>
213211
</section>
214212

215213
<section>
216-
<h3 id="dereferencable-entities">Provide a representation of the entity related by URL</h3>
217-
<p class="practicedesc">When dereferencing an entity related via a URL, the location SHOULD provide a representation of that entity. (This practices replicates that described in [[ld-bp]] <cite><a href="http://www.w3.org/TR/ld-bp/#uri-design-principles">Provide at least one machine-readable representation of the resource identified by the URI</a></cite>)</p>
218-
<p>Corollaries to this best practice is that Cool URIs don't change [[cooluris]], meaning that URLs describing entities SHOULD be stable and not depend on variable information. Also, the URL used to identify an entity is the best API endpoint of that entity (see also <a href="#api-versioning" class="sectionRef"></a>).</p>
219-
</section>
220-
221-
<section>
222-
<h3 id="type-links">External references should use typed term</h3>
223-
<p class="practicedesc">When using a property intended to reference another entity, properties SHOULD be defined to type string values as being references.</p>
224-
<p>For example, the <code>schema:image</code> property a Thing to an Image:</p>
225-
<pre class="example" title="Example typed relationship">
226-
{
227-
"@context": "http://schema.org",
228-
"id": "http://www.wikidata.org/entity/Q76",
229-
"type": "Person",
230-
"name": "Barack Obama",
231-
"givenName": "Barack",
232-
"familyName": "Obama",
233-
"jobTitle": "44th President of the United States",
234-
<strong>"image": "https://commons.wikimedia.org/wiki/File:President_Barack_Obama.jpg"</strong>
235-
}
236-
</pre>
237-
<p>This will be interpreted as a reference, rather than a string literal, because (at the time of publication), the schema.org JSON-LD Context defines <code>image</code> to be of type <code>@id</code>:</p>
238-
<pre class="example" title="schema.org context snippet for image">
239-
{
240-
"@context": {
241-
...
242-
"image": { "@id": "schema:image", <strong>"@type": "@id"</strong>},
243-
...
244-
}
245-
}
246-
</pre>
247-
<p>If not defined as such in a remote context, terms may be (re-) defined in a local context:</p>
248-
<pre class="example" title="Example typed relationship">
214+
<h3 id="things-not-strings">Things not strings</h3>
215+
<p class="practicedesc">When describing attributes, entity references SHOULD be used instead of string literals.</p>
216+
<p>In some cases, when describing an attribute of an entity, it is tempting to using string values which have no independent meaning. Such values often are used for well known things. A JSON-LD context can define a term for such values, which allow them to appear as strings within the message, but be associated with specific identifiers. In this case, the property must be defined with type <code>@vocab</code> so that values will be interpreted relative to a vocabulary rather than the file location.</p>
217+
<pre class="example" title="Example enumerated value">
249218
{
250219
"@context": ["http://schema.org", <strong>{
251-
"image": { "@id": "schema:image", "@type": "@id"}
220+
"gender": {"@id": "schema:gender", "@type": "@vocab"}
252221
}</strong>],
253222
"id": "http://www.wikidata.org/entity/Q76",
254223
"type": "Person",
255224
"name": "Barack Obama",
256225
"givenName": "Barack",
257226
"familyName": "Obama",
258227
"jobTitle": "44th President of the United States",
259-
"image": "https://commons.wikimedia.org/wiki/File:President_Barack_Obama.jpg"
228+
<strong>"gender": "Male"</strong>
260229
}
261230
</pre>
231+
<p>See article in SEO Skeptic [[seo-strings-to-things]] for further elaboration on the advantages of using <em>things</em> instead of <em>strings</em>.</p>
262232
</section>
263233

234+
264235
<section>
265236
<h3 id="embed-objects">Nest referenced inline objects</h3>
266237
<p class="practicedesc">When multiple related entity descriptions are provided inline, related entities SHOULD be nested.</p>
@@ -286,37 +257,76 @@ <h3 id="embed-objects">Nest referenced inline objects</h3>
286257
</section>
287258

288259
<section>
289-
<h3 id="things-not-strings">Things not strings</h3>
290-
<p class="practicedesc">When describing attributes, entity references SHOULD be used instead of string literals.</p>
291-
<p>In some cases, when describing an attribute of an entity, it is tempting to using string values which have no independent meaning. Such values often are used for well known things. A JSON-LD context can define a term for such values, which allow them to appear as strings within the message, but be associated with specific identifiers. In this case, the property must be defined with type <code>@vocab</code> so that values will be interpreted relative to a vocabulary rather than the file location.</p>
292-
<pre class="example" title="Example enumerated value">
260+
<h3 id="reverse-references">When describing an inverse relationship, use a referenced property</h3>
261+
<p class="practicedesc"></p>
262+
</section>
263+
</section>
264+
265+
<section>
266+
<h2>Contexts</h2>
267+
268+
<section>
269+
<h3 id="type-links">External references should use typed term</h3>
270+
<p class="practicedesc">When using a property intended to reference another entity, properties SHOULD be defined to type string values as being references.</p>
271+
<p>For example, the <code>schema:image</code> property a Thing to an Image:</p>
272+
<pre class="example" title="Example typed relationship">
273+
{
274+
"@context": "http://schema.org",
275+
"id": "http://www.wikidata.org/entity/Q76",
276+
"type": "Person",
277+
"name": "Barack Obama",
278+
"givenName": "Barack",
279+
"familyName": "Obama",
280+
"jobTitle": "44th President of the United States",
281+
<strong>"image": "https://commons.wikimedia.org/wiki/File:President_Barack_Obama.jpg"</strong>
282+
}
283+
</pre>
284+
<p>This will be interpreted as a reference, rather than a string literal, because (at the time of publication), the schema.org JSON-LD Context defines <code>image</code> to be of type <code>@id</code>:</p>
285+
<pre class="example" title="schema.org context snippet for image">
286+
{
287+
"@context": {
288+
...
289+
"image": { "@id": "schema:image", <strong>"@type": "@id"</strong>},
290+
...
291+
}
292+
}
293+
</pre>
294+
<p>If not defined as such in a remote context, terms may be (re-) defined in a local context:</p>
295+
<pre class="example" title="Example typed relationship">
293296
{
294297
"@context": ["http://schema.org", <strong>{
295-
"gender": {"@id": "schema:gender", "@type": "@vocab"}
298+
"image": { "@id": "schema:image", "@type": "@id"}
296299
}</strong>],
297300
"id": "http://www.wikidata.org/entity/Q76",
298301
"type": "Person",
299302
"name": "Barack Obama",
300303
"givenName": "Barack",
301304
"familyName": "Obama",
302305
"jobTitle": "44th President of the United States",
303-
<strong>"gender": "Male"</strong>
306+
"image": "https://commons.wikimedia.org/wiki/File:President_Barack_Obama.jpg"
304307
}
305308
</pre>
306-
<p>See article in SEO Skeptic [[seo-strings-to-things]] for further elaboration on the advantages of using <em>things</em> instead of <em>strings</em>.</p>
307309
</section>
310+
</section>
311+
312+
313+
<section>
314+
<h2>Publishing</h2>
308315

309316
<section>
310-
<h3 id="reverse-references">When describing an inverse relationship, use a referenced property</h3>
311-
<p class="practicedesc"></p>
317+
<h3 id="dereferencable-entities">Provide a representation of the entity related by URL</h3>
318+
<p class="practicedesc">When dereferencing an entity related via a URL, the location SHOULD provide a representation of that entity. (This practices replicates that described in [[ld-bp]] <cite><a href="http://www.w3.org/TR/ld-bp/#uri-design-principles">Provide at least one machine-readable representation of the resource identified by the URI</a></cite>)</p>
319+
<p>Corollaries to this best practice is that Cool URIs don't change [[cooluris]], meaning that URLs describing entities SHOULD be stable and not depend on variable information. Also, the URL used to identify an entity is the best API endpoint of that entity (see also <a href="#api-versioning" class="sectionRef"></a>).</p>
312320
</section>
321+
</section>
322+
323+
<section>
324+
<h2>Consuming</h2>
313325

314-
<!--
315326
<section>
316-
<h3 id="xxx"></h3>
317-
<p class="practicedesc"></p>
327+
<h3 id="cache-context">Cache JSON-LD Contexts</h3>
328+
<p class="practicedesc">While most use of JSON-LD should not require a client to change the data representation, JSON-LD does allow the use of various algorithms to re-shape a JSON-LD document. These require the use of the <a>JSON-LD Context</a>, which is typically represented using a link to a remote document. Because it is remote, processing time can be severely impacted by the time it takes to retrieve this context. Services providing a <a>JSON-LD Context</a> SHOULD set HTTP cache-control headers to allow liberal caching of such contexts, and clients SHOULD attempt to use a locally cached version of these documents. Typically, libraries used to process JSON-LD documents should do this for you. (See also [[json-ld-best-practice-caching]]).</p>
318329
</section>
319-
-->
320330
</section>
321331

322332
<section>

0 commit comments

Comments
 (0)