I am trying to use sh:severity sh:Warning to add warnings to the SHACL validation report. I noticed unexpected behaviour when a sh:Warning occurs within a node shape used by another node shape. For example if I use :AuthorNodeShape with a :PersonShape that uses sh:Warning, then the :AuthorNodeShape is reported having a sh:Violation (sh:resultMessage “Value does not have shape http://example.com/books/PersonShape“) instead of the sh:Warning.
I would expect a sh:Warning to be shown in the report for the Author.
This makes using sh:Warnings practically useless because all my data graphs fail even when there should only be warnings. Is there a way around this ?
You can reproduce this on https://shacl.org/playground/
Shape graph
@prefix : <http://example.com/books/> . @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#> . :AuthorNodeShape a sh:NodeShape ; sh:targetClass :Author ; sh:node :PersonShape . :PersonShape a sh:NodeShape ; sh:description "Super shape for all things that are Persons"@en ; sh:targetClass :Person ; sh:property [ sh:path :name ; sh:severity sh:Warning ; sh:minCount 1 ; ] .
Data Graph (with missing author name should result in sh:Warnings).
@prefix : <http://example.com/books/> . @prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . @prefix xsd: <http://www.w3.org/2001/XMLSchema#> . :Author rdfs:subClassOf :Person . :JRRTolkien a :Author ; :born "1892-01-03"^^xsd:date .
Report
[ a sh:ValidationResult ; sh:resultSeverity sh:Violation ; sh:sourceConstraintComponent sh:NodeConstraintComponent ; sh:sourceShape <http://example.com/books/AuthorNodeShape> ; sh:focusNode <http://example.com/books/JRRTolkien> ; sh:value <http://example.com/books/JRRTolkien> ; sh:resultMessage "Value does not have shape <http://example.com/books/PersonShape>" ; ] .