ShEx/ShapeMap
Obsolete - please see ShapeMap Spec
ShEx Validation is defined in terms of a Shape Map, a mapping of nodes to shapes. This page describes different techniques for associating nodes with shapes.
SHACL target*
The SHACL Specification section 2 defines a set of properties for associating nodes with shapes. These are defined as RDF properties, implying an execution model where the node/shape associations are supplied in RDF. Below, these are listed, along with terse labels for them for use in other execution environments such as HTML forms:
property | short name | description |
---|---|---|
sh:targetNode | targetNode | selects the specified RDF node. |
sh:targetClass | targetClass | selects RDF nodes with a type arc to the specified node. |
sh:targetSubjectsOf | targetSubjectsOf | selects all subjects of arcs with the specified predicate. |
sh:targetObjectsOf | targetObjectsOf | selects all objects of arcs with the specified predicate. |
These are functions which return a list of nodes. The nodes are paired with a shape name to construct a ShapeMap. For example, a ShapeMap could be a list like (using JSON's [] notation for lists):
[[ targetClass(foaf:Person), my:PersonShape ], [ targetSubjectsOf(foaf:knows), my:PersonShape ], [ targetObjectsOf(foaf:knows), my:PersonShape ]]
to test any node which has `rdf:type` `foaf:Person` or is the subject or object of a `foaf:knows` arc. The data:
<Alice> a foaf:Person ; foaf:knows <Bob>, <Claire> . <Don> foaf:knows <Evan> .
produces a ShapeMap:
[[ <Alice>, my:PersonShape ], # targetClass(foaf:Person), targetSubjectsOf(foaf:knows) [ <Bob>, my:Personshape ], # targetObjectsOf(foaf:knows) [ <Clair>, my:Personshape ], # targetObjectsOf(foaf:knows) [ <Don>, my:Personshape ], # targetSubjectsOf(foaf:knows) [ <Evan>, my:Personshape ], # targetObjectsOf(foaf:knows) ]]
Note that there are three reasons for `[ <Alice>, my:PersonShape ]` to appear but ShapeMaps are a set of node/shape pairs.
SPARQL query
A Sparql query links nodes to a shape.
select ?node ?shape { ... }
OWL inference
Each instance within the database to be validated need to be typed or its type needs to be inferred with the OWL open world inference engines/modes. Each class is associated to a shape or vise versa.