w3c / json-ld-syntax

JSON-LD 1.1 Specification
https://w3c.github.io/json-ld-syntax/
Other
111 stars 22 forks source link

creating new vocabulary terms section 4.1.3 and 4.1.4 #383

Open bertvannuffelen opened 2 years ago

bertvannuffelen commented 2 years ago

When reading the above sections it is really non-obvious that "@vocab": "#" is mandatory to support the creation of URI's with fragments.

If in the example in section 4.1.3 a value is given to "@id" then the document.jsonld disappears, while if "@vocab" statement is not included in the example in section 4.1.4, the uri http://example/Restaurant is created.

Can this be made explicit in the specification?

kr,

Bert

gkellogg commented 2 years ago

New in JSON-LD 1.1 was the ability to have document-relative vocabulary terms, by allowing @vocab to take a relative IRI, which is resolved against the base IRI via concatentation

Example 27 in 4.1.3 Base IRI uses an empty value for @id, which uses the document location as the base IRI for which "" is resolved. Base IRI resolution and vocabulary resolution use different algorithms. Terms which are document relative resolve against the document base using the algorithm described in RFC3986. Terms which are vocabulary relative resolve via concatenation, which is required to achieve the desired semantics. This has been the case since JSON-LD 1.0. It is really beyond the scope of this spec to describe RFC3986 URI/IRI resolution in detail, as that's a behavior this spec relies upon, rather than defines.

IRIs with fragment identifiers are most often associated with vocabulary terms, which is why there is special handling of @vocab. If you can suggest some simple editorial change to 4.1.4 which will resolve the confusion we could mark it as an erratum and consider it for some potential updated spec. We've held off on most changes to the editor's draft, as the rules for updating a spec are convoluted, and maybe evolving.