Owl 我不能将sh:lessThan与xsd:positiveInteger一起使用

Owl 我不能将sh:lessThan与xsd:positiveInteger一起使用,owl,ontology,semantic-web,shacl,topbraid-composer,Owl,Ontology,Semantic Web,Shacl,Topbraid Composer,我有以下小型本体,有两个类(“DataSubject”和“Minor”),一个属性的年龄从DataSubject到xsd:positiveInteger,还有一个个体(“John”,他是DataSubject,年龄等于20岁) 以下SHACL规则应将年龄低于16岁的所有数据主体标记为未成年人 rules:WhenDataSubjectIsMinor rdf:type sh:NodeShape ; sh:rule [ rdf:type sh:TripleRule ;

我有以下小型本体,有两个类(“DataSubject”和“Minor”),一个属性的年龄从DataSubject到xsd:positiveInteger,还有一个个体(“John”,他是DataSubject,年龄等于20岁)

以下SHACL规则应将年龄低于16岁的所有数据主体标记为未成年人

rules:WhenDataSubjectIsMinor
  rdf:type sh:NodeShape ;
  sh:rule [
      rdf:type sh:TripleRule ;
      #IF: "the age of the Data Subject is lower than 16"
      sh:condition [
        sh:property [
          sh:path ontology:has-age;
          sh:lessThan "16"^^xsd:positiveInteger ;
        ] ;
      ] ;
      #THEN: "the Data Subject is marked as type Minor"
      sh:subject sh:this ;
      sh:predicate rdf:type;
      sh:object ontology:Minor ;
  ] ;
  sh:targetClass ontology:DataSubject ;
.
但是,下面的Java代码推断John是未成年人。。。但是约翰不是,他20岁了!当然,规则是不正确的,特别是指令“sh:lessThan”16^^xsd:positiveInteger;”

如何将数据类型属性与给定常量进行比较

提前谢谢

利维奥


sh:lessThan用于建立两种财产之间的关系,例如出生日期sh:lessThan结婚日期。你需要的是sh:maxExclusive

有关详细信息,请参见SHACL规范,例如

非常感谢!:-)现在我不清楚如何使用sh:lessThan,除非我们可以定义一些“内部方法”来比较类,类似于在Java中使用可比较的接口所做的,但是我将研究:-)再次感谢!利维奥
rules:WhenDataSubjectIsMinor
  rdf:type sh:NodeShape ;
  sh:rule [
      rdf:type sh:TripleRule ;
      #IF: "the age of the Data Subject is lower than 16"
      sh:condition [
        sh:property [
          sh:path ontology:has-age;
          sh:lessThan "16"^^xsd:positiveInteger ;
        ] ;
      ] ;
      #THEN: "the Data Subject is marked as type Minor"
      sh:subject sh:this ;
      sh:predicate rdf:type;
      sh:object ontology:Minor ;
  ] ;
  sh:targetClass ontology:DataSubject ;
.
    public static void main(String[] args) throws Exception
    {
            //Load the ontology
        Model ontology = JenaUtil.createMemoryModel();
        FileInputStream fisOntology = new FileInputStream("./ontology.ttl");
        ontology.read(fisOntology, "urn:dummy", FileUtils.langTurtle);
        
            //Load the rules
        Model rules = JenaUtil.createMemoryModel();
        FileInputStream fisRules = new FileInputStream("./rules.ttl");
        rules.read(fisRules, "urn:dummy", FileUtils.langTurtle);
        
            //Executing the rule and print
        Model inferredTriples = RuleUtil.executeRules(ontology, rules, null, null);
        System.out.println(ModelPrinter.get().print(inferredTriples));
    }