we're trying to validate some data but right now the SHACL validation is on the anonymous object of a triple so focus node comes back empty. What we want is to get the subject of that triple as focus node.
I created a small example to illustrate my problem.
My shapes.ttl
file:
@prefix ex: <http://example.com#> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
ex:DiameterShape
rdf:type sh:NodeShape ;
sh:property [
sh:path ex:hasValue ;
sh:datatype xsd:integer ;
sh:message "Diameter should be an integer"@en ;
] ;
sh:property [
sh:path ex:hasValue ;
sh:maxInclusive 4000 ;
sh:minInclusive 300 ;
sh:message "Diameter should be between 300 and 4000"@en ;
sh:severity sh:Warning ;
] ;
sh:targetClass ex:Diameter ;
.
ex:ThingShape
rdf:type sh:NodeShape ;
sh:property [
sh:path ex:hasAspect ;
sh:class ex:Diameter ;
] ;
sh:targetClass ex:Thing ;
.
My data.ttl
file:
@prefix ex: <http://example.com#> .
ex:Thing_123
a ex:Thing ;
ex:hasAspect [
a ex:Diameter ;
ex:hasValue 200 ;
] .
Which contains invalid data. Running the shaclvalidator tool...
shaclvalidate.bat -datafile data.ttl -shapesfile shapes.ttl
...returns the error but notice the focus node is empty... meaning in a large enough data set it's impossible to find where the error comes from. Ideally we want to see ex:Thing_123
as focus node.
We only have control over the shapes file so getting rid of anonymous nodes is not an option.
[ rdf:type sh:ValidationReport ;
sh:conforms false ;
sh:result [ rdf:type sh:ValidationResult ;
sh:focusNode [] ;
sh:resultMessage "Diameter should be between 300 and 4000"@en ;
sh:resultPath ex:hasValue ;
sh:resultSeverity sh:Warning ;
sh:sourceConstraintComponent sh:MinInclusiveConstraintComponent ;
sh:sourceShape [] ;
sh:value 200
]
] .
Thanks in advance!