SHACL - closed world validation

45 views
Skip to first unread message

JD

unread,
Oct 7, 2019, 1:33:02 PM10/7/19
to TopBraid Suite Users
Hello
I am searching for an answer to what seems like an obvious question.

Is there a way to make sure everything is part of a shape? Meaning, in my closed world, I don't want any triple that doesn't match something in my shapes graph.

I know how to target and validate things (classes, properties, nodes) that I know about.
How do you in-validate the things that you don't know?

Is there a way to target every node?

Thanks

Steven Michael Folsom

unread,
Oct 7, 2019, 1:39:08 PM10/7/19
to topbrai...@googlegroups.com

I believe that is what https://www.w3.org/TR/shacl/#ClosedConstraintComponent is meant to address.

--
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/29d5ec0c-86c2-41df-ac25-a01e4ada1a68%40googlegroups.com.

JD

unread,
Oct 7, 2019, 3:00:22 PM10/7/19
to TopBraid Suite Users
My reading of that constraint is that it only closes a shape. Meaning, that a given focus node can not have properties that are not specified in a shape. But I think the node has to become a focus node first.

Becoming a focus node seems to happen when a node becomes a target of a target declaration or "whenever a focus node is provided directly as input to the validation process for that shape". I haven't figured out how to target "anything not in another shape". Nor have I identified how to make use of that quoted text.

Note: I am still learning the SHACL spec so my use of terms/ideas might be incorrect.

Rob Atkinson

unread,
Oct 7, 2019, 6:30:56 PM10/7/19
to topbrai...@googlegroups.com
One option would be to have a SHACL engine that captures provenance of shape validation - it means lots of extra triples of course, but you could then run such a query without doing something to force revaluation of al SHACL rules. Maybe an extension to SHACL to nominate an optional provenance graph to record rule execution.

--
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.

Holger Knublauch

unread,
Oct 7, 2019, 7:15:54 PM10/7/19
to topbrai...@googlegroups.com

To make sure that all triples in a data graph conform to at least one shape, I think you will need to go outside of SHACL Core and either use SHACL-SPARQL or SHACL custom targets (part of SHACL-AF [1]). In particular, assuming you have a number of shapes, and all of them are sh:closed true, then you could try (untested):

ex:GraphClosureShape
    sh:target [
        sh:SPARQLTarget ;
        sh:select "SELECT DISTINCT ?this { ?this ?p ?o }" ;
    ] ;
    sh:or ( ex:Shape1 ex:Shape2 ex:Shape3 )
.

Basically this would iterate over all subjects in the graph and check that they conform to at least one of the enumerated node shapes. If all of them are sh:closed then they cannot legally have any other triples.

Note that this only traverses triples in the "forward" direction, and it would be more complicating if you have closed shapes that also use sh:path expressions to walk in an inverse direction...

Holger

[1] https://w3c.github.io/shacl/shacl-af/#SPARQLTarget

--
You received this message because you are subscribed to the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to topbraid-user...@googlegroups.com.

JD

unread,
Oct 9, 2019, 2:05:19 PM10/9/19
to TopBraid Suite Users
Thanks for the replies. I hoped there was a simple answer that I had overlooked. Seems like something that should have been part of the basic standard.
Reply all
Reply to author
Forward
0 new messages