Thanks a lot for your detailed explanation support, Irene and David! Very much appreciated! The sh:or solution is exactly what I was looking for, and that`ll be our choice to go for. Introducing superclasses for the classes in question would artificially blow up our ontology and would not work well in our case. Thanks for the valuable hints.
On Mon, Nov 30, 2020 at 5:46 PM Irene Polikoff <[email protected]> wrote: > Yes, David is correct, creating a common parent class is indeed the > simplest approach. > > It is the simplest to express and with this approach, autocomplete in > TopBraid EDG will work as expected - showing only instances of the > specified classes. > > I never suggested to simply use sh:class constraint with multiple classes. > All constraints must be met. Thus, if you use multiple classes with > sh:class, the value would need to be an instance of all classes - as you > have discovered. > > What I suggested in the e-mail below is to have multiple targets. A target > of a shape is a union of all target statements. Targets are, of course, > different from constraints. They define where a shape is applicable, not > how the values should look like. > > If you, for some reason, can’t create a common parent class, the next > option is to use sh:or - I have mentioned this in my original e-mail. For > example: > > ex:OrExample1 > a owl:Class, sh:NodeShape ; > sh:property [ > sh:path ex:property ; > sh:or ( > [ > sh:class ex:A ; > ] > [ > sh:class ex:B ; > ] > ) > ] . > > > You can also use sh:or with different paths. Such as: > > ex:OrExample2 > a owl:Class, sh:NodeShape ; > sh:or ( > [ > sh:path ex:property1 ; > sh:class ex:A ; > ] > [ > sh:path ex:property2 ; > sh:class ex:B ; > ] > ) . > > > Another approach is to use sh:in with a complex property path. I am > showing it to demonstrate different ways to say things in SHACL. The > property path below is the same as using > ex:property/rdf:type/rdfs:subClassOf* in SPARQL. > > ex:InExample > a owl:Class, sh:NodeShape ; > sh:property [ > sh:path (ex:property rdf:type [sh:zeroOrMorePath > rdfs:subClassOf]) ; > sh:in ( ex:A ex:B ) ; > ] . > > > The sh:or and sh:in options will work for validation, but will not limit > the autocompletion on the forms when editing to only instances of A and B. > > > On Nov 30, 2020, at 10:33 AM, David Price <[email protected]> wrote: > > > > On 30 Nov 2020, at 14:39, Henrik Dibowski <[email protected]> wrote: > > Hi Irene and all, > > I was looking for existing discussions about the problem we`re facing, and > found your post here. In SHACL I want to express that the object nodes of > an object property can be of either class A, B, C... That`s what I`m trying > to define in the PropertyShape of the object property via the sh:class > predicate. Here I need to define this alternative from a list of classes. > Using owl:unionOf does not seem to work here > > > As Irene said: > > Second, SHACL is its own language. You cannot use OWL axioms in SHACL >> definitions just as you can’t use SHACL statements in OWL axioms. SHACL >> has its own logical expressions using sh:or, sh:and, sh:not, etc. >> > > > , as the SHACL engine reports constraint violations for any subject > instance, which is not an instance of all the classes. Defining several > values for sh:class, as suggested by you, Irene, does not work either, as > the implemented semantics is not the union but the intersection, i.e. only > instances can be in the object position that are members of ALL the > classes. So that`s not the wanted behavior, but does quite the opposite of > a union construct. > > My question to you: How can we define the desired expression? Or is the > SHACL engine faulty? I have this problem not only for the sh:class > predicate, but also for sh:targetClass of a NodeShape, where I want to have > an easy way to declare the union of several classes as target class. I do > not want to go for a SPARQL target definition here (there has to be a > simpler solution!?), and besides, for sh:class it would not be an option at > all. > > > The simplest approach is to make a superclass of the classes in question. > In EDG you can declare that to be abstract too. > > Cheers, > David > > > Many thanks > > On Wednesday, February 5, 2020 at 3:19:21 PM UTC+1 Irene Polikoff wrote: > >> Michel, >> >> First, all target declarations are cumulative. The target is a union of >> all targets https://www.w3.org/TR/shacl/#targets >> >> So, for the validation purposes, you could simply do: >> >> alim:NodeShape_1 sh:targetClass bs:InformationObject, bs:Activity, >> bs:PhysicalObject. >> >> For the form view and edit purposes, you will see the rdfs:seeAlso on >> the form for instances of these classes, but not in the same display with >> the fields that are defined directly for the class or for any class it is >> connected to via rdfs:subClassOf statement, transitively. >> >> Instead, you will get a dropdown on the form that will let you switch to >> the alim:NodeShape_1 view of a resource. This view will only show >> properties defined for alim:NodeShape_1. Each node shape targeting a >> resource results in its own view on a resource. >> >> If this is not what you want, do not create a new node shape that will be >> an alternative view. Instead, add a property shape for rdfs:seeAlso >> directly for each of the classes or create a common super class and add the >> property shape to it. >> >> In EDG, for modeling convenience, there is an option to add already >> existing property definitions (property shapes) to a class (node shape) as >> well as an option to copy property definitions from another node shape. >> >> Second, SHACL is its own language. You can not use OWL axioms in SHACL >> definitions just as you can’t use SHACL statements in OWL axioms. SHACL >> has its own logical expressions using sh:or, sh:and, sh:not, etc. >> >> SHACL engines do not perform OWL inferencing e.g., to resolve the set >> represented as a union. You can, in principle, run OWL inferencing on your >> ontology which could insert rdfs:subClassOf statements from these 3 classes >> to the union class which will be a blank node and you could attach a >> property shape for rdfs:seeAlso to that blank node, but I would not >> recommend this. >> >> >> Third, if you want to see on a form a hyperlink to a document on a web, >> use xsd:anyURI or, if values are text that includes links, use ref:HTML. >> You can also specify multiple datatypes. >> >> On Feb 5, 2020, at 7:16 AM, 'Bohms, H.M. (Michel)' via TopBraid Suite >> Users <[email protected]> wrote: >> >> Dear Irene >> >> Still bit struggling with TBCtoEDG. >> >> Following your advice I made my ontology a shacl one in TBC. >> >> I added: >> alim:NodeShape_1 >> rdf:type sh:NodeShape ; >> sh:property [ >> sh:path rdfs:seeAlso ; >> sh:datatype xsd:string ; >> ] ; >> sh:targetClass [ >> rdf:type owl:Class ; >> owl:unionOf ( >> bs:InformationObject >> bs:Activity >> bs:PhysicalObject >> ) ; >> ] ; >> . >> >> This way I hoped to get a rdfs:seeAlso property in my >> bs:InformationObject/alim:Paper form. (I actually have data pointing to an >> doc on the web). >> >> However when I use EDG (including this update shacl file) and go to a >> specific instance of InformationObject I get: >> >> <image001.jpg> >> >> >> >> And also an error is thrown in TBC: >> >> <image007.jpg> >> >> >> >> Thx for advice, >> Michel >> >> Ps >> I attached the actual test ontology >> >> >> Dr. ir. H.M. (Michel) Böhms >> Senior Data Scientist >> >> T +31888663107 <+31%2088%20866%203107> >> M +31630381220 <+31%206%2030381220> >> E [email protected] >> Location >> >> >> >> <image006.gif> >> >> >> This message may contain information that is not intended for you. If you >> are not the addressee or if this message was sent to you by mistake, you >> are requested to inform the sender and delete the message. TNO accepts no >> liability for the content of this e-mail, for the manner in which you use >> it and for damage of any kind resulting from the risks inherent to the >> electronic transmission of messages. >> >> >> >> >> >> -- >> 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 [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/topbraid-users/ec66e6a6d0f840b093c55230981f3446%40tno.nl >> . >> <alim.shapes.ttl> >> >> > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/topbraid-users/e69817dc-062b-487a-a50c-2434a1b0f7dan%40googlegroups.com > <https://groups.google.com/d/msgid/topbraid-users/e69817dc-062b-487a-a50c-2434a1b0f7dan%40googlegroups.com?utm_medium=email&utm_source=footer> > . > > > UK +44 (0) 7788 561308 > US +1 (336) 283-0808 > > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/topbraid-users/560E7839-E8B2-4EE6-A3EE-CE10C280F5B3%40topquadrant.com > <https://groups.google.com/d/msgid/topbraid-users/560E7839-E8B2-4EE6-A3EE-CE10C280F5B3%40topquadrant.com?utm_medium=email&utm_source=footer> > . > > > -- > 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 [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/topbraid-users/B35CA3A1-27F3-4CD3-B8D4-6ADD7AA6E154%40topquadrant.com > <https://groups.google.com/d/msgid/topbraid-users/B35CA3A1-27F3-4CD3-B8D4-6ADD7AA6E154%40topquadrant.com?utm_medium=email&utm_source=footer> > . > -- 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 [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/CAKW4bcSNbG5oeFS8Wj38y%2BZ8kyp-sy8bQd2nHP-zfd3E2kRFPw%40mail.gmail.com.
