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

Rules on parent class are not being applied. #142

Closed
gruhnow opened this issue Aug 13, 2024 · 6 comments
Closed

Rules on parent class are not being applied. #142

gruhnow opened this issue Aug 13, 2024 · 6 comments

Comments

@gruhnow
Copy link

gruhnow commented Aug 13, 2024

I created a playground to reproduce the issue here.
Constraints:

@prefix : <http://example.org/ontology#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .


:hasName a owl:DatatypeProperty ;
    rdfs:domain :Animal ;
    rdfs:range xsd:string ;
    rdfs:label "has name" ;
    rdfs:comment "Specifies the name of an animal.";
.

:Animal a rdfs:Class, sh:NodeShape ;
    rdfs:label "Animal" ;
    rdfs:comment "A general class for all animals." ;
	sh:property [
      rdf:type sh:PropertyShape ;
      sh:path :hasName ;
      sh:minCount 1 ;
    ] ;
.


:Dog a rdfs:Class, sh:NodeShape ;
    rdfs:subClassOf :Animal ;
    rdfs:label "Dog" ;
    rdfs:comment "A class for all dogs." ;
.

Shapes:

@prefix : <http://example.org/ontology#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix vcard: <http://www.w3.org/2006/vcard/ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

:Buddy a :Dog ;
#    :hasName "Buddy" ;
    :hasVaccinationStatus true .

Based on @HolgerKnublauch 's comments here I'd expect constraint validation to fail because Buddy does not have a name which is required by the animal class. Am I missing something?

@tpluscode
Copy link
Collaborator

Thank you for reporting. I would have to look at the code to confirm but I think we may not currently implement sub classes.

(You did forget :Mammal rdfs:subClassOf :Animal but it does not change the outcome)

@gruhnow
Copy link
Author

gruhnow commented Aug 13, 2024

@tpluscode Nice catch! I simplified my example for the issue, but broke it in the process. I've updated the link to a fixed example.

@gruhnow
Copy link
Author

gruhnow commented Aug 13, 2024

I'll have to dig more since I'm not familiar with the code base, but it looks like getInstances calls getInstancesOf which is supposed to collect sub classes.

@giacomociti
Copy link
Contributor

the triple :Dog rdfs:subClassOf :Animal . should be in the data graph. See also w3c/data-shapes#155

@tpluscode
Copy link
Collaborator

Thanks @giacomociti for pointing that out. With this change, the playground example indeed works

I suppose we should close this issue then, lest we intend to deviate from the spec

@gruhnow
Copy link
Author

gruhnow commented Aug 14, 2024

Thank you for the clarification @giacomociti! Closing.

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