我正在尝试创建一个新的本体,并在一些操作后保存它。它创建得很好,我在处理类和其他事情时没有问题,但是当我尝试将它保存到本地文件时给了我一个错误!我的代码是:
//create a new ontology
SOURCE = "http://www.w3.org/2002/07/owl#";
NS = SOURCE + "#";
ontology = ModelFactory.createOntologyModel();
ontology.read( SOURCE, "RDF/XML" );
///////some actions
//save the ontology
try {
File file= new File("Log.owl");
ontology.write(new FileOutputStream(file));
}
catch (IOException e) {
e.printStackTrace();
}
错误是:
Exception in thread "main" com.hp.hpl.jena.shared.BadURIException: Only well-formed absolute URIrefs can be included in RDF/XML output: <d> Code: 57/REQUIRED_COMPONENT_MISSING in SCHEME: A component that is required by the scheme is missing.
at com.hp.hpl.jena.xmloutput.impl.BaseXMLWriter.checkURI(BaseXMLWriter.java:829)
at com.hp.hpl.jena.xmloutput.impl.BaseXMLWriter.xmlnsDecl(BaseXMLWriter.java:348)
at com.hp.hpl.jena.xmloutput.impl.Basic.writeRDFHeader(Basic.java:56)
at com.hp.hpl.jena.xmloutput.impl.Basic.writeBody(Basic.java:39)
at com.hp.hpl.jena.xmloutput.impl.BaseXMLWriter.writeXMLBody(BaseXMLWriter.java:500)
at com.hp.hpl.jena.xmloutput.impl.BaseXMLWriter.write(BaseXMLWriter.java:472)
at com.hp.hpl.jena.xmloutput.impl.BaseXMLWriter.write(BaseXMLWriter.java:458)
at com.hp.hpl.jena.rdf.model.impl.ModelCom.write(ModelCom.java:271)
at com.hp.hpl.jena.ontology.impl.OntModelImpl.write(OntModelImpl.java:2552)
我知道“http://www.w3.org/2002/07/owl#”的格式是 TURTLE,但我想在 RDF/XML 中有本体,我不知道该写什么而不是该链接。我尝试了不同的链接,但每次它都给了我另一个错误。SOURCE 应该是一个真正的链接吗?
感谢您的回复!