eclipse-rdf4j / rdf4j

Eclipse RDF4J: scalable RDF for Java
https://rdf4j.org/
BSD 3-Clause "New" or "Revised" License
365 stars 163 forks source link

SHACL: dash:hasValueIn duplicates the sh:focusNode value for sh:value in constraint validation reports #2439

Closed rdstn closed 4 years ago

rdstn commented 4 years ago

When using the new extended dash:hasValueIn constraint component, validation reports duplicate the sh:focusNode value in the sh:value field.

Example SHACL shape:

@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix dash: <http://datashapes.org/dash#> .
@prefix rsx: <http://rdf4j.org/shacl-extensions#> .
@prefix vocsh: <http://example.org/shape/> .
@prefix voc: <https://shacl.co/vocabulary/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .

vocsh:SimpleObject
    a sh:NodeShape ;
    rsx:targetShape [ a sh:Shape ; sh:property[ sh:path rdf:type ; sh:hasValue voc:SimpleObject ;  ] ];
;
    sh:property [
        sh:path voc:valIn ; 
        sh:maxCount 1 ; 
        dash:hasValueIn ("blue" "green" "pink") ; 
        sh:datatype xsd:string ; 
    ] .

Example SPARQL:

base <https://shacl.co/resource/>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix voc: <https://shacl.co/vocabulary/>
INSERT {
    <https://shacl.co/vocabulary/123> voc:valIn "pin";
           rdf:type <https://shacl.co/vocabulary/SimpleObject>.
}
WHERE {}

The SPARQL produces the following report:

_:node1efmbis8tx33004 a sh:ValidationResult;
  sh:focusNode <https://shacl.co/vocabulary/123>;
  sh:resultPath <https://shacl.co/vocabulary/valIn>;
  sh:sourceConstraintComponent <http://datashapes.org/dash#HasValueInConstraintComponent>;
  sh:sourceShape _:node125;
  sh:value <https://shacl.co/vocabulary/123> .

Expected:

_:node1efmbis8tx33004 a sh:ValidationResult;
  sh:focusNode <https://shacl.co/vocabulary/123>;
  sh:resultPath <https://shacl.co/vocabulary/valIn>;
  sh:sourceConstraintComponent <http://datashapes.org/dash#HasValueInConstraintComponent>;
  sh:sourceShape _:node125;
  sh:value "pin" .

This was observed while running RDF4J 3.3.0

hmottestad commented 4 years ago

After reading the spec a bit closer I think the correct approach is to omit sh:value for sh:hasValue and for dash:hasValueIn.

If there should be a value for sh:value then it should be mentioned in the spec: https://www.w3.org/TR/shacl/#HasValueConstraintComponent

I really wish that the shacl document could have a nice little table showing which contraint components can be used together and which produce a sh:value.