SHACL NodeShape help

26 views
Skip to first unread message

cbur...@healthwise.org

unread,
Jun 22, 2023, 1:22:24 PM6/22/23
to TopBraid Suite Users
Let's say I have a sh:NodeShape and an accompanying sh:PropertyShape -- call it ex:NodeShape-myProperty. I want to specify that all targets of this property shape must conform to particular pattern -- namely, they must have a particular value for a particular property; i.e., the triple

ex:MyResource ex:requiredProperty ex:RequiredValue

must exist for each object of ex:myProperty. Ideally, I'd want EDG to only display resources that met this pattern as possible objects to be selected in the Editor for ex:myProperty -- not just use the pattern for validation when saving the data.

How do I represent this? Can I do this using just sh:property, or do I need to create another sh:NodeShape to represent the targets of ex:NodeShape-myProperty? What would that look like?

It's a basic enough pattern that I was sure some examples would exist in the TQ SHACL documentation, but I can't find any. Can anyone help? Thanks.

David Price

unread,
Jun 22, 2023, 2:47:36 PM6/22/23
to topbrai...@googlegroups.com
This seems to work. If I make a data graph then instances of Person only show a “Car” instances of Vehicle when setting ownsVehicle. 

@prefix graphql: <http://datashapes.org/graphql#> .
@prefix metadata: <http://topbraid.org/metadata#> .
@prefix teamwork: <http://topbraid.org/teamwork#> .

ex:Car
  a sh:NodeShape ;
  rdfs:label "Car" ;
  sh:property ex:Car-kind ;
  sh:targetObjectsOf ex:vehicleKind ;
.
ex:Car-kind
  a sh:PropertyShape ;
  sh:path ex:vehicleKind ;
  sh:datatype xsd:string ;
  sh:in (
      "Car"
    ) ;
.
ex:Person
  a owl:Class ;
  a sh:NodeShape ;
  rdfs:label "Person" ;
  rdfs:subClassOf owl:Thing ;
  sh:property ex:Person-name ;
  sh:property ex:Person-ownsVehicle ;
.
ex:Person-name
  a sh:PropertyShape ;
  sh:path ex:name ;
  sh:datatype xsd:string ;
  sh:name "name" ;
.
ex:Person-ownsVehicle
  a sh:PropertyShape ;
  sh:path ex:ownsVehicle ;
  sh:class ex:Vehicle ;
  sh:name "owns vehicle" ;
  sh:node ex:Car ;
.
ex:Vehicle
  a owl:Class ;
  a sh:NodeShape ;
  rdfs:label "Vehicle" ;
  rdfs:subClassOf owl:Thing ;
  sh:property ex:Vehicle-tag ;
  sh:property ex:Vehicle-vehicleKind ;
.
ex:Vehicle-tag
  a sh:PropertyShape ;
  sh:path ex:tag ;
  sh:datatype xsd:string ;
  sh:maxCount 1 ;
  sh:name "tag" ;
.
ex:Vehicle-vehicleKind
  a sh:PropertyShape ;
  sh:path ex:vehicleKind ;
  sh:datatype xsd:string ;
  sh:in (
      "Car"
      "Train"
    ) ;
  sh:maxCount 1 ;
  sh:name "vehicle kind" ;
.

Cheers,
David

--
The topics of this mailing list include TopBraid EDG and related technologies such as SHACL.
To post to this group, send email to topbrai...@googlegroups.com
---
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/81724a8d-7694-44a2-84eb-1e40f7f7aa27n%40googlegroups.com.


Carl Burnett

unread,
Jun 22, 2023, 7:35:16 PM6/22/23
to topbrai...@googlegroups.com

Ahhh, this works like a charm! Thank you so much for the insight, David.

Carl

 

From: topbrai...@googlegroups.com <topbrai...@googlegroups.com> On Behalf Of David Price
Sent: Thursday, June 22, 2023 11:47 AM
To: topbrai...@googlegroups.com
Subject: Re: [topbraid-users] SHACL NodeShape help

 

*** 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/FTFYmtYbkCI/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/40E9DD49-06DE-47C5-940D-9A503360FDEE%40topquadrant.com.

Reply all
Reply to author
Forward
0 new messages