使用Jena API读取猫头鹰文件

时间:2016-05-23 18:55:32

标签: java alignment ontology apache-jena

大家好,所以我试图建立一个与Ontologies一致的项目;我正在寻找本体示例,我在PDF文件中找到了这个本体,并想通过在.owl文件中复制粘贴来使用它,但它不会工作 String path="file:E:\\MSIR\\S4\\Jena Library\\PersonA.owl"; Model model = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM); model.read(path);

但它给了我这个错误:

Exception in thread "main" org.apache.jena.riot.RiotException: [line: 6, col: 6 ] The processing instruction target matching "[xX][mM][lL]" is not allowed.

请告诉我该怎么办?我不应该只复制和粘贴本体代码吗?我应该从头开始创建我的本体,我该怎么做? 提前谢谢。

1 个答案:

答案 0 :(得分:1)

您需要将 owl文件放在 src 文件夹中,然后尝试使用此功能:

String path = "src/PersonA.owl" ;
Model model = ModelFactory.createOntologyModel(OntModelSpec.OWL_DL_MEM);
model.read(path);
model.write(System.out) ; // print the owl file to make sure that you did      //read the file