Comments (8)
Hi @xyzisinus,
Thanks for your detailed write-up of this report.
I haven't yet had a chance to look deeply into what is causing the problem you are seeing, but my immediate concern is it might be related to some changes introduced in the most-recent v0.11.3 release of pyshacl.
Have you tried any other versions other than the latest release, to try to reproduce your problem?
Please try v0.11.1 to see if the problem is present, and if so, please try v0.10.0 and see if it is still present there.
I will look more deeply into exactly what is causing this problem later this weekend.
from pyshacl.
Update, reading it again, I think I see a problem in your shape definition. You are using both sh:targetObjectOf
and sh:property
together in the same shape, to try to enforce the same rule in two different ways. That is saying "everything that is an object of this property, should also have this property at this property path" which is incorrect for what you are trying to achieve.
You can do this rule with sh:targetObjectOf
or sh:property
but not both.
Try this:
schema:AddressShape
a sh:NodeShape ;
sh:targetObjectsOf schema:hasAddress ;
sh:class schema:PostalAddress .
from pyshacl.
Update 2:
I was just thinking, you might be confusing targetObjectsOf
and targetSubjectsOf
For example, changing your Shape to this, will work:
schema:AddressShape
a sh:NodeShape ;
sh:targetSubjectsOf schema:hasAddress ;
sh:property [
sh:path schema:hasAddress ;
sh:class schema:PostalAddress ;
] .
That will do what you want, is it saying "get all targets that are subjects which have this hasAddress
" and "on those targets, follow this property path to check its class".
However using targetObjectsOf
like this:
schema:AddressShape
a sh:NodeShape ;
sh:targetObjectsOf schema:hasAddress ;
sh:class schema:PostalAddress .
this is easier, and shorter and identical to the above. It says "find all targets which are the object of hasAddress
, and check its class."
from pyshacl.
@ashleysommer Thank you very much for your quick response! I tried both suggestions in your update 2. The result of the first suggestion:
Constraint Violation in ClassConstraintComponent (http://www.w3.org/ns/shacl#ClassConstraintComponent):
Severity: sh:Violation
Source Shape: [ sh:class schema:PostalAddress ; sh:path schema:hasAddress ]
Focus Node: ex:Bob
Value Node: ex:Alice
Result Path: schema:hasAddress
The result of the second suggestion (2 errors reported):
Constraint Violation in ClassConstraintComponent (http://www.w3.org/ns/shacl#ClassConstraintComponent):
Severity: sh:Violation
Source Shape: schema:AddressShape
Focus Node: ex:Alice
Value Node: ex:Alice
Constraint Violation in NodeConstraintComponent (http://www.w3.org/ns/shacl#NodeConstraintComponent):
Severity: sh:Violation
Source Shape: [ sh:node schema:AddressShape ; sh:path schema:address ]
Focus Node: ex:Bob
Value Node: ex:BobsAddress
Result Path: schema:address
Out of these two alternatives, the first one makes more sense to me because "hasAddress" path is used in reasoning.
from pyshacl.
And I'm still bit confused looking at the code in https://github.com/RDFLib/pySHACL/blob/master/pyshacl/shapes_graph.py starting from line 187, especially line 189 where targetObjectsOf is concerned. In this chunk of code (till the end of the file) I don't see how targetObjectsOf gets to participate in finding the focus nodes which are objects of some shape. I haven't looked/poked the code carefully yet. My observation is just from a quick scan of the code. Thanks!
from pyshacl.
Hi, the chunk of code in that file you're looking at is the "shapes detection routine" its job is to find all possible permutations of SHACL shapes in a shapes file, in order to later iterate over them. The code which builds focus nodes for a given shape is in a different file in the project.
See how sh:targetObjectsOf
is used here:
Line 151 in 005f001
Then look on line 175, 210, and 239. I know the code is hard to follow, but I hope that helps you to understand how sh:targetObjectsOf
is done in PyShacl.
from pyshacl.
@ashleysommer Thank you for the pointer! I'll look at the code when I get a chance :)
from pyshacl.
@ashleysommer I'm closing the issue now. Thank you for your support and insight!
from pyshacl.
Related Issues (20)
- [Discussion] Pinned vs loose requirements, application vs library use cases HOT 5
- 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
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.