CredentialEngine / Schema-Development

Development of the vocabularies for the CTI models
14 stars 8 forks source link

Error: @list in @context #948

Open philbarker opened 2 months ago

philbarker commented 2 months ago

In the JSON-LD context file, several properties are declared with the @list keyword for their @container, for example:

    "skos:hasTopConcept": {
      "@type": "@id",
      "@container": "@list"
    },

This has unintended consequences. It means that data such as

{
  "@context": "https://credreg.net/ctdl/schema/context/json",
  "@graph":[
    {
        "@id": "http://example.org/",
          "@type": "skos:ConceptScheme",
          "skos:hasTopConcept": [
                "http://example.org/lion",
                "http://example.org/tiger",
                "http://example.org/bear"
        ]
    }
  ]
}

transforms to the RDF statements

<http://example.org/> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://www.w3.org/2004/02/skos/core#ConceptScheme> .
<http://example.org/> <http://www.w3.org/2004/02/skos/core#hasTopConcept> _:b0 .
_:b0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> <http://example.org/lion> .
_:b0 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:b1 .
_:b1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> <http://example.org/tiger> .
_:b1 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> _:b2 .
_:b2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#first> <http://example.org/bear> .
_:b2 <http://www.w3.org/1999/02/22-rdf-syntax-ns#rest> <http://www.w3.org/1999/02/22-rdf-syntax-ns#nil> .

(see this in the JSON-LD playground)

Notice that there is only one top concept, which is a blank node representing an RDF:List not a skosConcept.

I understand that this was intended to maintain the order within concept schemes, but it is the wrong way to do that. If you want to maintain the order of concepts etc. without listIDs you'll have to fall back on JSON lists being ordered; this isn't the way to do it.

The solution is to remove the "@container": "@list" statements from the context file and put something in the handbook saying things should generally be rendered in the order they appear in the JSON (at least in terms of Registry JSON) when no other ordering construct is available.

philbarker commented 1 month ago

To confirm which properties need changing, they are:

in each of