Closed hsolbrig closed 4 years ago
It is relative to the document in which it is contained. It should work properly in jsonld.js, but in the embedded context of the playground, this may not be apparent.
Is it document relative only, or can it be changed with '@base'?
There are tests for this, and I believe it does not consider @base
.
5.2 of the Context Processing Algorithm makes this pretty clear:
Initialize context to the result of resolving context against the base IRI of the document containing the local context which is established
It's detailed enough, and I don't think we really need to burden the syntax document with this much detail.
I tried some pretty trivial tests using the npm module to parse a JSON-LD doc which referenced another:
{ "@context": "http://localhost/tmp/npmz/jsonld-user/outer.jsonld",
"outer": { "inner": "http://inner/" } }
which in turn referenced another:
{ "@context": { "@version": 1.1,
"outer": {
"@id": "foo:outer",
"@context": "http://localhost/tmp/npmz/jsonld-user/inner.jsonld"
} } }
(both served as "application/ld+json") This worked as long as the URLs were absolute but not when I changed e.g. that 2nd to have an @context of either "inner.jsonld" or "/tmp/npmz/jsonld-user/inner.jsonld". Should this be covered by the tests?
I thought we had a test for this from 1.0, but I don't see one, so something like this is certainly necessary.
5.2 of the Context Processing Algorithm makes this pretty clear:
Initialize context to the result of resolving context against the base IRI of the document containing the local context which is established
It's detailed enough, and I don't think we really need to burden the syntax document with this much detail.
While there is definitely detail that is irrelevant to JSON-LD end user, I don't see this question falling into that category. Where we are today, the syntax document appears be the document that json-ld users would go to to answer questions about how the language is used and interpreted. Less than ideal, I know, but requiring someone to have consumed all three specifications before being able to use JSON-LD in anger is asking an awful lot.
I thought we had a test for this from 1.0, but I don't see one, so something like this is certainly necessary.
The above pull provides one which is the only test for:
I created an analogous remote test but a PR on that will fail until it gets merged as it relies on https://w3c.github.io/json-ld-api/tests
.
This issue was discussed in a meeting.
The specification says that an
@context
can be anIRI reference
, meaning that it can be an absolute or a relative IRI. Questions: 1) If relative, is it resolved against the document base? 2) Why doesn't this appear to work in the playground? (see: http://tinyurl.com/u6z4ot7 for one attempt)