I created ontology in protege. I have some dataTypeProperties of which ranges are set as integer, dateTime and string.
In my java application i am using Jena api to write onto owl files, i am handling dataTypeProperties with this single method.:
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();
}
}
After writing to owl file, it looks like this:
....
<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>
....
The problem is that now if I open my owl file in protege and run reasoner (Fact++), it popups errors as below:
All the errors shown by reasoner are of properties having ranges of integer or dataTime datatypes. Properties with ranges gives no error.
Can someone points out the reason of the errors?
I am pretty sure that the problem is that you are using this single function public void setDataTypeProperty()
for writing strings, integers, and dateTime. Your function writes all values as plain literal. you should check TypedLiterals
In jena try model.createTypedLiteral(arg0)