What is the effect of closing a PropertyShape?

147 views Asked by At

In the SHACL specification, as far as I can see, nothing forbids closing a PropertyShape.

The following is the default example from the SHACL Playground, with the default errors corrected, so the data is valid.

Shapes:

@prefix dash: <http://datashapes.org/dash#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <http://schema.org/> .
@prefix sh: <http://www.w3.org/ns/shacl#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

schema:PersonShape
    a sh:NodeShape ;
    sh:targetClass schema:Person ;
    sh:property [
        sh:path schema:givenName ;
        sh:datatype xsd:string ;
        sh:name "given name" ;
    ] ;
    sh:property [
        sh:path schema:birthDate ;
        sh:lessThan schema:deathDate ;
        sh:maxCount 1 ;
    ] ;
    sh:property [
        sh:path schema:gender ;
        sh:in ( "female" "male" ) ;
    ] ;
    sh:property [
        sh:path schema:address ;
        sh:node schema:AddressShape ;
    ] .

schema:AddressShape
    a sh:NodeShape ;
    sh:closed true ;
    sh:property [
        sh:path schema:streetAddress ;
        sh:datatype xsd:string ;
    ] ;
    sh:property [
        sh:path schema:postalCode ;
        sh:or ( [ sh:datatype xsd:string ] [ sh:datatype xsd:integer ] ) ;
        sh:minInclusive 10000 ;
        sh:maxInclusive 99999 ;
    ] .

Data (valid - no validation results):

@prefix ex: <http://example.org/ns#> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <http://schema.org/> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

ex:Bob
    a schema:Person ;
    schema:givenName "Robert" ;
    schema:familyName "Junior" ;
    schema:birthDate "1971-07-07"^^xsd:date ;
    schema:deathDate "2068-09-10"^^xsd:date ;
    schema:address ex:BobsAddress .

ex:BobsAddress
    schema:streetAddress "1600 Amphitheatre Pkway" ;
    schema:postalCode 19404 

Now when you close the sh:path schema:address property shape of the schema:PersonShape like so:

    sh:property [
        sh:closed true ;
        sh:path schema:address ;
        sh:node schema:AddressShape ;
    ] .

With this change, there are validation results:

[
    a sh:ValidationResult ;
    sh:resultSeverity sh:Violation ;
    sh:sourceConstraintComponent sh:ClosedConstraintComponent ;
    sh:sourceShape _:n1121 ;
    sh:focusNode <http://example.org/ns#Bob> ;
    sh:resultPath schema:streetAddress ;
    sh:value "1600 Amphitheatre Pkway" ;
    sh:resultMessage "Predicate is not allowed (closed shape)" ;
] .
[
    a sh:ValidationResult ;
    sh:resultSeverity sh:Violation ;
    sh:sourceConstraintComponent sh:ClosedConstraintComponent ;
    sh:sourceShape _:n1121 ;
    sh:focusNode <http://example.org/ns#Bob> ;
    sh:resultPath schema:postalCode ;
    sh:value 19404 ;
    sh:resultMessage "Predicate is not allowed (closed shape)" ;
] .

The specification of sh:closed says:

[...] a property called sh:closed that can be used to specify the condition that each value node has values only for those properties that have been explicitly enumerated via the property shapes specified for the shape via sh:property.

I am sorry: I fail to come up with an explanation of what is happening, as well as of what should happen (if the two are not the same).

Can someone explain the observed/specified behaviour?

Thanks!

0

There are 0 answers