Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix generated SHACL to allow subclasses to satisfy constraints #74

Open
JPEWdev opened this issue Oct 26, 2023 · 5 comments
Open

Fix generated SHACL to allow subclasses to satisfy constraints #74

JPEWdev opened this issue Oct 26, 2023 · 5 comments
Assignees

Comments

@JPEWdev
Copy link
Contributor

JPEWdev commented Oct 26, 2023

The model that is produced by the spec parser is not allowing sub classes to satisfy the requirements of a property.

For example, core:CreationInfo.createdBy should allow core:Agent or any subclass derived from it (e.g. core:Organization), but instead it only allows an exact core:Agent

This is a problem with both the generated TTL and JSON-LD model file.

@zvr
Copy link
Member

zvr commented Oct 26, 2023

Confirming the issue.

With an example test data file:

@prefix core: <https://spdx.org/rdf/v3/Core/> .
@prefix ex: <http://zvr.invalid/rdf/> .

ex:someOrganization a core:Organization .
ex:someCreationInfo a core:CreationInfo .
ex:someCreationInfo core:createdBy ex:someOrganization .

checking the PySHACL validation with pyshacl -s model.ttl example-data.ttl produces:

Constraint Violation in ClassConstraintComponent (http://www.w3.org/ns/shacl#ClassConstraintComponent):
        Severity: sh:Violation
        Source Shape: [ sh:class core:Agent ; sh:minCount Literal("1", datatype=xsd:integer) ; sh:name Literal("createdBy") ; sh:path core:createdBy ]
        Focus Node: ex:someCreationInfo
        Value Node: ex:someOrganization
        Result Path: core:createdBy
        Message: Value does not have class core:Agent

@zvr zvr changed the title Parser is not producing a model that allows sub classes to sastify constraints Fix generated SHACL to allow subclasses to satisfy constraints Oct 26, 2023
@zvr
Copy link
Member

zvr commented Oct 26, 2023

So the problem is not in the rdfs:range declaration, but in the generated SHACL.

@zvr
Copy link
Member

zvr commented Oct 26, 2023

The corresponding SHACL part of the generated model is:

core:CreationInfo a sh:NodeShape ;
    sh:property   [ sh:class core:Agent ;
            sh:minCount 1 ;
            sh:name "createdBy" ;
            sh:path core:createdBy ],
...

@kestewart
Copy link

@zvr - any update on when this is resolved. Getting questions from @JPEWdev on the call as he has too much SPDX to manually validate.

@zvr
Copy link
Member

zvr commented Jan 17, 2024

This refers to the old parser output, no longer relevant.

Nevertheless, I leave this open to remind me to check this on the new generated output, just in case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants