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

Validating the domain (or ObjectProperty range) asserted in a data graph exists in the ontology graph? #183

Closed
tduval-unifylogic opened this issue May 2, 2023 · 6 comments

Comments

@tduval-unifylogic
Copy link

tduval-unifylogic commented May 2, 2023

Another question.

I would like to validate that the domain asserted in the data graph actually exists as a class specified in the ontology. I have successfully created validation for DatatypeProperty ranges:

    [ sh:path rdfs:range ; sh:nodetype sh:IRI ;
        sh:targetObjectsOf rdfs:range ;
        sh:in ( xsd:anyType xsd:anyURI xsd:base64Binary ...etc.  ) ;
    ] ,

but now i would like to be able to validate both domain and ranges existence for object properties.

@ajnelson-nist
Copy link
Contributor

Is your application an OWL application? If so, domains and ranges can get significantly complex, e.g. for properties that have a domain that is all X's and all not-Y's would be a union of X with the complement of Y's. That could be hairy to write a catchall SHACL shape for. If this is just an RDFS application instead, nevermind this point.

Either a sh:qualifiedValueShape would do what you need, or this could:

ex:CheckRangeIsUsingDefinedClass-shape
    a sh:NodeShape ;
    sh:nodeKind sh:IRI ;
    sh:or (
        [ a sh:NodeShape ; sh:class rdfs:Class ; ]
        [ a sh:NodeShape ; sh:class owl:Class ; ]
    )
    sh:targetObjectsOf rdfs:domain ;
    .

I haven't tested that snippet, but I think it would work.

And again, this assumes the more simplified case of properties defined in the RDFS style without OWL - OWL would need some further contortion using an sh:xone to represent "Either the shape is a blank node (implying a OWL class expression instead of class (in which case, here come a lot of property paths to confirm declarations)), or it matches [the above shape]."

(Also, careful, there's a typo'd sh:nodetype in your example. You might want to try the SHACL-SHACL conformance testing from the SHACL spec; pyshacl provides this with --metashacl.)

@tduval-unifylogic
Copy link
Author

tduval-unifylogic commented May 2, 2023

sh:class owl:Class

works perfect for my needs!

Thanks again!

@ajnelson-nist
Copy link
Contributor

You're welcome!

By the way, it's sounding like you're getting into "TBox" review with SHACL. You might want to be aware of this Issue.

@tduval-unifylogic
Copy link
Author

ah! thanks fo that!

@ashleysommer
Copy link
Collaborator

@tduval-unifylogic
Is it OK to close this issue thread now?

@tduval-unifylogic
Copy link
Author

tduval-unifylogic commented May 24, 2023 via email

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