Comments (10)
Hi @michielhildebrand
Thanks for the bug report. I'm guessing this is output from the PySHACL command line tool?
Looks like you're using JSON-LD ouput. Does it do the same when the report is output as Turtle (TTL) format?
Another question, does it have the same problem if the sh:value
is a Literal or a URI? Looks like in this example the value in question is a BNode which is not correctly serialized.
I think this is a limitation of the commandline tool output that might need to be expanded.
When using PySHACL as a library as part of a larger python application and called within the code, this problem is not present, the sh:value
property is always populated correctly.
from pyshacl.
The sh:value is also empty in turtle
@prefix crm: <http://www.cidoc-crm.org/cidoc-crm/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix vgw: <https://vangoghworldwide.org/shapes/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
[] a sh:ValidationReport ;
sh:conforms false ;
sh:result [ a sh:ValidationResult ;
sh:focusNode <http://vangoghmuseum.nl/data/artwork/d0005V1962> ;
sh:resultMessage "Dimension does not conform to shape vgw:Dimension" ;
sh:resultPath crm:P43_has_dimension ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:NodeConstraintComponent ;
sh:sourceShape [ a sh:PropertyShape ;
sh:group vgw:DimensionGroup ;
sh:message "Dimension does not conform to shape vgw:Dimension" ;
sh:node vgw:Dimension ;
sh:path crm:P43_has_dimension ;
sh:severity sh:Violation ] ;
sh:value [ ] ] .
I also tried it as a python library. I get the exact same result.
from pyshacl.
I looked into it a bit closer. I hope this helps to figure out where it goes wrong.
pyShacl returns this report:
[] a sh:ValidationReport ;
sh:conforms false ;
sh:result [ a sh:ValidationResult ;
sh:focusNode [ ] ;
sh:resultMessage "Dimension requires a value (crm:P90_has_value)" ;
sh:resultPath crm:P90_has_value ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:MinCountConstraintComponent ;
sh:sourceShape [ a sh:PropertyShape ;
sh:message "Dimension requires a value (crm:P90_has_value)" ;
sh:minCount 1 ;
sh:path crm:P90_has_value ;
sh:severity sh:Violation ] ],
[ a sh:ValidationResult ;
sh:focusNode <http://vangoghmuseum.nl/data/artwork/d0005V1962> ;
sh:resultMessage "Dimension does not conform to shape vgw:Dimension" ;
sh:resultPath crm:P43_has_dimension ;
sh:resultSeverity sh:Violation ;
sh:sourceConstraintComponent sh:NodeConstraintComponent ;
sh:sourceShape [ a sh:PropertyShape ;
sh:group vgw:DimensionGroup ;
sh:message "Dimension does not conform to shape vgw:Dimension" ;
sh:node vgw:Dimension ;
sh:path crm:P43_has_dimension ;
sh:severity sh:Violation ] ;
sh:value [ ] ] .
In here I would expect the sh:value of the last ValidationResult to contain the sh:focusNode of the first ValidationResult. In Topbraid this is the case:
[ a <http://www.w3.org/ns/shacl#ValidationReport> ;
<http://www.w3.org/ns/shacl#conforms>
false ;
<http://www.w3.org/ns/shacl#result>
[ a <http://www.w3.org/ns/shacl#ValidationResult> ;
<http://www.w3.org/ns/shacl#focusNode>
_:b0 ;
<http://www.w3.org/ns/shacl#resultMessage>
"Dimension requires a value (crm:P90_has_value)" ;
<http://www.w3.org/ns/shacl#resultPath>
crm:P90_has_value ;
<http://www.w3.org/ns/shacl#resultSeverity>
<http://www.w3.org/ns/shacl#Violation> ;
<http://www.w3.org/ns/shacl#sourceConstraintComponent>
<http://www.w3.org/ns/shacl#MinCountConstraintComponent> ;
<http://www.w3.org/ns/shacl#sourceShape>
[]
] ;
<http://www.w3.org/ns/shacl#result>
[ a <http://www.w3.org/ns/shacl#ValidationResult> ;
<http://www.w3.org/ns/shacl#focusNode>
<http://vangoghmuseum.nl/data/artwork/d0005V1962> ;
<http://www.w3.org/ns/shacl#resultMessage>
"Dimension does not conform to shape vgw:Dimension" ;
<http://www.w3.org/ns/shacl#resultPath>
crm:P43_has_dimension ;
<http://www.w3.org/ns/shacl#resultSeverity>
<http://www.w3.org/ns/shacl#Violation> ;
<http://www.w3.org/ns/shacl#sourceConstraintComponent>
<http://www.w3.org/ns/shacl#NodeConstraintComponent> ;
<http://www.w3.org/ns/shacl#sourceShape>
[] ;
<http://www.w3.org/ns/shacl#value>
_:b0
]
] .
from pyshacl.
Thanks @michielhildebrand I think I've determined why this is not working properly for you, I've just got to isolate the exact set of conditions to replicate it.
Edit: yep, I see that it affects sh:focusNode too. the Validation Report graph is a bit weird because it contains nodes from both the SHACL Shape Graph, and the DataGraph, smooshed into one representation. What is important here is that FocusNode and ValueNode are the only two entries in each ValidationResult which originate from the DataGraph.
Since v0.11.0 pyshacl uses rdflib.Dataset rather than rdflib.Graph for its internal rdf store, which means when I'm pulling nodes from the Data graph to put in the validation report, it doesn't know which namedgraph to use when querying them, so just comes back blank.
I don't know why this hasn't been caught by the tests, there are tests in place to ensure this kind of regression doesn't happen.
from pyshacl.
@michielhildebrand
I've pushed a new version of PySHACL to PyPI, v0.12.1, I've included a potential fix for this issue, can you please test to see if your problem is resolved in this new version?
from pyshacl.
Fixed by #cf6df94
from pyshacl.
Cool! I see something in the valueNode now. Thanks a lot.
BTW. Sorry for the delay. I was offline for a few weeks.
from pyshacl.
Hi Ashley, I noticed an issue with the fix. In case the value is a blank node you seem to generate a new id for it. Therefore the same blank node occurring in a value and in a focusNode can not be compared on id.
from pyshacl.
Hi @michielhildebrand
Thanks for mentioning that.
I don't generate the IDs for Blank nodes, that is done by the RDFLib. Blank node IDs are only relevant to the graph they are currently in. In order for the value node to be displayed in the Report Graph, it needs to be copied over from the Data Graph. When a blank node is copied from one graph to another graph, it will no longer have the same ID. The ID it had in the Data Graph no longer exists in the Report Graph.
I think I might be able to fix the second part you mentioned about the valueNode and focusNode not having the same ID in the Report Graph. In the current implementation they are both copied over separately (thus they are two new blank nodes), but I could put a simple check if they are the same node, only copy it into the report graph once, then use that for both valueNode and focusNode, then they will have the same ID. I'll create a new issue for it.
from pyshacl.
New issue #57
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.