Comments (6)
Hi @RanjithSoman
When I first read this, I assumed you were seeing the same issue as reported here:
#6
But looking at it again, I think this is something different.
The interesting thing is that if you put your Shapes file and Data file as separate snippets into the SHACL playground, which uses a completely separate and independent shacl implementation, you get the same results: http://shacl.org/playground/
But this might be just because SHACL-JS (used in shacl playground) does not do any inferencing on the datagraph at all.
So this is probably a bug in pySHACL.
The SHACL test suite (which pySHACL is tested against and passes) uses test cases that are in 99% of cases a combined SHACL file and Data file. So cases where the SHACL shapes file and target data file are separate are not thoroughly tested. You might have found a case where a SPARQL-constraint in the Shacl Shapes file is not being applied correctly to the data graph in the target file.
I will need to hook this up to the debugger and step through the validation process to find out what is going on here.
from pyshacl.
SHACL playground doesn't support SHACL SPARQL at the moment.
I believe there is a bug in the pySHACL. However, I am new to SHACL and I not fully confident about how my shape data is structured too.
from pyshacl.
@RanjithSoman
I've found the problem.
See in the combined file, your NodeShape has ID: Testsparql:Process
.
There are no target classes defined on the NodeShape, and the shape is subclass of rdfs:Class
, so the Nodeshape Testsparql:Process
becomes an "Implicit Target Class", therefore this shacl shape applies validation to all classes in the datagraph that are instances of type Testsparql:Process
. Which is (I think) your intention. And you see a correct result.
However looking at the split files example, in your SHACL Shape graph file you have renamed the NodeShape to have ID Testsparql:Processshape
. Again, there are no target classes defined, and the shape is still subclass of rdfs:Class
. So again, this NodeShape becomes an "Implicit Target Class", and will apply validation to all classes in the datagraph that are instances of type Testsparql:Processshape
. But the Process instances in the datagraph file are of type Testsparql:Process
, so none of them get the rule applied to them.
In short: Changing the ID of Testsparql:Processshape
in the SHACL Shape file to Testsparql:Process
fixes your problem.
from pyshacl.
@RanjithSoman
UNRELATED to this issue:
I noticed your split file example, you have an ontology declaration in the datagraph file. That ontology declaration includes a sh:declares
predicate which points to the PrefixDeclaration in the SHACL Shapes file.
I think this whole ontology declaration should go into the SHACL Shapes file, rather in the datafile.
- Because a target datagraph is not usually itself an ontology (but sometimes can be)
- The ID of the subject of the ontology declaration is
<http://semanticprocess.x10host.com/Ontology/Testsparql>
, I think that is the name of the SHACL file, not the datagraph file. Declaring it in the datafile means the SHACL shapes graph does not know about that declaration. - The sh:declares predicate points to
Testsparql:PrefixDeclaration
which is a node in the SHACL shapes graph. The datagraph does not join with the shacl shapes graph, so this triple does nothing. - In the shacl shapes graph, the
Testsparql:Processshape
has ash:shacl
rule that includessh:prefix
of the ID of the ontology declaration. But thesh:prefix
predicate can only find prefix IDs of nodes that are declared in the SHACL Shapes file. So it won't see it.
In short: Maybe you just made a copy/paste mistake when splitting the files, but the ontology declaration you have put in the datagraph file should be in the shacl shapes file.
But in this case that does not change the outcome of the validation. For some reason a working sh:declares and sh:prefix combo is not required in order for this sh:shacl rule to complete correctly. Might have something to do with the implicit prefix binding that pyshacl does when loading RDF graphs.
from pyshacl.
@RanjithSoman Please close this issue if your problem is solved.
from pyshacl.
@ashleysommer Thank you for the clarification. Much appreciated.
from pyshacl.
Related Issues (20)
- SPARQL ASK rule incorrectly passing HOT 7
- Can the prettytable dependency be upgraded to major version 3? HOT 1
- Generating SHACL-SPARQL shapes in RDFLib HOT 2
- Shacl does not seem to work on rdflib.Dataset() HOT 1
- Unable to see the validation result in pyshacl HOT 2
- How to ensure subject is not a sh:BlankNode when validating a owl:Class in an ontology? HOT 4
- owl:imports for data graph is hardcoded to false HOT 2
- pySHACL uses deprecated API `pkg_resources` HOT 4
- Trouble with qualified value shape HOT 6
- Failed to catch violations with properties that are not defined HOT 8
- Is a shape (whether node or property) restricted to one instance of sh:not? HOT 5
- Multiple sh:nots causing strange validation results HOT 2
- Multiple sh:xones on one sh:NodeShape grouping member shapes causing unexpected validation results
- `sh:entailment` and `pyshacl --advanced` HOT 1
- `sh:severity` on shapes linked by `sh:node` HOT 2
- `_evaluation_path` length is not configurable HOT 3
- [Discussion] Higher performance "remote" validation
- Difference between PySHACL and TopBraid SHACL API HOT 1
- Message: Node ex:**** does not contain a value in the set: ['Literal("true" = True, datatype=xsd:boolean)'] HOT 7
- pySHACL 0.26.0 is not yet on PyPI HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyshacl.