shaclex
shaclex copied to clipboard
Cardinality contraint issue when omitting sh:maxCount in a closed shape
Given the following input:
@prefix schema: <http://schema.org/> .
@prefix ex: <http://example.com/> .
@prefix dbr: <http://dbpedia.org/resource/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
ex:4 a ex:Film ;
ex:screenwritter dbr:Jonathan_Nolan , dbr:Christopher_Nolan ;
ex:year dbr:2006 ;
schema:countryOfOrigin dbr:USA ;
schema:director dbr:Christopher_Nolan ;
schema:musicBy dbr:David_Julyan ;
schema:name "The Prestige" .
ex:3 a ex:Film ;
ex:screenwritter dbr:Christopher_Nolan ;
ex:year dbr:2010 ;
schema:countryOfOrigin dbr:USA ;
schema:director dbr:Christopher_Nolan ;
schema:musicBy dbr:Hans_Zimmer ;
schema:name "Inception" .
ex:2 a ex:Film ;
ex:screenwritter dbr:Jonathan_Nolan , dbr:Christopher_Nolan ;
ex:year dbr:2014 ;
schema:countryOfOrigin dbr:USA ;
schema:director dbr:Christopher_Nolan ;
schema:musicBy dbr:Hans_Zimmer ;
schema:name "Interstellar" .
ex:1 a ex:Film ;
ex:screenwritter dbr:Christopher_Nolan ;
ex:year dbr:2017 ;
schema:countryOfOrigin dbr:USA ;
schema:director dbr:Christopher_Nolan ;
schema:musicBy dbr:Hans_Zimmer ;
schema:name "Dunkirk" .
and the following SHACL shape (using closed shapes):
@prefix schema: <http://schema.org/> .
@prefix ex: <http://example.com/> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix dbr: <http://dbpedia.org/resource/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
ex:Film a sh:NodeShape ;
sh:closed true ;
sh:property [ sh:maxCount 1 ;
sh:minCount 1 ;
sh:nodeKind sh:IRI ;
sh:path schema:countryOfOrigin
] ;
sh:property [ sh:in ( ex:Film ) ;
sh:path rdf:type
] ;
sh:property [ sh:maxCount 1 ;
sh:minCount 1 ;
sh:nodeKind sh:IRI ;
sh:path ex:year
] ;
sh:property [ sh:maxCount 1 ;
sh:minCount 1 ;
sh:nodeKind sh:IRI ;
sh:path schema:director
] ;
sh:property [ sh:maxCount 1 ;
sh:minCount 1 ;
sh:nodeKind sh:IRI ;
sh:path schema:musicBy
] ;
sh:property [ sh:datatype xsd:string ;
sh:maxCount 1 ;
sh:minCount 1 ;
sh:path schema:name
] ;
sh:property [ sh:minCount 1 ;
sh:nodeKind sh:IRI ;
sh:path ex:screenwritter
] ;
sh:targetClass ex:Film .
It seems that shaclex validator is taking the default ShEx cardinality values (i.e., 1 for max and min) instead of SHACL ones. When I tried this example on RDFShape I reached a satisfactory validation with JenaSHACL and SHACL_TQ validators; however, when I used shaclex validator it complains about the cardinality of ex:screenwritter property.
I looked into the SHACL specification and it was not clear for me which is the default cardinality behaviour, so it would be interesting to clarify this. Although, I assume this as an error due to the difference between this engine and the other two mentioned ones.