1

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

  • According to the doc: *"The values of sh:lessThan in a shape are IRIs. "* - so I doubt a property path is possible (I might be wrong). But, why are you not trying a SPARQL query constraint if SHACL is too complicated or maybe limited? – UninformedUser Sep 29 '20 at 14:39
  • Thank you. I hope there is a way, otherwise, yes, I will try SPARQL. Indeed, I would like to only use SHACL, if possible. – Livio Robaldo Sep 29 '20 at 17:32

1 Answers1

0

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.

Holger Knublauch
  • 1,176
  • 5
  • 4
  • Thank you! Yes, the spec are clear. I was wondering whether there was a way to cast a path into an IRI. But I understood there is not. An idea for the next versions of SHACL maybe :-) Thanks a lot again for all your kind replies! Livio – Livio Robaldo Sep 30 '20 at 07:02