w3c / json-ld-syntax

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

keyword aliases for @id and @type cannot be singly @protected? #246

Closed azaroth42 closed 4 years ago

azaroth42 commented 5 years ago

In section 4.1.5 (and equivalent in the algorithm) it says that aliases applied to keywords are ignored, other than (per 4.3.3) the use of @container:@set applied to @type.

However, the @protected keyword can be applied to keyword aliases by setting it in the context overall. This is at odds with the text, and prevents protecting ONLY the (very common, and important) aliases for @id and @type.

Propose (I know, 11th hour) that @protected be allowed as an entry for keyword aliases (unless we already discussed this and decided against it, and I'm just forgetting). We can already protect them, just by the syntactic sugar form of setting it at the context level.

azaroth42 commented 5 years ago

Works as expected:

{
  "@context": [{
    "@version": 1.1,
    "@protected": true,
    "id": "@id",
    "type": {"@id" : "@type", "@container": "@set"},
    "@type": {"@container": "@set"}
  },
  ... context here that tries to modify id, type or @type and cannot ...
  ],
  "id": "http://example.com/1",
  "type": ["http://example.org/ns/Foo"]
}

Does not work, as @protected is ignored for aliases of keywords:

{
  "@context": [{
    "@version": 1.1,
    "id": {"@id": "@id", "@protected": true},
    "type": {"@id" : "@type", "@container": "@set", "@protected" : true},
    "@type": {"@container": "@set", "@protected": true}
  },
    ... context here that tries to modify id, type or @type ... and succeeds! ...
  ],
  "id": "http://example.com/1",
  "type": ["http://example.org/ns/Foo"]
}
azaroth42 commented 5 years ago

Also, the syntax is inconsistent with the API definition.

Syntax says that the definitions will be ignored, whereas API says "Any other value means that a keyword redefinition error has been detected and processing is aborted."

The API is the correct intention, and the syntax document should be updated to this effect.

azaroth42 commented 5 years ago

Changing to editorial as the algorithm is in -api, not -syntax

azaroth42 commented 5 years ago

@gkellogg to look through other normative sections to ensure consistency

azaroth42 commented 5 years ago

Resolution: Allow the use of @protected as a valid keyword in term definitions which are aliases of keywords or where the term is @type.

iherman commented 4 years ago

This issue was discussed in a meeting.

gkellogg commented 4 years ago

I added the syntax change in cfd32c665fd728ed5198bdf9c3ad606723074a27, but intended to do a PR. Can't easily undo that, so please check it out and see if the change is reasonable.

gkellogg commented 4 years ago

WG resolved to close the issue as complete.