w3c / json-ld-syntax

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

Describe scoped context with @base for id map? #254

Closed azaroth42 closed 4 years ago

azaroth42 commented 5 years ago

Adding @base as a scoped context below an id map makes the structure much more useful:

    "post": {
      "@id": "schema:blogPost",
      "@container": "@id",
      "@context": {
        "@base": "http://content.com/posts/"
      }
    }

As then the URIs become relative to base, and can thus be simple keys / slugs.

azaroth42 commented 4 years ago

Irrelevant as in no longer works? (And if so ... wouldn't that be a normative change?) Or irrelevant as in this could be a best practice, but not needed in the spec?

gkellogg commented 4 years ago

No, it's relevant.

gkellogg commented 4 years ago

It might be considered a bug, but the algorithm doesn't set the local context when processing id-map keys, it is deferred until processing values, thus your example won't work.

We could (probably should) add a step after 13.8.3.1 to set map context if @container includes @id; I'm not sure why we didn't do this.

This will require more tests for this.

In the mean time, I'm just going to update the example to set @base in the top-level context.

azaroth42 commented 4 years ago

Hmm, then I'm doubly glad I found it, as it works in the playground just fine!

azaroth42 commented 4 years ago

(Relabeling so we know to discuss on a call)