KnowWhereGraph / KWG-SHACL

This is the repository of SHACL shapes development/research for KWG.
1 stars 1 forks source link

Lessons of using sh:or #10

Open zhurui0509 opened 2 years ago

zhurui0509 commented 2 years ago

There are several ways of using sh:or in our shapes, the main two are:

  1. sh:or (
        sh:property [
            rdfs:comment "An Observation has to have at least one phenomenon time or result time."@en ;
            sh:path sosa:phenomenonTime ;
        sh:minCount 1 ; 
            ] 
    
        sh:property [
            rdfs:comment "An Observation has to have at least one phenomenon time or result time."@en ;
            sh:path sosa:resultTime ;
            sh:minCount 1 ;
            ]    
    ) ;
  2.  sh:or  (    
            [
            sh:path sosa:phenomenonTime ;
            sh:minCount 1 ;
            ] 
            [
            sh:path sosa:resultTime ;
            sh:minCount 1 ;
            ]          
     ) ;

I believe the correct way is 2 based on SHACL documentation. I tested it both using (1). GraphDB, (2). SHACL Playground, and (3). pyshacl. the 2 works for both (1) and (2). It does not work for pyshacl (i.e., need to have both, so it is like sh:and) probably because their implementation is not correct (has to deeply check and create an issue for them if so).

The 1 is also tested on (1), (2), and (3), none works.

So I removed sh:or from ObservationConstraint, and updated a TimeConstraint.ttl (for the sake of adding a rdfs:comment). It can then be applied to both Observation and ObservationCollection.