joylix
joylix

Reputation: 127

Why this SHACL validation does not work as expected?

Here is my shacl.ttl:

@prefix ex: <http://datashapes.org/sh/tests/core/path/path-sequence-003.test#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

ex:paintNodeShape
  rdf:type sh:NodeShape ;
  sh:property ex:ColorProperty ;
  sh:targetNode ex:John .

ex:ColorProperty
  rdf:type sh:PropertyShape ;
  sh:qualifiedValueShape [  
      sh:path (ex:paint  ex:ballColor ) ;
      sh:hasValue "Red" ;
     ] ;
  sh:qualifiedMinCount 2 .

and here is data.ttl:

@prefix ex: <http://datashapes.org/sh/tests/core/path/path-sequence-003.test#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .

ex:John
  ex:paint [ ex:ballColor "Red"] ;
  ex:paint [ ex:ballColor "Red"] ;
  ex:paint [ ex:ballColor "Blue"] .

I want to verify that John painted at least two balls red, and the data given should meet the requirements. But I got an error message: "Less than 2 values have shape _:22728aa9248d56603d8c20009b9d6742" . Is there something wrong with my sequence path? Thanks a lot for your help!

Upvotes: 1

Views: 316

Answers (1)

IS4
IS4

Reputation: 13217

Your shape definition is a bit different from how the SHACL examples for sh:qualifiedValueShape go. I believe the property shape might need sh:path ex:paint to really match the property, like this:

ex:ColorProperty
  rdf:type sh:PropertyShape ;
  sh:path ex:paint ;
  sh:qualifiedValueShape [  
      sh:path ex:ballColor ;
      sh:hasValue "Red" ;
     ] ;
  sh:qualifiedMinCount 2 .

This should represent a shape for the values of the ex:paint property.

Upvotes: 1

Related Questions