回复: how to use sh:if

Hi, Irene, Thank you very much for your reply and detailed code.
It's been very helpful to me.
I've also been told to use sh:rule to implement this,  I need to take a closer look at the examples in the SHACL test suite.
But with respect to sh:if, it would be nice to have a more detailed example in the test set  ,In the SHACL-AF specification, there are sh:if, sh:then, sh:else, So what about multiple branches like elseif?  Is it necessary to add sh:elseif?

Kind regards,
Joylix

________________________________
发件人: Irene Polikoff <irene@topquadrant.com>
发送时间: 2021年7月17日 7:39
收件人: Joy lix <joylix4112@outlook.com>
抄送: public-shacl@w3.org <public-shacl@w3.org>
主题: Re: how to use sh:if

Sorry was too quick to respond and made a couple of typos in the first option.

Use the following:


:TallPerson a owl:Class, sh:NodeShape;
sh:property [sh:path :hasHeight;
                   sh:datatype xsd:integer;
                   sh:minInclusive 185;]
...
.

Or

:TallPerson a owl:Class, sh:NodeShape;
sh:property :TallPerson-height;
...
.
Together With

:TallPerson-height a  sh:PropertyShape;
sh:path :hasHeight;
sh:datatype xsd:integer;
sh:minInclusive 185;
.

Or just the property shape with target


:TallPerson-height a  sh:PropertyShape;
Sh:target :TallPerson
sh:path :hasHeight;
sh:datatype xsd:integer;
sh:minInclusive 185;
.

On Jul 16, 2021, at 1:56 PM, Irene Polikoff <irene@topquadrant.com> wrote:

You do not need to use sh:if for this example.

Simply do:

:ShortPerson a owl:Class, sh:NodeShape;
sh:path :hasHeight;
sh:datatype xsd:integer;
sh:maxInclusive 155 ;
.

:MediumPerson a owl:Class, sh:NodeShape;
sh:path :hasHeight;
sh:minExclusive 155;
sh:datatype xsd:integer;
sh:maxExclusive 185;
.

:TallPerson a owl:Class, sh:NodeShape;
sh:path :hasHeight;
sh:datatype xsd:integer;
sh:minInclusive 185;
.

This will give you a violation message for Bob.

You can also make these property shapes within the node shape if you need to make some statements about other properties of these class members e.g.

:TallPerson a owl:Class, sh:NodeShape;
sh:property [sh:path :hasHeight;
                   sh:datatype xsd:integer;
                   sh:minInclusive 185;]
...
.

On Jul 16, 2021, at 3:28 AM, Joy lix <joylix4112@outlook.com<mailto:joylix4112@outlook.com>> wrote:

Dear all:

      I'm not very clear about the use of sh:if, The examples given in the SHACL-AF specification are relatively simple so I don't understand them very well.
Consider the following example:

if someone.height>180 then
       someone is tallPerson
else if someone.height>155 then
       someone is mediumPerson
else
       someone is shortPerson

How do I present it use sh:if in a shacl shape file?
Can the SHACL validation engine give an violation message for the following data files?
         :bob a :Person ;
                 :hasHeight 185 ;
                 a :shortPerson .
Because Bob, by definition, should be a tallPerson.

Thank you for your help!

Kind regards,
Joylix

Received on Sunday, 18 July 2021 15:30:42 UTC