如何为OWL DataProperties定义自己的范围

Elt*_*.fd 3 rdf owl rdfs

我最近开始学习Web Ontology Language(OWL).我想用我自己定义的值范围定义DataProperty.考虑以下属性:

  <owl:DatatypeProperty rdf:ID="myProperty">
     <rdfs:domain rdf:resource="#MyDomain"/>
     <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#double"/>
  </owl:DatatypeProperty>
Run Code Online (Sandbox Code Playgroud)

该属性具有double值的范围,但我想限制范围,以使我的属性只接受介于0和1之间的双精度值.如果您指导我如何定义我自己的数据属性范围,我将非常感激.

Ant*_*ann 12

在这里你去(在Turtle中而不是RDF/XML,为了简洁):

:myProperty  a  owl:DatatypeProperty;
    rdfs:domain  :MyDomain;
    rdfs:range  [
        a  rdfs:Datatype;
        owl:onDatatype  xsd:double;
        owl:withRestrictions ( [xsd:minInclusive 0] [xsd:maxInclusive 1] )
    ] .
Run Code Online (Sandbox Code Playgroud)

我建议你使用xsd:decimal的不是xsd:double,因为xsd:double是在精度有限,是不相交的xsd:decimal,这也使得它脱节xsd:integer,xsd:int等等.

更新:在RDF/XML中,它对应于(看看它与Turtle相比有多乱):

<owl:DatatypeProperty rdf:about="#myProperty">
    <rdfs:domain rdf:resource="#MyDomain"/>
    <rdfs:range>
        <rdfs:Datatype>
            <owl:onDatatype rdf:resource="&xsd;double"/>
            <owl:withRestrictions rdf:parseType="Collection">
                <rdf:Description>
                    <xsd:minInclusive rdf:datatype="&xsd;double">0</xsd:minInclusive>
                </rdf:Description>
                <rdf:Description>
                    <xsd:maxInclusive rdf:datatype="&xsd;double">1</xsd:maxInclusive>
                <rdf:Description>
                </rdf:Description>
            </owl:withRestrictions>
        </rdfs:Datatype>
    </rdfs:range>
</owl:DatatypeProperty>
Run Code Online (Sandbox Code Playgroud)

但是如果你直接用文本编辑器编写RDF,你应该学会使用Turtle.它比RDF/XML更简单,更简洁.你真的可以看到三元组.而且很快就会成为标准,转向W3C候选推荐标准即将来临.

**2017年10月3日更新:Turtle于2014年2月标准化.如果您更喜欢基于JSON的RDF表示法,还有JSON-LD,这是另一个W3C标准.