w3c / shacl

SHACL Community Group (Post-REC activitities)
27 stars 4 forks source link

Support sh:message, sh:severity and sh:deactivated per constraint triple #27

Open HolgerKnublauch opened 4 months ago

HolgerKnublauch commented 4 months ago

RDF 1.2 will provide some syntax for attaching statements to other statements.

Currently, sh:message and sh:severity need to be placed in shapes. But shapes can contain multiple constraint triples, and not all of them should receive the same message and severity.

For example

ex:MyClass-myProperty
    a sh:PropertyShape ;
    sh:path ex:myProperty ;
    sh:maxCount 1 .

ex:MyClass-myProperty-minCount
    a sh:PropertyShape ;
    sh:path ex:myProperty ;
    sh:minCount 1 ;
    sh:severity sh:Warning ;
    sh:message "There SHOULD be at least one value here" .

It should become possible to use RDF 1.2 reification or quoted triples to do something like this

ex:MyClass-myProperty
    a sh:PropertyShape ;
    sh:path ex:myProperty ;
    sh:maxCount 1 ;
    sh:minCount 1 {| 
        sh:severity sh:Warning ;
        sh:message "There SHOULD be at least one value here" ;
    |} .

This would avoid having to introduce artificial shapes just to encapsulate warning or severity.

We have implemented this in TopBraid for several years now and didn't run into complaints from users.

The same mechanism would also be great for sh:deactivated (we didn't implement that yet).