2

大家好,我正在尝试构建一个与本体一致的项目;我正在搜索本体示例,我在 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.

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

4

1 回答 1

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
于 2016-11-14T12:26:35.430 回答