Skip to content

Commit 23ba42e

Browse files
committed
Core: clarify a lot of language
... now that I'm more awake
1 parent 1c003d4 commit 23ba42e

File tree

1 file changed

+20
-38
lines changed

1 file changed

+20
-38
lines changed

jsonschema-core.xml

+20-38
Original file line numberDiff line numberDiff line change
@@ -336,17 +336,18 @@
336336
</t>
337337
<t>
338338
The value for this keyword MUST be a string, and MUST represent a valid <xref target="RFC3986">URI-reference</xref>.
339-
This URI SHOULD be normalized, and SHOULD NOT be an empty fragment &lt;#&gt; or an empty string &gt;&lt;.
339+
This value SHOULD be normalized, and SHOULD NOT be an empty fragment &lt;#&gt; or an empty string &lt;&gt;.
340340
</t>
341341
<t>
342-
The root schema of a JSON Schema document SHOULD specify an absolute-URI "id" (containing a scheme, but no fragment).
342+
The root schema of a JSON Schema document SHOULD have an "id" with a valid absolute-URI (containing a scheme, but no fragment).
343343
</t>
344344
<t>
345-
To identify a particular subschema in a document without needing a JSON Pointer,
346-
subschemas can give themselves ids that can be identified by a fragment-part.
347-
These "id" keywords with a fragment MUST begin with a letter ([A-Za-z]), to be followed by any number of
348-
letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
349-
<!-- This restriction is the one defined by XML -->
345+
To facilitate the identification of subschemas in a JSON Schema document,
346+
subschemas can use "id" to give themselves a URI with a custom fragment-part.
347+
This form of "id" keyword MUST begin with a hash ("#") to identify it as a fragment URI reference,
348+
followed by a letter ([A-Za-z]), followed by any number of
349+
letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), or periods (".").
350+
<!-- This restriction is the same one defined by XML -->
350351
</t>
351352
<t>
352353
For example:
@@ -406,62 +407,43 @@
406407
<artwork>
407408
<![CDATA[
408409
{
409-
"id": "http://example.net/myschema#",
410+
"id": "http://example.net/root.json#",
410411
"definitions": {
411-
"schema1": {
412+
"single": {
412413
"id": "schema1",
413414
"type": "integer"
414415
},
415-
"schema2", {
416-
"type": "array",
417-
"items": { "$ref": "schema1" }
418-
}
416+
},
417+
"items": {
418+
"type": "array",
419+
"items": { "$ref": "schema1" }
419420
}
420421
}
421422
]]>
422423
</artwork>
423424
</figure>
424425
<t>
425-
When an implementation encounters the &lt;schema1&gt; schema, it resolves the "id" URI reference
426-
against the current base URI, resolving to &lt;http://example.net/schema1&gt;.
426+
When an implementation encounters the &lt;#/definitions/single&gt; schema, it resolves the "id" URI reference
427+
against the current base URI to &lt;http://example.net/schema1&gt;.
427428
</t>
428429
<t>
429-
When an implementation then looks inside the &lt;schema2&gt; schema, it encounters the &lt;schema1&gt; reference,
430-
and resolves this the URI &lt;http://example.net/schema1&gt; which is understood as the schema defined elsewhere in the same document.
430+
When an implementation then looks inside the &lt;#/items&gt; schema, it encounters the &lt;schema1&gt; reference,
431+
and resolves this to &lt;http://example.net/schema1&gt; which is understood as the schema defined elsewhere in the same document.
431432
</t>
432-
<figure>
433-
<preamble>
434-
An example with fragment "id" keywords:
435-
</preamble>
436-
<artwork>
437-
<![CDATA[
438-
{
439-
"id": "http://some.site/schema#",
440-
"not": { "$ref": "#inner" },
441-
"definitions": {
442-
"schema1": {
443-
"id": "#inner",
444-
"type": "boolean"
445-
}
446-
}
447-
}
448-
]]>
449-
</artwork>
450-
</figure>
451433
</section>
452434
<section title="External references">
453435
<t>
454436
To differentiate schemas between each other in a vast ecosystem, schemas are identified by URI.
455437
As specified above, this does not necessarially mean anything is downloaded, but instead JSON Schema
456-
implementations SHOULD provide ways to import a schema so that other schemas can reference it.
438+
implementations SHOULD provide ways to import a schema by URI so that other schemas can successfully reference it.
457439
</t>
458440
<t>
459441
Implementations SHOULD be able to associate arbritrary URIs with an arbritrary schema and/or
460442
automatically associate a schema's "id"-given URI, depending on the trust that the the validator
461443
has in the schema.
462444
</t>
463445
<t>
464-
A schema may have multiple URIs, but a URI must identify not more than one schema.
446+
A schema MAY (and likely will) have multiple URIs, but a URI has no way to identify more than one schema.
465447
Validators that try to have multiple schemas associated to the same URI SHOULD raise an error condition.
466448
</t>
467449
</section>

0 commit comments

Comments
 (0)