Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
417 views
in Technique[技术] by (71.8m points)

rdf - How to Define My Own Ranges for OWL DataProperties

I have recently started learning Web Ontology Language (OWL). I want to define a DataProperty with my own defined range of value. Consider the following property:

  <owl:DatatypeProperty rdf:ID="myProperty">
     <rdfs:domain rdf:resource="#MyDomain"/>
     <rdfs:range rdf:resource="http://www.w3.org/2001/XMLSchema#double"/>
  </owl:DatatypeProperty>

The property has the range of double value but I want to restrict the range in order to make my property to accept only double values between 0 and 1. I would be very grateful if you guide me how to define my own ranges for data properties.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Here you go (in Turtle rather than RDF/XML, for conciseness):

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

I would suggest that you use xsd:decimal instead of xsd:double, because xsd:double is limited in precision and is disjoint from xsd:decimal, which also makes it disjoint from xsd:integer, xsd:int, etc.

UPDATE: in RDF/XML, it corresponds to (look at how messy it is compared to 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>

But if you are writing RDF directly with a text editor, you should really learn to use Turtle. It's much simpler and more concise than RDF/XML. You can really see the triples. And it's going to be a standard soon, the move to W3C Candidate Recommendation is imminent.

**Update October 3rd, 2017: Turtle was standardised in February 2014. If you prefer a notation for RDF based on JSON, there is also JSON-LD, another W3C standard.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...