[shex] Customize validation of some constraints (#94)

labra has just created a new issue for https://github.com/shexSpec/shex:

== Customize validation of some constraints ==
# Use case

This feature has been requested by a simple use case. Some users want to use the same shapes to describe data which validate the same data before and after applying inference.

For example, imagine some RDF data like the following:

```
:alice a :Teacher ;
         schema:name "Alice" .

:Teacher rdfs:subClassOf :Person .
``` 

A possible shape for teachers before RDFS inference could be:

```
<TeacherShape> {
 a [ :Teacher]  ;
 schema:name xsd:string ;
}
```

but if we apply inference, that node would no longer conform, because the inference system would add the triple `:alice a :Person`.

A possible shape for teachers after inference could be:

```
<TeacherShape> {
 a [ :Teacher]  ;
 a [:Person ] ;
 schema:name xsd:string ;
}
```

But in this case, the node before inference would not conform as expected.

Although this is right, from a practical point of view, keeping two set of shapes, one for shapes of nodes before inference and another for shapes of nodes after inference can be problematic so some users (see [this issue](https://github.com/validatingrdf/validatingrdf.github.io/issues/21) ), are requesting some solution to have a single shape file which can be used to validate both before and after inference.

One solution could be to define some annotations to disable the validation of some constraints when some conditions are met 

For example, a shape for the previous case could be:

```
<TeacherShape> {
 a [ :Teacher]  ;
 a [:Person ] ;  // sx:applyWhen sx:RDFSEntailment 
 schema:name xsd:string ;
}
```

where the annotation `sx:applyWhen` defines that the triple constraint `a [:Person]` should only be applied when the validation is performed after RDFS inference. 

Maybe there are other solutions or best practices that we could recommend for this use case.

Please view or discuss this issue at https://github.com/shexSpec/shex/issues/94 using your GitHub account

Received on Tuesday, 16 July 2019 10:06:08 UTC