【发布时间】:2014-09-18 02:59:34
【问题描述】:
我在 protege 中创建了本体。我有一些 dataTypeProperties,其范围设置为整数、日期时间和字符串。
在我的 java 应用程序中,我使用 Jena api 写入 owl 文件,我正在使用这种单一方法处理 dataTypeProperties。:
public void setDataTypeProperty(String resourceURI, String propertyName, String propertyValue)
{
if (resourceURI==null)
return;
Model model = ModelFactory.createDefaultModel();
//read model from file
InputStream in = FileManager.get().open(inputFileName);
if (in == null)
{
throw new IllegalArgumentException( "File: " + inputFileName + " not found");
}
model.read(in, "");
try {
in.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// Add property to Model
Resource resource = model.createResource(resourceURI);
resource.addProperty(model.createProperty(baseURI+propertyName), model.createLiteral(propertyValue));
//Writing model to file
try {
FileWriter out = new FileWriter( inputFileName );
model.write( out, "RDF/XML-ABBREV" );
out.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
写入 owl 文件后,如下所示:
....
<File rdf:about="http://www.semanticweb.org/administrator/ontologies/2014/2/untitled-ontology-5#677f5c75-7527-45e2-8430-829466027034">
<filePeakLocation>ismaila swabi</filePeakLocation> //String Datatype
<filePeakDay>6</filePeakDay> //Integer Datatype
<fileLastAccessed>2014-07-26T13:17:49</fileLastAccessed> //dateTime
<created>2014-07-26T13:17:27</created> //dateTime
<hasPath>/examples/run.sh</hasPath> //String Datatype
<fileAccessedLocation>ismaila swabi_atTime_2014-07-26T13:17:49</fileAccessedLocation>
<filePeakHour>13</filePeakHour> //Integer
</File>
....
问题是,现在如果我在 protege 中打开我的 owl 文件并运行 reasoner (Fact++),它会弹出如下错误:
reasoner 显示的所有错误都是具有整数或 dataTime 数据类型范围的属性。具有范围的属性不会出错。
有人能指出错误的原因吗?
【问题讨论】:
标签: rdf jena owl ontology protege