w3c / w3c/json-ld-api

Compaction cannot round-trip terms using `@container: @list` and `@type: @vocab`

Open
#558 10 comments 0 reactions 1 assignee View on GitHub

@niklasl is already working on this.

Since Feb 12, 2025.

ErratumRaised spec:enhancement spec:substantive substantive:class 3
Dominant language
HTML
Stars
106
Forks
40
PR merge metrics
No merged PRs in 30d

Description

The following compact data expands as expected to a @list of vocabulary term IRIs:

{
  "@context": {
    "owl": "http://www.w3.org/2002/07/owl#",
    "rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
    "rdfs": "http://www.w3.org/2000/01/rdf-schema#",
    "owl:unionOf": {"@container": "@list", "@type": "@vocab"},
    "@base": "http://purl.org/ontology/bibo/"
  },
  "@graph": [
    {
      "@id": "authorList",
      "rdfs:range": {
        "owl:unionOf": ["rdf:List", "rdf:Seq"]
      }
    }
  ]
}

However, when compacting the results using the same context, the JSON-LD 1.1 algorithm fails to produce the same compact form.

Here is the above example and the problematic compaction behaviour in the playground.

There are many use cases where a compact form of the combination of @container: @list and @type: @vocab is useful, such as when expressing an owl:unionOf or a owl:propertyChainAxiom, a FRESNEL lens or various expressions in ShEx and SHACL .

I have implemented a fix for this in TRLD. As this implementation strives to follow the specification algortihm, these changes ought to be fairly easy to apply in the specification too (adjusting some prose, and introducing a new section for the new sub-algorithm).

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.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.