sh:sourceShape points to blank PropertyShape

Hi! We have a bunch of rules (NodeShapes) with a lot of metadata in them.
We want ValidationResults to point to those shapes, so we can display the
metadata along with the node and value to blame.
Our rules are often implemented as a single sh:property, and sometimes with
sh:and, sh:or, sh:node.

We find with both TQ SHACL and RDF4J SHACL that sh:sourceShape is set to
the PropertyShape, which in our case is a blank node.
For example:

<sh1> a sh:NodeShape;
  sh:target...
  sh:property [sh:path ...; ...]. <<< set to this blank-node PropertyShape

<sh2> a sh:NodeShape;
  sh:target...
  sh:not [sh:property [sh:path ...; ...]]. <<< set to the NodeShape

Paradoxically, results from the more complicated shape sh2 ends up pointing
to the right node, whereas the simpler shape sh1 points to a blank node.

What we do is post-process the validation results to redirect
sh:sourceShape to the right node, eg:

delete {?x sh:sourceShape ?propShape}
insert {?x sh:sourceShape ?nodeShape}
where {
  ?x sh:sourceShape ?propShape
  filter(isBlank(?propShape))
  filter exists {?propShape sh:path []}
  ?propShape ^sh:property ?nodeShape
}

However, shouldn't the spec lay down some rules that sh:sourceShape is
redirected "upwards" from blank-node PropertyShape?

--
Vladimir Alexiev, PhD, PMP
Chief Data Architect
Sirma AI, trading as Ontotext: https://www.ontotext.com, LinkedIn, Twitter,
Rate GraphDB
Email: vladimir.alexiev@ontotext.com, skype:valexiev1
Mobile: +359 888 568 132, SMS: 359888568132@sms.mtel.net
Calendar:
https://www.google.com/calendar/embed?src=vladimir.alexiev@ontotext.com
Publications and CV: https://github.com/VladimirAlexiev/my

Received on Friday, 18 February 2022 15:03:17 UTC