sh:or vs sh:xone

18 views
Skip to first unread message

Maatary Okouya

unread,
Jun 24, 2021, 4:27:56 AM6/24/21
to TopBraid Suite Users
Hi,

I am trying  to double check some modeling use of sh:or/sh:xone my team and I have done so far. It will greatly help me wrap my head around the meanings of disjunction in shacl. 



We need to express the following: 

  • A Cell Expression (reified relation) is between either ( exclusively) a CellType and a Complex, (x)or an Organ and Virus, (x)or an Organ and a FunctionalClass and so on. 

  • Another way to look at it is your graph can have CellType - cellexpression -> Complex | Organ - cellExpression -> Virus | .....


The way we have modeled that is with an sh:xone as in what follows: 


resnet:CellExpression
  rdf:type owl:Class ;
  rdf:type sh:NodeShape ;
  rdfs:label "CellExpression" ;
  rdfs:subClassOf owl:Thing ;
  sh:xone (
      [
        sh:property [
            sh:path resnet:regulator ;
            sh:NodeKind sh:IRI ;
            sh:class resnet:CellType ;
            sh:maxCount 1 ;
            sh:minCount 1 ;
          ] ;
        sh:property [
            sh:path resnet:target ;
            sh:NodeKind sh:IRI ;
            sh:class resnet:Complex ;
            sh:maxCount 1 ;
            sh:minCount 1 ;
          ] ;
      ]
      [
        sh:property [
            sh:path resnet:regulator ;
            sh:NodeKind sh:IRI ;
            sh:class resnet:Organ ;
            sh:maxCount 1 ;
            sh:minCount 1 ;
          ] ;
        sh:property [
            sh:path resnet:target ;
            sh:NodeKind sh:IRI ;
            sh:class resnet:Virus ;
            sh:maxCount 1 ;
            sh:minCount 1 ;
          ] ;
      ]
      [
        sh:property [
            sh:path resnet:regulator ;
            sh:NodeKind sh:IRI ;
            sh:class resnet:Organ ;
            sh:maxCount 1 ;
            sh:minCount 1 ;
          ] ;
        sh:property [
            sh:path resnet:target ;
            sh:NodeKind sh:IRI ;
            sh:class resnet:FunctionalClass ;
            sh:maxCount 1 ;
            sh:minCount 1 ;
          ]
      ]
  );
.


However  based on conversation and read I have had here and there (in particular with Hogler)  on sh:or , i'm thinking maybe the sh:xor is actually not necessary here, and simply using

sh:or would be best. Indeed as soon as one of the alternative works, it should only be that one if more properties are added, none of the alternative should pass. 

hence we could express it as such: 

resnet:CellExpression
  rdf:type owl:Class ;
  rdf:type sh:NodeShape ;
  rdfs:label "CellExpression" ;
  rdfs:subClassOf owl:Thing ;
  sh:or (
      [
        sh:property [
            sh:path resnet:regulator ;
            sh:NodeKind sh:IRI ;
            sh:class resnet:CellType ;
            sh:maxCount 1 ;
            sh:minCount 1 ;
          ] ;
        sh:property [
            sh:path resnet:target ;
            sh:NodeKind sh:IRI ;
            sh:class resnet:Complex ;
            sh:maxCount 1 ;
            sh:minCount 1 ;
          ] ;
      ]
      [
        sh:property [
            sh:path resnet:regulator ;
            sh:NodeKind sh:IRI ;
            sh:class resnet:Organ ;
            sh:maxCount 1 ;
            sh:minCount 1 ;
          ] ;
        sh:property [
            sh:path resnet:target ;
            sh:NodeKind sh:IRI ;
            sh:class resnet:Virus ;
            sh:maxCount 1 ;
            sh:minCount 1 ;
          ] ;
      ]
      [
        sh:property [
            sh:path resnet:regulator ;
            sh:NodeKind sh:IRI ;
            sh:class resnet:Organ ;
            sh:maxCount 1 ;
            sh:minCount 1 ;
          ] ;
        sh:property [
            sh:path resnet:target ;
            sh:NodeKind sh:IRI ;
            sh:class resnet:FunctionalClass ;
            sh:maxCount 1 ;
            sh:minCount 1 ;
          ]
      ]
  );
.

Apologies for no specific formatting for the code, i could not. find a button to format code

Kind regards, 

-M-

Irene Polikoff

unread,
Jun 24, 2021, 7:43:05 AM6/24/21
to topbrai...@googlegroups.com
Because you can only have one value for each property, I think the following will work:

resnet:CellExpression
  rdf:type owl:Class ;
  rdf:type sh:NodeShape ;
  rdfs:label "CellExpression" ;
  rdfs:subClassOf owl:Thing ;
  sh:property [
            sh:path resnet:target ;
            sh:NodeKind sh:IRI ;
            sh:maxCount 1 ;
            sh:minCount 1 ;
          ] ;
  sh:property [
            sh:path resnet:regulator ;
            sh:NodeKind sh:IRI 
            sh:maxCount 1 ;
            sh:minCount 1 ;
          ] ;
  sh:or (
      [
        sh:property [
            sh:path resnet:regulator;
            sh:class resnet:CellType ;
          ] ;
        sh:property [
            sh:path resnet:target ;
            sh:class resnet:Complex ;
          ] ;
      ]
      [
        sh:property [
            sh:path resnet:regulator ;
            sh:class resnet:Organ 
          ] ;
        sh:property [
            sh:path resnet:target ;
            sh:class resnet:Virus ;
          ] ;
      ]
      [
        sh:property [
            sh:path resnet:regulator ;
            sh:class resnet:Organ ;
          ] ;
        sh:property [
            sh:path resnet:target ;
            sh:class resnet:FunctionalClass ;
          ]
      ]
  );
.

--
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/438295bc-5787-4e0e-a062-27750069386en%40googlegroups.com.

Maatary Okouya

unread,
Jun 28, 2021, 4:14:21 AM6/28/21
to TopBraid Suite Users
Understood thank you
Reply all
Reply to author
Forward
0 new messages