2017-04-25 75 views
1

我需要實現這樣的OWL格式:耶拿OWL/RDF函數型

<owl:DatatypeProperty rdf:ID="Role-description"> <rdfs:range 
rdf:resource="http://www.w3.org/2001/XMLSchema#string"/> 
<rdfs:domain rdf:resource="#Role"/> 
<rdf:type rdf:resource="http://www.w3.org/2002/07/owl#FunctionalProperty"/> 

我使用的耶拿,當我嘗試下一步:

DatatypeProperty datatypeProperty = ontModel.createDatatypeProperty(OWL.NS + "Role-description"); 
datatypeProperty.addRDFType(OWL.FunctionalProperty); 
datatypeProperty.asDatatypeProperty(); 

獲取所有老虎鉗一個反之亦然。

<rdf:RDF 
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
    xmlns:owl="http://www.w3.org/2002/07/owl#" 
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> 
    <owl:Class rdf:about="http://www.w3.org/2002/07/owl#Task"/> 
    <owl:Class rdf:about="http://www.w3.org/2002/07/owl#Actor"/> 
    <owl:ObjectProperty rdf:about="http://www.w3.org/2002/07/owl#Task-performedBy-Actor"/> 
    <owl:ObjectProperty rdf:about="http://www.w3.org/2002/07/owl#Actor-performs-Task"/> 
    <owl:FunctionalProperty rdf:about="http://www.w3.org/2002/07/owl#Role-description"> 
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#DatatypeProperty"/> 
    </owl:FunctionalProperty> 
</rdf:RDF> 

歡迎任何建議

+0

我不明白WH YIT公司重要的數據是如何序列。語義應該是相同的,任何正確的解析器都會從中得到完全正確的信息。在OWL的序列化中沒有排序,因爲OWL本體由一組OWL公理構成OWL公理 – AKSW

+0

@AKSW我經常看到類似的「需求」,通常是由於過度指定的請求或分配而導致的。通常是與非RDF或非OWL工具鏈交互的結果。 – Ignazio

回答

2

你所得到的輸出不是反之亦然。你基本上擁有的是多種類型的RDF資源。這取決於耶拿如何序列化它們(即哪一個被認爲是「主要」)。爲了說明這一點,我將連載你的榜樣海龜(略作修改使用自定義命名空間):

@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> . 
@prefix owl: <http://www.w3.org/2002/07/owl#> . 
@prefix roles: <http://example.com/ns/roles#> . 
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> . 
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . 

roles:Role-description 
     a  owl:DatatypeProperty , owl:FunctionalProperty . 

現在,這裏是你怎麼能操縱類型的一個方便的序列化的順序:

public static final String ROLES_NS = "http://example.com/ns/roles#"; 

public static void main(String[] args) { 
    OntModel ontModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM); 
    ontModel.setNsPrefix("roles", ROLES_NS); 

    DatatypeProperty prop = ontModel.createDatatypeProperty(
      ROLES_NS + "Role-description"); 
    prop.setRDFType(OWL.FunctionalProperty); 
    prop.addRDFType(OWL.DatatypeProperty); 

    RDFDataMgr.write(System.out, ontModel, RDFFormat.RDFXML_PRETTY); 
} 

它產生以下輸出:

<rdf:RDF 
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" 
    xmlns:owl="http://www.w3.org/2002/07/owl#" 
    xmlns:roles="http://example.com/ns/roles#" 
    xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" 
    xmlns:xsd="http://www.w3.org/2001/XMLSchema#"> 
    <owl:DatatypeProperty rdf:about="http://example.com/ns/roles#Role-description"> 
    <rdf:type rdf:resource="http://www.w3.org/2002/07/owl#FunctionalProperty"/> 
    </owl:DatatypeProperty> 
</rdf:RDF> 
+0

非常感謝,謝謝! – Svitlana