2014-07-02 41 views
3

我使用Protege在OWL中添加了一些新的DataType。在數據類型屬性的Protege中定義DataRange表達式

數據類型就像是個和我想指定它的範圍與雙值範圍從0到100

同樣名爲質量數據類型,我想指定它的範圍與雙值範圍爲0〜 1.

我們如何在數據範圍表達式中指定這些東西?

我試圖找出,但我發現兩個鏈接,但在我的上下文中沒有用。

  1. How to Define My Own Ranges for OWL DataProperties如果我們手動創建OWL文件,而不是使用門生這是非常有用的。

  2. http://answers.semanticweb.com/questions/16541/datatype-property-protege當我們沒有添加新數據類型的選項時,這與上下文有關。

請幫忙如何編寫這些場景的數據範圍的表達門徒

場景: enter image description here

回答

7

這只是xsd:double[ >= 0, <= 0 ]

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 . 
+0

儘管這不是這個問題的一部分,如果我們定義的任何數據對象作爲對自定義數據類型的類型,也可對其進行驗證,我們有範圍給定? – Gaurav

+0

數據類型實際上是double,但minInclusive和maxInclusive的數據類型是整數。不應該有兩倍?我們是否需要像double [> = 0.00,<= 100.00]一樣定義? – Gaurav

+0

哦,這是一個很好的觀點。我不知道如何完成從整數到雙打的轉換。使用'double [> = 0.0,<= 0.0]'可能更安全。一些reasoners會做數據類型推理。例如,如果你聲明'x hasPercentage 101.0',Pellet會說它不一致。 –

0

此信息可能是幫助那些想獨立的整數(或任何數據類型)賦值爲數據類型屬性的範圍誰。在數據範圍表達式編輯器鍵入以下代碼:

{"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} 
相關問題