Giter Site home page Giter Site logo

Comments (8)

ashleysommer avatar ashleysommer commented on June 12, 2024

Hi @mdw00d
I've run some tests and have determined the source of the problem you are seeing.

It looks like you are using the "Implicit Class Target" mechanism to find the target nodes to apply the shape to, as described in section 2.1.3.3 SHACL spec here: https://www.w3.org/TR/shacl/#implicit-targetClass.

Your shape does not have a sh:targetNode or sh:targetClass, instead relying on the RDFS:Class of the Shape to be the targetClass to apply the constraints to. As per this definition:

Informally, if a shape is also declared to be a class in the shapes graph then all SHACL instances of this class are a target for the shape.

If s is a SHACL instance of sh:NodeShape or sh:PropertyShape in an RDF graph G and s is also a SHACL instance of rdfs:Class in G

Unfortunately this doesn't apply to your shape because you have ex:Func defined as type of owl:Class, but not rdfs:Class.

Of course, owl:Class is a subclass of rdfs:Class, but that is never inferred in the shapes graph because in pyshacl, as per SHACL best-practice, no inferencing (entailment) rules are ever allowed to run against the shapes graph.

So to solve your problem, simply change the definition of ex:Func to:

 ex:Func  a owl:Class , rdfs:Class , sh:NodeShape ;

Or, you could make it an explicit shape, by setting the sh:targetClass, like this:

 ex:Func  a owl:Class , sh:NodeShape ;
        rdfs:label       "Func" ;
        rdfs:subClassOf   ex:Function ;
        sh:targetClass ex:Func ;
        sh:property  [ a sh:PropertyShape ;
 ...

This method doesn't rely on the Implicit Class Target mechanism, and won't run into problems like you're seeing now.

from pyshacl.

ashleysommer avatar ashleysommer commented on June 12, 2024

I'm guessing the SHACL playground JS tool has a slightly relaxed interpretation of the wording in section 2.1.3.3, so perhaps checks for not only rdfs:Class but also owl:Class, when finding implicit class shapes in the shapes file.

It certainly wouldn't be too much of a stretch to also add that change to pySHACL too.

from pyshacl.

mdw00d avatar mdw00d commented on June 12, 2024

Okay, thanks. I am using a third-party tool to generate the SHACL, and unfortunately it does not add the rdfs:Class assertions, so I guess I will need to massage its output.

Again, thanks for taking a look at this.

from pyshacl.

ashleysommer avatar ashleysommer commented on June 12, 2024

@mdw00d Can you let me know the name of the third-party tool you're using to generate the SHACL?
If it is a popular tool, and it generates slightly incompatible Shapes, then I should probably fix pySHACL so that it works with its outputs (or communicate with the upstream developers to get it fixed on their end).

from pyshacl.

mdw00d avatar mdw00d commented on June 12, 2024

I used TopQuadrant's EDG product.

Thanks again for your assistance.

from pyshacl.

ashleysommer avatar ashleysommer commented on June 12, 2024

@mdw00d
After communicating with the developers at TopQuadrant, we've decided on a fix for this in pySHACL.
Your generated SHACL Shapesfile will now work correctly as of pySHACL v0.11.1 (just released).

from pyshacl.

ashleysommer avatar ashleysommer commented on June 12, 2024

Fixed via 5b8ffec

from pyshacl.

mdw00d avatar mdw00d commented on June 12, 2024

Thanks!

from pyshacl.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.