shacl mapping question for domain/ranges

34 views
Skip to first unread message

Bohms, H.M. (Michel)

unread,
Apr 2, 2020, 10:06:55 AM4/2/20
to topbrai...@googlegroups.com

 

In RDFS:

 

ex:someproperty

  a rdf:Property ;

  rdfs:domain ex:somedomainclass ;

  rdfs:range ex:somerangeclass ;

 

In SHACL:

 

ex:someproperty

  a rdf:Property, sh:PropertyShape ;

  ….?

 

Or not possible and need for:

 

ex:somepropertyShape1

  a sh:PropertyShape ;

  sh:targetSubjectsOf ex:someproperty ;

  sh:class ex:somedomainclass .

 

ex:somepropertyShape1

  a sh:PropertyShape ;

  sh:targetObjectsOf ex:someproperty ;

  sh:class ex:somerangeclass .

 

 

 

 

 

Dr. ir. H.M. (Michel) Böhms
Senior Data Scientist

+31888663107
+31630381220
michel...@tno.nl

Location

 

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.

 

 

 

 

dprice

unread,
Apr 2, 2020, 10:29:12 AM4/2/20
to topbrai...@googlegroups.com
SHACL spec says:

2.3 Property Shapes

A property shape is a shape in the shapes graph that is the subject of a triple that has sh:path as its predicate.


Make a separate property shape and in it use sh:path to refer to the property. Something like:

ex:someproperty_shape
a sh:PropertyShape ;
sh:path ex:someproperty ;
...

sh:path can have more complex structures, but that’s a basic starting point. See https://www.w3.org/TR/shacl/#dfn-shacl-property-path

Cheers,
David

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 topbraid-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/ce25c5df596b4406a7311e9f27dfcb34%40tno.nl.


Bohms, H.M. (Michel)

unread,
Apr 2, 2020, 10:34:22 AM4/2/20
to topbrai...@googlegroups.com

So in the end:

 

 

ex:somepropertyShape1

  a sh:PropertyShape ;

  sh:path ex:someproperty ;

  sh:targetSubjectsOf ex:someproperty ;

  sh:class ex:somedomainclass .

 

ex:somepropertyShape2

  a sh:PropertyShape ;

  sh:path ex:someproperty ;

  sh:targetObjectsOf ex:someproperty ;

  sh:class ex:somerangeclass .

 

the path and target subjectsof feel a bit double...

 

 

 

 

 

 

Dr. ir. H.M. (Michel) Böhms
Senior Data Scientist

+31888663107
+31630381220
michel...@tno.nl

Location

 

dprice

unread,
Apr 2, 2020, 10:48:58 AM4/2/20
to topbrai...@googlegroups.com
No - don’t need sh:targetSubjectsOf or sh:targetObjectsOf for the basic case.

Reference the property shape from the NodeShape that has the property as a possible predicate using sh:property. Set the sh:class or sh:datatype in the property shape and the basics are done.

Suggest reading this as it has a lot of good examples and compares RDFS/OWL and SHACL:


Cheers,
David

On 2 Apr 2020, at 15:34, 'Bohms, H.M. (Michel)' via TopBraid Suite Users <topbrai...@googlegroups.com> wrote:

So in the end:
 
 
ex:somepropertyShape1
  a sh:PropertyShape ;
  sh:path ex:someproperty ;
  sh:targetSubjectsOf ex:someproperty ;
  sh:class ex:somedomainclass .
 
ex:somepropertyShape2
  a sh:PropertyShape ;
  sh:path ex:someproperty ;
  sh:targetObjectsOf ex:someproperty ;
  sh:class ex:somerangeclass .
 
the path and target subjectsof feel a bit double...
 
 
 
Dr. ir. H.M. (Michel) Böhms
Senior Data Scientist

Irene Polikoff

unread,
Apr 2, 2020, 10:56:46 AM4/2/20
to topbrai...@googlegroups.com
Further to David’s responses, some more below

On Apr 2, 2020, at 10:06 AM, 'Bohms, H.M. (Michel)' via TopBraid Suite Users <topbrai...@googlegroups.com> wrote:

 
In RDFS:
 
ex:someproperty
  a rdf:Property ;
  rdfs:domain ex:somedomainclass ;
  rdfs:range ex:somerangeclass ;
 
In SHACL:
 
ex:someproperty
  a rdf:Property, sh:PropertyShape ;
  ….?

No. A property is not a property shape

 
Or not possible and need for:
 
ex:somepropertyShape1
  a sh:PropertyShape ;
  sh:targetSubjectsOf ex:someproperty ;
  sh:class ex:somedomainclass .
 
ex:somepropertyShape1
  a sh:PropertyShape ;
  sh:targetObjectsOf ex:someproperty ;
  sh:class ex:somerangeclass .


A property shape must have sh:path

If you were to change the first property shape to

ex:somepropertyShape1
  a sh:PropertyShape ;
   ex:path ex:someproperty ;
  sh:targetSubjectsOf ex:someproperty ;
  sh:class ex:somedomainclass .

You would be saying that for each triple

?s ex:someproperty ?o

There must be a triple

?o a ex:somedomainclass.

Which is not what you want to say.

You would need to either use an inverse path on ex:someproperty - see https://www.w3.org/TR/shacl/#property-path-inverse or, alternatively, use sh:class ex:somerangeclass.

If you make these changes to your property shapes, you will get the validation to ensure the "right values" for the subjects and objects of triples. However, RDFS is not about validation, it is about inferencing. For inferencing you'd need to use SHACL rules.

Since the intention of SHACL constraints is different from the intention of RDFS domain/range, the literal translation (I think) you are trying to accomplish here would be into SHACL rules. On the other hand, if one were to reinterpret RDFS domain/range axioms into constraints, the most common way of doing this would be something like:

ex:somdomainclass a rdfs:Class, sh:NodeShape;
sh:property [sh:path ex:someproperty;
     sh:class ex:somerangeclass].

And, as David mentioned, the common conversion patterns are described at https://spinrdf.org/shacl-and-owl.html. They are also implemented by TopBraid EDG. Conversion will be done automatically - see https://www.topquadrant.com/from-owl-to-shacl-in-an-automated-way/
 
 
 
 
 
Dr. ir. H.M. (Michel) Böhms
Senior Data Scientist

T +31888663107
M +31630381220
michel...@tno.nl
Location

 
<image001.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.
 
 
 
 

Bohms, H.M. (Michel)

unread,
Apr 2, 2020, 11:02:45 AM4/2/20
to topbrai...@googlegroups.com

 

Would I only need the extra property shape complexity in case of the global property constraints like functional etc.?

 

 

 

 

Dr. ir. H.M. (Michel) Böhms
Senior Data Scientist

+31888663107
+31630381220
michel...@tno.nl

Location

 

dprice

unread,
Apr 2, 2020, 11:06:18 AM4/2/20
to topbrai...@googlegroups.com

On 2 Apr 2020, at 16:02, 'Bohms, H.M. (Michel)' via TopBraid Suite Users <topbrai...@googlegroups.com> wrote:

 
Would I only need the extra property shape complexity in case of the global property constraints like functional etc.?

Yes. In general, please read the OWL v SHACL link I gave you and follow whatever that says. That was written exactly to answer these questions.

Cheers,
David

Irene Polikoff

unread,
Apr 2, 2020, 11:08:52 AM4/2/20
to topbrai...@googlegroups.com
As explained in https://spinrdf.org/shacl-and-owl.html, we translate functional into sh:maxCount.

Other than that, they do not introduce anything additional.

On Apr 2, 2020, at 11:02 AM, 'Bohms, H.M. (Michel)' via TopBraid Suite Users <topbrai...@googlegroups.com> wrote:

 
Would I only need the extra property shape complexity in case of the global property constraints like functional etc.?
 
Dr. ir. H.M. (Michel) Böhms
Senior Data Scientist

Bohms, H.M. (Michel)

unread,
Apr 2, 2020, 11:18:58 AM4/2/20
to topbrai...@googlegroups.com

Thx, see in red.

 

 

Van: topbrai...@googlegroups.com <topbrai...@googlegroups.com> Namens Irene Polikoff
Verzonden: Thursday, April 2, 2020 4:57 PM
Aan: topbrai...@googlegroups.com
Onderwerp: Re: [topbraid-users] shacl mapping question for domain/ranges

 

Further to David’s responses, some more below



On Apr 2, 2020, at 10:06 AM, 'Bohms, H.M. (Michel)' via TopBraid Suite Users <topbrai...@googlegroups.com> wrote:

 

 

In RDFS:

 

ex:someproperty

  a rdf:Property ;

  rdfs:domain ex:somedomainclass ;

  rdfs:range ex:somerangeclass ;

 

In SHACL:

 

ex:someproperty

  a rdf:Property, sh:PropertyShape ;

  ….?

 

No. A property is not a property shape

 

> ok, clear!



 

Or not possible and need for:

 

ex:somepropertyShape1

  a sh:PropertyShape ;

  sh:targetSubjectsOf ex:someproperty ;

  sh:class ex:somedomainclass .

 

ex:somepropertyShape1

  a sh:PropertyShape ;

  sh:targetObjectsOf ex:someproperty ;

  sh:class ex:somerangeclass .

 


A property shape must have sh:path

 

If you were to change the first property shape to

 

ex:somepropertyShape1

  a sh:PropertyShape ;

   ex:path ex:someproperty ;

  sh:targetSubjectsOf ex:someproperty ;

  sh:class ex:somedomainclass .

 

> ok

 

You would be saying that for each triple

 

?s ex:someproperty ?o

 

There must be a triple

 

?o a ex:somedomainclass.

 

> I do not get that..... it says: sh:targetSubjectsOf

> so why not: ?s ex:somedomainclass

 

Which is not what you want to say.

 

You would need to either use an inverse path on ex:someproperty - see https://www.w3.org/TR/shacl/#property-path-inverse or, alternatively, use sh:class ex:somerangeclass.

 

If you make these changes to your property shapes, you will get the validation to ensure the "right values" for the subjects and objects of triples. However, RDFS is not about validation, it is about inferencing. For inferencing you'd need to use SHACL rules.

 

Since the intention of SHACL constraints is different from the intention of RDFS domain/range, the literal translation (I think) you are trying to accomplish here would be into SHACL rules. On the other hand, if one were to reinterpret RDFS domain/range axioms into constraints, the most common way of doing this would be something like:

 

ex:somdomainclass a rdfs:Class, sh:NodeShape;

sh:property [sh:path ex:someproperty;

                                     sh:class ex:somerangeclass].

 

> ok, I will do that! Solves also my next issue on unions of classes for domains (for each domain class I willspecify...)

 

And, as David mentioned, the common conversion patterns are described at https://spinrdf.org/shacl-and-owl.html. They are also implemented by TopBraid EDG. Conversion will be done automatically - see https://www.topquadrant.com/from-owl-to-shacl-in-an-automated-way/

 

> Ok, guess the above is only needed in situations like functional etc. that is really for all doamins/ranges etc.

 

 

THx! Michel


 
 
 
 
Dr. ir. H.M. (Michel) Böhms
Senior Data Scientist

T +31888663107
M +31630381220
michel...@tno.nl
Location

 
<image001.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 topbraid-user...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/topbraid-users/ce25c5df596b4406a7311e9f27dfcb34%40tno.nl.

--
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.

Bohms, H.M. (Michel)

unread,
Apr 2, 2020, 11:20:35 AM4/2/20
to topbrai...@googlegroups.com

 

I always use this link indeed but I might have overlooked examples/guides for dealing with rdfs:domain and rdfs:range ...

 

 

 

 

Dr. ir. H.M. (Michel) Böhms
Senior Data Scientist

+31888663107
+31630381220
michel...@tno.nl

Location

 

Bohms, H.M. (Michel)

unread,
Apr 2, 2020, 11:25:39 AM4/2/20
to topbrai...@googlegroups.com

One more

 

Suppose I have a property with ONLY a range specified

 

In that case I do need the PropertyShape right?

 

(since it becomes a universal constraint, not only in he context of some domain classes)

 

 

 

 

 

Dr. ir. H.M. (Michel) Böhms
Senior Data Scientist

+31888663107
+31630381220
michel...@tno.nl

Location

 

Irene Polikoff

unread,
Apr 2, 2020, 11:29:48 AM4/2/20
to topbrai...@googlegroups.com
See below
The target is about resources that are targeted - in this case all ?s in ?s ex:someproperty ?o. 

If you put constraints directly on a Node Shape, you are constraining values of the targeted resources. If you put constraints into a property shape, you are constraining values that can be reached from the targeted resources via the specified path.

You could do

ex:someNodeShape1
  a sh:NodeShape ;

  sh:targetSubjectsOf ex:someproperty ;
  sh:class ex:somedomainclass .

Irene Polikoff

unread,
Apr 2, 2020, 11:40:18 AM4/2/20
to topbrai...@googlegroups.com
Purely from the data validation perspective, yes.

If you, however, you wanted to tell tools that the property should be available for all resources to enter values, you would need to still associate it with something like owl:Thing or rtfs:Resource e.g.,:

ex:Shape1 a sh:NodeShape;
sh:targetClass owl:Thing;
sh:property [sh:path ex:someproperty;
     sh:class ex:somerangeclass].

Or

owl:Thing a sh:NodeShape;
sh:property [sh:path ex:someproperty;
     sh:class ex:somerangeclass].

Even better  if you had your own class for all resources that you are working with.

On Apr 2, 2020, at 11:25 AM, 'Bohms, H.M. (Michel)' via TopBraid Suite Users <topbrai...@googlegroups.com> wrote:

One more
 
Suppose I have a property with ONLY a range specified
 
In that case I do need the PropertyShape right?
 
(since it becomes a universal constraint, not only in he context of some domain classes)
 
 
Dr. ir. H.M. (Michel) Böhms
Senior Data Scientist

Reply all
Reply to author
Forward
0 new messages