RDFLib / pySHACL

A Python validator for SHACL
Apache License 2.0
241 stars 63 forks source link

Message: Node ex:**** does not contain a value in the set: ['Literal("true" = True, datatype=xsd:boolean)'] #231

Closed alpertungakin closed 1 month ago

alpertungakin commented 1 month ago

Hello, I am trying to validate an RDF file against a SHACL graph. I could not post the files here because they are huge-in-size, but I pasted down sample parts. RDF: ex:GUID_5ACC3D0F-28A1-4E83-A0F1-930748BCB013_9_4 a sf:Polygon, citygml:WallSurfaceType ; geo:asWKT "POLYGON Z ((78864.787 457866.289 10.244, 78866.931 457863.129 10.244, 78865.859 457864.71 12.256, 78864.787 457866.289 10.244))"^^geo:wktLiteral ; citygml:parent ex:GUID_5ACC3D0F-28A1-4E83-A0F1-930748BCB013_9 ; brep:directionNormalX -8.275105e-01 ; brep:directionNormalY -5.614502e-01 ; brep:directionNormalZ 2.790508e-04 ; valid:consecutiveSamePoints false ; valid:hasDuplicatedRings false ; valid:hasHoleOutside false ; valid:hasInnerNestedRings false ; valid:hasInteriorDisconnected false ; valid:hasIntersectedRings false ; valid:isCcwise true ; valid:isClosed false ; valid:isCollapsedtoLine false ; valid:isCoplanar false ; valid:isNormalsDeviated false ; valid:noSelfIntersection true ; valid:tooFewPoints false ; valid:wallSurfaceNormals true .

SHACL: <http://www.opengis.net/ont/sf#Polygon-isNormalsDeviated> a sh:PropertyShape ; sh:hasValue false ; sh:path <http://www.semanticweb.org/alper/ontologies/2024/3/8/untitled-ontology-32#isNormalsDeviated> .

The question: on the RDF size, the relevant node has a value as "valid:isNormalsDeviated false ;", also the SHACL has "sh:hasValue false" constraint, but pyshacl engine could not match them, raises the error below:

Validation Report: Constraint Violation in HasValueConstraintComponent (http://www.w3.org/ns/shacl#HasValueConstraintComponent): Severity: sh:Violation Source Shape: <http://www.opengis.net/ont/sf#Polygon-isNormalsDeviated> Focus Node: ex:GUID_5ACC3D0F-28A1-4E83-A0F1-930748BCB013_9_4 Result Path: <http://www.semanticweb.org/alper/ontologies/2024/3/8/untitled-ontology-32#isNormalsDeviated> Message: Node ex:GUID_5ACC3D0F-28A1-4E83-A0F1-930748BCB013_9_4-><http://www.semanticweb.org/alper/ontologies/2024/3/8/untitled-ontology-32#isNormalsDeviated> does not contain a value in the set: ['Literal("false" = False, datatype=xsd:boolean)']

What is the part I am missing? Thanks for the helps.

ashleysommer commented 1 month ago

Thanks for posting. This is an odd issue, I'll see if I can reproduce it locally to track down where the unexpected result is coming from.

ashleysommer commented 1 month ago

@alpertungakin I've created a reproduction of your provided data, and shape file, and it is working correctly for me, see this complete example:

https://gist.github.com/ashleysommer/4a87ff274d7639c4b0e9dcdba3eb72aa

In order to track down what issue you're seeing, I'll need more complete examples, or a file containing a minimal reproduction of the error you're seeing.

alpertungakin commented 1 month ago

Thanks a lot for your test. I am currently testing and comparing your code with mine now. I am posting down links of my code and data. By the way, the pySHACL version is 0.23.0 and the rdflib version is 6.3.2. in my environment. Can it change something, what are the versions in your environment?

RDF data: https://github.com/alpertungakin/3DCMQuality/blob/main/denhaag_rdf.ttl SHACL: https://github.com/alpertungakin/3DCMQuality/blob/main/shacl4cg_v2.ttl validation code: https://github.com/alpertungakin/3DCMQuality/blob/main/validator.py

alpertungakin commented 1 month ago

Thanks a lot for your test. I am currently testing and comparing your code with mine now. I am posting down links of my code and data. By the way, the pySHACL version is 0.23.0 and the rdflib version is 6.3.2. in my environment. Can it change something, what are the versions in your environment?

RDF data: https://github.com/alpertungakin/3DCMQuality/blob/main/denhaag_rdf.ttl SHACL: https://github.com/alpertungakin/3DCMQuality/blob/main/shacl4cg_v2.ttl validation code: https://github.com/alpertungakin/3DCMQuality/blob/main/validator.py

I have tried it with your code and it returned as Conforms=True. I think the problem is in the rest of the RDF document.

ashleysommer commented 1 month ago

I'm using PySHACL v0.26.0 and RDFLib v7.0.0, though it shouldn't matter for this issue, it is very straightforward behaviour and should work fine on all versions.

In the future when you file an issue report, please only use the latest PySHACL version.

ashleysommer commented 1 month ago

I think the issue is that in the RDF Data file the prefix for valid: namespace is a url something like https://raw.github.../blob/master/untitled-ontology-32#, but in the SHACL file your sh:path properties use <http://www.semanticweb.org/alper/ontologies/2024/3/8/untitled-ontology-32#> so the SHACL path will never match that in the RDF data.

alpertungakin commented 1 month ago

Thanks a lot for the guidance. I have changed the "valid: path" in the RDF with valid: <http://www.semanticweb.org/alper/ontologies/2024/3/8/untitled-ontology-32#> ., which is also in SHACL as the same, and the issue is resolved now. I'm closing the issue.