How to use sh:minus

30 views
Skip to first unread message

cbur...@healthwise.org

unread,
Feb 24, 2021, 6:44:32 PM2/24/21
to TopBraid Suite Users
The SHACL-AF spec contains a definition for a property called sh:minus, but I don't think my brain is able to parse it properly. Some examples might help, but the only one I've been able to find anywhere is in Example 3 of this tutorial, where sh:this is used as the object of sh:minus.

What I want to do is define a property shape that infers a list of values that is calculated by taking all the values of another property shape -- call it ex:includes -- and removing all the values of a third property shape -- call it ex:excludes. But I can't seem to write a valid sh:values statement that does this.

Is sh:minus even the right property to use for this? If so, what is the proper syntax? For what it's worth, this was one of my attempts:

  sh:values [
      sh:nodes [
          sh:path ex:includes;
        ] ;
      sh:minus ex:excludes;
    ] ;

Holger Knublauch

unread,
Feb 24, 2021, 6:58:22 PM2/24/21
to topbrai...@googlegroups.com

sh:minus takes any node expression and will simply compute the nodes resulting from sh:nodes and then remove the nodes resulting from sh:minus.

Did you try

  sh:values [
      sh:nodes [ sh:path ex:includes ] ;
      sh:minus [ sh:path ex:excludes ];
    ] ;

The way you have written it would just exclude the property ex:excludes itself, because that's a constant term node expression

For the geeks here is the implementation of sh:minus

    public ExtendedIterator<RDFNode> eval(RDFNode focusNode, NodeExpressionContext context) {
        Set<RDFNode> sans = minus.eval(focusNode, context).toSet();
        return getInput().eval(focusNode, context).filterDrop(n -> sans.contains(n));
    }

Holger


--
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/ba2904a6-242d-4c9c-8ad3-ad334edfd5e1n%40googlegroups.com.

Carl Burnett

unread,
Feb 25, 2021, 11:39:14 AM2/25/21
to topbrai...@googlegroups.com

Holger, that did the trick. Thanks! I felt like I had tried every possible combination, but apparently not that one.

 

Are there plans to develop a more detailed spec with examples, or maybe further tutorials for SHACL? With other specs/languages, it’s possible to google around and find a similar example to see someone else did something. But with SHACL, I often feel alone in a giant, empty sea…

 

Carl

 

From: topbrai...@googlegroups.com <topbrai...@googlegroups.com> On Behalf Of Holger Knublauch
Sent: Wednesday, February 24, 2021 3:58 PM
To: topbrai...@googlegroups.com
Subject: Re: [topbraid-users] How to use sh:minus

 

*** External email: use caution ***

--
You received this message because you are subscribed to a topic in the Google Groups "TopBraid Suite Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/topbraid-users/I9rSZumVNVQ/unsubscribe.
To unsubscribe from this group and all its topics, send an email to topbraid-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/551b2dea-a35d-c1a9-d84b-a7059371c777%40topquadrant.com.

Holger Knublauch

unread,
Mar 1, 2021, 8:18:19 PM3/1/21
to topbrai...@googlegroups.com

Hi Carl,

since this topic has come up many times recently, and the existing documentation of SHACL Node Expressions (and thus sh:values and sh:TripleRules) in the spec was rather wanting, I have finally allocated some time to produce examples for most of the node expression types:

    https://w3c.github.io/shacl/shacl-af/#node-expressions

While we at TQ may produce all kinds of tutorials and product documentation, the W3C specs (here, Community Report draft) are the ultimate sources that most people will look up.

HTH
Holger

cbur...@healthwise.org

unread,
Mar 2, 2021, 11:30:57 AM3/2/21
to TopBraid Suite Users
Thank you! This work is very much appreciated.

Carl

Reply all
Reply to author
Forward
0 new messages