w3c / w3c/json-ld-syntax

Clarification needed for expansion of terms with `@container` set to `@id` and a local context with a `@base`

Open
#412 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

ErratumRaised spec:substantive
Dominant language
HTML
Stars
139
Forks
23
PR merge metrics
No merged PRs in 30d

Description

When expanding this compact data:

{
  "@context": {
    "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns/",
    "@vocab": "https://example.org/ns#",
    "typeDescribed": {
      "@id": "rdf:type",
      "@context": {"@base": "https://example.org/ns/"},
      "@container": "@id"
    }
  },
  "@id": "/item/1",
  "typeDescribed": {
    "Item": {"label": "Item"}
  }
}

I cannot tell from the spec (step 13.8.3.7.4 of the expansion algorithm) whether the key Item will be resolved against the local context or not. Actually, reading the spec I see nothing that sets the active context to the local context of the typeDescribed before reaching 13.8.3.7.4, although I would expect that this is the intention. Both the JSON-LD Playground and the Ruby RDF Distiller do expand the above to this:

[
  {
    "@id": "/test/item/1",
    "http://www.w3.org/1999/02/22-rdf-syntax-ns#type": [
      {
        "https://example.org/ns/label": [
          {"@value": "Item"}
        ],
        "@id": "https://example.org/ns/Item"
      }
    ]
  }
]

In the Ruby code corresponding to step 13.8.2 and onwards, IIRC, a container_context is defined and from thereon used.

Unless I've missed something in the algorithm that clarifies that something like this is required, I believe we should clarify this exhaustively in the spec, and add this test case (unless I've overlooked an existing one for this).

I've made a similar adjustment to TRLD to reflect this presumably desired behaviour.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read step 13.8.3.7.4 of the JSON-LD expansion algorithm and compare it with lib/json/ld/expand.rb around line 615. Check the linked Ruby RDF Distiller and TRLD behavior, then clarify the specification and add a regression test for the @container: @id case with a local @base context.

Written by the indexing model from the issue text.

Assessment

Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.