Defining DataRange Expression in Protege for a Data Type Property

Gaurav picture Gaurav · Jul 2, 2014 · Viewed 10.1k times · Source

I am adding few new DataType in the OWL using Protege.

The DataType is like percentage and I want to specify it's range with the double value ranging from 0 to 100.

Similarly a DataType named Quality and I want to specify it's range with the double value ranging from 0 to 1.

How can we specify these things in the Data range Expression ?

I tried to find out but I found two links but not useful in my context.

  1. How to Define My Own Ranges for OWL DataProperties This is useful if we are manually creating the OWL file and not using Protege.

  2. http://answers.semanticweb.com/questions/16541/datatype-property-protege This is related to the context when we don't have the option of adding the new data type.

Please help how to write the Data range expression for these scenario in Protege

Scenario: enter image description here

Answer

Joshua Taylor picture Joshua Taylor · Jul 2, 2014

It's just xsd:double[ >= 0, <= 100 ].

screenshot

<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:owl="http://www.w3.org/2002/07/owl#"
    xmlns="http://stackoverflow.com/q/24531940/1281433/percentages#"
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#">
  <owl:Ontology rdf:about="http://stackoverflow.com/q/24531940/1281433/percentages"/>
  <owl:DatatypeProperty rdf:about="http://stackoverflow.com/q/24531940/1281433/percentages#hasPercentage">
    <rdfs:range>
      <rdfs:Datatype>
        <owl:onDatatype rdf:resource="http://www.w3.org/2001/XMLSchema#double"/>
        <owl:withRestrictions rdf:parseType="Collection">
          <rdf:Description>
            <xsd:minInclusive rdf:datatype="http://www.w3.org/2001/XMLSchema#integer"
            >0</xsd:minInclusive>
          </rdf:Description>
          <rdf:Description>
            <xsd:maxInclusive rdf:datatype="http://www.w3.org/2001/XMLSchema#integer"
            >100</xsd:maxInclusive>
          </rdf:Description>
        </owl:withRestrictions>
      </rdfs:Datatype>
    </rdfs:range>
  </owl:DatatypeProperty>
</rdf:RDF>
@prefix :      <http://stackoverflow.com/q/24531940/1281433/percentages#> .
@prefix owl:   <http://www.w3.org/2002/07/owl#> .
@prefix rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix xsd:   <http://www.w3.org/2001/XMLSchema#> .
@prefix rdfs:  <http://www.w3.org/2000/01/rdf-schema#> .

:hasPercentage  a   owl:DatatypeProperty ;
        rdfs:range  [ a                     rdfs:Datatype ;
                      owl:onDatatype        xsd:double ;
                      owl:withRestrictions  ( [ xsd:minInclusive
                                        0 ] [ xsd:maxInclusive  100 ] )
                    ] .

<http://stackoverflow.com/q/24531940/1281433/percentages>
        a       owl:Ontology .