例如,我需要描述一只1岁到4岁之间的狗,如何限制属性的取值范围?属性数量有 minCardinality 和 maxCardinality。但不适合我的例子。
<xs:element name="age">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:minInclusive value="1"/>
<xs:maxInclusive value="4"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
举个具体的例子,如何将上面的xsd翻译成owl?
您可以直接将合格的基数限制定义为本地类限制。例如,要定义阿米巴原虫的年龄范围为 1 到 4,请使用以下命令:
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="http://example.org/things#age"/>
<owl:maxQualifiedCardinality rdf:datatype="xs:nonNegativeInteger">4</owl:maxQualifiedCardinality>
<owl:onDataRange rdf:resource="http://example.org/things#Amoeba"/>
</owl:Restriction>
</rdfs:subClassOf>
<rdfs:subClassOf>
<owl:Restriction>
<owl:onProperty rdf:resource="http://example.org/things#age"/>
<owl:minQualifiedCardinality rdf:datatype="xs:nonNegativeInteger">1</owl:minQualifiedCardinality>
<owl:onDataRange rdf:resource="http://example.org/things#Amoeba"/>
</owl:Restriction>
</rdfs:subClassOf>
这有点难以阅读。等效的 Turtle 序列化更容易阅读和管理(注意三元组的直接表示。JSON-LD 是 RDF 的另一种易于使用的文本序列化):
rdfs:subClassOf [
rdf:type owl:Restriction ;
owl:maxQualifiedCardinality "4"^^xs:nonNegativeInteger ;
owl:onDataRange ex:Amoeba ;
owl:onProperty ex:age ;
] ;
rdfs:subClassOf [
rdf:type owl:Restriction ;
owl:minQualifiedCardinality "1"^^xs:nonNegativeInteger ;
owl:onDataRange ex:Amoeba ;
owl:onProperty ex:age ;
] ;
您可以使用 xsd:minInclusive 和 xsd:maxInclusive
<owl:Class rdf:ID="dog">
<owl:Restriction>
<owl:onProperty rdf:resource="#age"/>
<owl:withRestrictions>
<xsd:minInclusive rdf:datatype="&xsd;integer">1</xsd:minInclusive>
<xsd:maxInclusive rdf:datatype="&xsd;integer">4</xsd:maxInclusive>
</owl:withRestrictions>
</owl:Restriction>
</owl:Class>