jargon-sh / issues

The jargon.sh issue tracker
1 stars 0 forks source link

prop, class and codelist names should be unique #3

Closed VladimirAlexiev closed 7 months ago

VladimirAlexiev commented 8 months ago

Look at https://jargon.sh/user/unece/DigitalProductPassport/v/working/artefacts/diagram/render.svg?light=true. Here is a problem: image

This leads to the following conflict in the generated ontology (JSONLD) https://jargon.sh/user/unece/DigitalProductPassport/v/working/artefacts/jsonld/render.jsonld:

@id: "DigitalProductPassport:assuranceLevel",
@type: ["rdf:Property","owl:ObjectProperty"],
rdfs:label: "assuranceLevel",
schema:rangeIncludes: {@id: "DigitalProductPassport:assuranceLevel"},

You can already see the conflict: a property refers to itself as "range" (i.e. a class).

This is also seen explicitly at the beginning:

rdfs:label: "assuranceLevel",
@type: "rdfs:Class",
@id: "DigitalProductPassport:assuranceLevel",

This domain is by @onthebreeze, but I think Jargon should enforce that each prop, class and codelist name is unique within the domain (and across these 3 categories).

Most ontologies enforce a naming convention that classes (and codelist classes) use UpperCase whereas props use lowerCase. So it's just fine for the prop to be DigitalProductPassport:assuranceLevel and the class to be DigitalProductPassport:AssuranceLevel.

jargon-sh commented 8 months ago

Thanks @VladimirAlexiev for creating such a well constructed issue.

Jargon does support the type of naming conventions you mention, but only for Classes and Properties.

I'll get a backlog item added that includes similar rules for codelists. This will notify domain authors of this type of collision in the future.

I've also worked with @onthebreeze to add a workaround for this specific domain in the meantime.

I'll close this issue when the feature is implemented.

jargon-sh commented 7 months ago

When a Jargon Domain is configured to generate JSON-LD, it will detect and raise an error for code lists colliding with names of things in the model:

Screen Shot 2024-04-01 at 3 36 17 pm

Jargon will also now warn you when you are about to save a Domain with errors:

Screen Shot 2024-04-01 at 3 41 56 pm

Whilst this won't prevent the situation from happening again, Domain authors will be aware of it.

I'll investigate and consider if a Domain with errors should still generate JSON-LD - or only allow that if the Domain is error free.

VladimirAlexiev commented 7 months ago

This is now also resolved in https://jargon.sh/user/unece/DigitalProductPassport/v/working/artefacts/jsonld/render.jsonld, thanks @onthebreeze:

{
  rdfs:label: "assuranceLevelCode",
  @type: "rdfs:Class",
  @id: "DigitalProductPassport:assuranceLevelCode",
  rdfs:comment: "Code that describes the assurance level of the conformity assessment"
},
{
  @id: "DigitalProductPassport:assuranceLevel",
  @type: [
    "rdf:Property",
    "owl:ObjectProperty"
  ],
  rdfs:label: "assuranceLevel",
  schema:rangeIncludes: {
    @id: "DigitalProductPassport:assuranceLevelCode"
  },
  schema:domainIncludes: {
    @id: "DigitalProductPassport:Evidence"
  },
  rdfs:comment: "The assurance level of the evidence (self declaration, 2nd party, 3rd party, accredited auditor)"
},