2012-05-14 21 views
0

我有一個貓頭鷹本體,其中有一個DatatypeProperty「hasAge」 誰能告訴我爲什麼這個代碼返回空值?我應該如何在Jena中使用getDatatypeProperty(String PropertyName)?

String URI = "http://owldl.com/ontologies/dl-safe.owl" 
DatatypeProperty data = model.getDatatypeProperty(URI+"hasAge") 

data is null! 雖然該行退出的貓頭鷹文件:

<!-- http://owldl.com/ontologies/dl-safe.owl#hasAge --> 
<owl:DatatypeProperty rdf:about="&dl-safe;hasAge"/> 

這個本體工作只是ObjectProperties罰款。但是,它似乎不適用於數據類型屬性

回答

2

您錯過了#那裏。

URI+"hasAge"將是:

http://owldl.com/ontologies/dl-safe.owlhasAge 

但作爲註釋表明,該屬性的URI是:

http://owldl.com/ontologies/dl-safe.owl#hasAge 

它因此改爲:

String URI = "http://owldl.com/ontologies/dl-safe.owl#"; 
相關問題