weso / shaclex

SHACL/ShEx implementation
http://weso.github.io/shaclex
MIT License
76 stars 17 forks source link

`shacl` -> `shex` cardinality bugs #637

Open jeswr opened 3 months ago

jeswr commented 3 months ago

When a shacl constraint has an inspecified maxCount, there is no maximum bound. This means that if I have the following shape

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
@prefix ex: <http://example.org/test#> .

ex:TestShape a sh:NodeShape ;
  sh:targetClass ex:AccessRequest ;
  sh:property [
    sh:path ex:requestedGraphs ;
    sh:minCount 1 ;
    sh:datatype xsd:string
  ] .

Then the following should be generated

prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix ex: <http://example.org/test#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix sh: <http://www.w3.org/ns/shacl#>
ex:TestShape  {
ex:requestedGraphs  xsd:string{1,}
}

instead of

prefix xsd: <http://www.w3.org/2001/XMLSchema#>
prefix ex: <http://example.org/test#>
prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
prefix sh: <http://www.w3.org/ns/shacl#>
ex:TestShape  {
ex:requestedGraphs  xsd:string{1,1}
}

Similarly the default for minCount is 0 wheras the converter here uses a default of 1.