Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
HolgerKnublauch opened this issue Feb 16, 2024 · 2 comments

Comments

@HolgerKnublauch
Copy link
Contributor

HolgerKnublauch commented Feb 16, 2024

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).

@bertvannuffelen
Copy link

I personally am not sure if this can be allowed. Semantically this becomes a very tricky issue.

What is the meaning of

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" ;
    |} ; 
   sh:message "This a global error message" ;
   sh:severity sh:Violation.

but also why cannot I write it as follows

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

where is the limit of using RDF 1.2 reification? Can it be applied to any property in the shape and how much nesting of this is allowed?

The semantics of sh:message is the "message associated with the Shape" (see diagram https://w3c.github.io/shacl/shacl-core/#constraints-section) not the "message associated with a RDF statement in a shape.
That is a big difference.

Moreover, reification is limited to simple cases: otherwise this is ambiguous. In the next example sh:or has switched arguments. I assume that RDF 1.2. triple reification will be done on syntactic equivalence and not on semantic equivalence, and therefore RDF 1.2 reification cannot ensure equality here.

ex:MyClass1-myProperty
    a sh:PropertyShape ;
	sh:or (
		[
			sh:path ex:firstName ;
			sh:minCount 1 ;
		]
		[
			sh:path ex:givenName ;
			sh:minCount 1 ;
		]
	)  {|
        sh:severity sh:Warning ;
        sh:message "There SHOULD be at least one value here" ;
    |} .


ex:MyClass2-myProperty
    a sh:PropertyShape ;
	sh:or (
		[
			sh:path ex:givenName ;
			sh:minCount 1 ;
		]
		[
			
                        sh:path ex:firstName ;
			sh:minCount 1 ;
		]
	) . {|
        sh:severity sh:Warning ;
        sh:message "There SHOULD be at least one value here" ;
    |} .

@HolgerKnublauch
Copy link
Contributor Author

To your first question, if there is a reification on a constraint then this takes precedence over the values attached to the surrounding shape.

The second question, allowing reification at sh:path, doesn't look good to me as it would go too far.

On your reference to the spec, this would of course need to be updated in the 1.2 document as the 1.0 spec was written before RDF star was on a W3C process.

I agree that cases like sh:or are less pretty, if only for the rdf:List syntax. But those details can be worked out, e.g. by limiting this syntax to the simple cases such as sh:minCount.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants