Embedding a path in the parameter of sh:lessThan

53 views Asked by At

Connected to this question (and its previous ones):

Using sh:maxExclusive to compare (the values of) two datatype properties

I created a small ontology with three classes: DataSubject, MemberState, and Minor. There are two datatype properties: has-age and has-minimalage. The former is from DataSubject(s) to integers, the latter is from MemberState(s) to integers. Then there is an object property has-member-state from DataSubject(s) to MemberState(s).

Now we have the following individuals:

ontology:John
  rdf:type ontology:DataSubject ;
  ontology:has-age "20"^^xsd:positiveInteger ;
  ontology:has-member-state ontology:Spain ;
.
ontology:Spain
  rdf:type ontology:MemberState ;
  ontology:has-minimalage "16"^^xsd:positiveInteger ;
.

And I want to write a SHACL rule saying that each DataSubject whose age is less than the minimal age of his member state is also an individual of the class Minor.

In light of the replies I got to my other questions, I tried:

  sh:rule [
      rdf:type sh:TripleRule ;
      sh:condition [
        sh:property [
          sh:path ontology:has-age ;
          sh:lessThan (ontology:has-member-state ontology:has-minimalage)
        ] ;
      ] ;
      sh:subject sh:this ;
      sh:predicate rdf:type;
      sh:object ontology:Minor ;
  ] ;

Which does not work: it classifies John as Minor, but 20 is not less than 16. Of course I tried many other variants, e.g., "sh:lessThan[sh:node[sh:path (ontology:has-member-state ontology:has-minimalage)];];", many of which do not probably make any sense, but none of them work.

Can someone suggest me how to embed a path in the parameter of sh:lessThan?

I am sorry if I start being annoying with all these questions :-( I am new to SHACL and SPARQL but I am really trying my best to learn them out of all what I can find on the Web.

Thanks Livio

1

There are 1 answers

1
Holger Knublauch On

The official spec is (hopefully) pretty clear that the values must be IRIs, i.e. only direct properties are permitted. You can however try to revert the logic and use a path at the property shape. Otherwise, fall back to SPARQL.