Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cardinality contraint issue when omitting sh:maxCount in a closed shape #401

Open
herminiogg opened this issue Mar 1, 2021 · 0 comments

Comments

@herminiogg
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant