- From: RDF Data Shapes Working Group Issue Tracker <sysbot+tracker@w3.org>
- Date: Wed, 02 Sep 2015 05:11:14 +0000
- To: public-data-shapes-wg@w3.org
shapes-ISSUE-84 (Allowed IRIs): Constraint to limit IRIs of focus nodes to a given enumeration (similar to owl:oneOf) [SHACL Spec] http://www.w3.org/2014/data-shapes/track/issues/84 Raised by: Holger Knublauch On product: SHACL Spec I tried to model that the class sh:NodeKind consists of exactly three instances (sh:IRI, sh:Literal, sh:BlankNode), but failed to find a simple way of expressing this within the SHACL Core language. Maybe I am missing something. But I believe this is a recurring pattern in controlled vocabularies and may deserve its "built-in" construct. OWL has the equivalent built-in via owl:oneOf. A possible syntax and template are below. sh:NodeKind a sh:ShapeClass ; rdfs:subClassOf rdfs:Resource ; rdfs:label "Node kind" ; rdfs:comment "The class of RDF node kinds: literals, blank nodes and IRIs." ; sh:constraint [ a sh:AllowedIRIsConstraint ; sh:allowedIRIs ( sh:BlankNode sh:IRI sh:Literal ) ; ] ; . sh:AllowedIRIsConstraint a sh:ConstraintTemplate ; rdfs:subClassOf sh:TemplateConstraint ; rdfs:label "Enumerated class constraint" ; rdfs:comment "Specifies that the IRIs of the focus nodes must be one of the members of the rdf:List given as sh:allowedIRIs." ; sh:argument [ sh:predicate sh:allowedIRIs ; sh:valueClass rdf:List ; rdfs:label "allowed IRIs" ; rdfs:comment "The list of IRIs that are allowed" ; ] ; sh:message "Node is not among the allowed IRIs" ; sh:sparql """ SELECT ?this WHERE { FILTER NOT EXISTS { GRAPH ?shapesGraph { ?allowedIRIs (rdf:rest*)/rdf:first ?this . } } } """ ; . An alternative would be to create an sh:inverseProperty constraint on rdf:type starting at the focus node sh:NodeKind using a sh:nodeShape scope, but this is verbose and doesn't feel intuitive.
Received on Wednesday, 2 September 2015 05:11:18 UTC