Using sh:closed in combination with SHACL property paths and logical constraint components

Hi,

I have a question about behavior in SHACL playground.

I am trying to use a closed shape to validate a case where the data graph should have instances/resources that have either property A or B.

As a minimal example, I want to validate that a ex:Person must have either ex:firstName OR ex:givenName.
Also, there should be no other statements in the graph.

Example data graph:

```
@prefix ex: <http://example.org/ns#> .

ex:Bob a ex:Person ;
  ex:firstName "Robert" ;
  ex:givenName "Bob" .

ex:Alice a ex:Person ;
  ex:firstName "Alice" .

ex:Edward a ex:Person ;
  ex:givenName "Ted" .
```

Example shapes graph:

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

ex:OrConstraintExampleShape
  a sh:NodeShape ;
  sh:targetClass ex:Person ;
#  sh:property [
#    sh:path [ sh:alternativePath ( ex:firstName ex:givenName ) ] ;
#    sh:minCount 1 ;
#    sh:maxCount 1 ;
#  ] ;
  sh:xone (
    [
      sh:path ex:firstName ;
      sh:minCount 1 ;
      sh:maxCount 1 ;
    ]
    [
      sh:path ex:givenName ;
      sh:minCount 1 ;
      sh:maxCount 1 ;
    ]
  ) ;
  sh:ignoredProperties (rdf:type) ;
  sh:closed true.
```

Here I tried a couple of alternate ways to express the constraint, namely SHACL property paths and logical constraint components.

However, I observe that when using either approach in combination with a closed shape, the playground always gives validation error that the ex:firstName and ex:givenName predicates are not allowed.

Or is it required to add additional property shapes where those predicates are explicitly enumerated as a value of sh:path?

As in:

```
ex:OrConstraintExampleShape
  sh:property [ sh:path ex:firstName ] , [ sh:path ex:givenName ] .
```

Regards,
John

Received on Saturday, 16 September 2017 20:52:04 UTC