问题
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.
How to Define My Own Ranges for OWL DataProperties This is useful if we are manually creating the OWL file and not using Protege.
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:
回答1:
It's just xsd:double[ >= 0, <= 0 ]
.
<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 .
回答2:
This post might be helpful to those who would like to assign discrete integer (or any data type) values as the range of the data type property. Type the following code in the data range expression editor:
{"0"^^xsd:int , "1"^^xsd:int , "10"^^xsd:int , "18"^^xsd:int , "2"^^xsd:int , "3"^^xsd:int , "4"^^xsd:int , "5"^^xsd:int , "6"^^xsd:int , "8"^^xsd:int}
来源:https://stackoverflow.com/questions/24531940/defining-datarange-expression-in-protege-for-a-data-type-property