- From: Irene Polikoff <irene@topquadrant.com>
- Date: Sat, 16 Sep 2017 23:41:20 +0200
- To: John Walker <john.walker@semaku.com>
- Cc: "public-rdf-shapes@w3.org" <public-rdf-shapes@w3.org>
- Message-Id: <6B208FE1-62BA-44AA-B16F-47FEE5184AC5@topquadrant.com>
as stated in https://www.w3.org/TR/shacl/#ClosedConstraintComponent <https://www.w3.org/TR/shacl/#ClosedConstraintComponent> The SHACL Core language includes a property called sh:closed that can be used to specify the condition that each value node has values <https://www.w3.org/TR/shacl/#dfn-value> only for those properties that have been explicitly enumerated via the property shapes <https://www.w3.org/TR/shacl/#dfn-property-shape> specified for the shape via sh:property. So, yes. Creating explicit property shapes for them should do it or add them to the ignored list. > On Sep 16, 2017, at 10:51 PM, John Walker <john.walker@semaku.com> wrote: > > 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# <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# <http://www.w3.org/1999/02/22-rdf-syntax-ns#>> . > @prefix rdfs: <http://www.w3.org/2000/01/rdf-schema# <http://www.w3.org/2000/01/rdf-schema#>> . > @prefix sh: <http://www.w3.org/ns/shacl# <http://www.w3.org/ns/shacl#>> . > @prefix ex: <http://example.org/ns# <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 21:41:50 UTC