Open jakubklimek opened 1 year ago
Indeed, that is a know issue. If nothing in the data graph matches any shape targets (ie. in your example there is no resource with type dcat:Catalog
), then no validation takes place. I think this is according to the spec and the wiki is a little misleading.
SHACL Play! shows a different message, not equivalent to failed validation. That may be a UI-only feature
A shape with sh:targetNode will always be executed, regardless of whether the graph contains that node, or any node. It will simply set the target to the given targetNode even if it doesn't "exist". So - from my superficial look - the validation engine should report a violation if there is no instance of that class.
That does make sense but isn't it the opposite of what you said on Discord and also to how the engines behave?
I don't know which version of SHACL_TQ weso.es uses, but all engines report success when the shape has no target or target which is not present in data graph
https://rdfshape.weso.es/link/16789515368
By the way @jakubklimek, I noticed only now that you should change sh: targetNode
to sh:targetClass
@tpluscode Actually, if I understand the Wiki example correctly, having sh:targetNode
pointing to the class instead of sh:targetClass
and supplementing it with the inverse of rdf:type
are parts of the whole trick here.
ah ok, I failed to really understand before.
Yes, without a logic as described by Holger this cannot work. Otherwise it does assume that no targets found => no validation
I propose we revert #81 because we misunderstood the spec (and the example to check there is at least one instance is useful)
Can you link to the spec where this is scenario mentioned?
https://www.w3.org/TR/shacl/#targets
RDF terms produced by targets are not required to exist as nodes in the data graph.
I want to check whether in the Data graph, there is at least one instance of
dcat:Catalog
. I followed this example from the SHACL wiki. tl;dr: It does not work in Zazuko, it works in SHACL Play!, but I am not sure which behavior is the correct one.Data graph - note that there is one instance of
dcat:Catalog
:Shapes graph:
Like this, it validates in Zazuko. However, if I remove the
dcat:Catalog
, e.g., by emptying the data graph, it still validates, which is not what I want. According to the example, and also in SHACL Play! it does not validate, which is what I want. However, I am not sure that the example is correct, since the targetNode cannot target anything, when there is nodcat:Dataset
in the data graph, and therefore there is nothing to validate, and therefore the data graph seems valid. 🤷🏻♂️