Jena Riot加载有效的乌龟文件时出现异常

时间:2017-10-17 09:16:04

标签: jena

我有一个位于here的海龟文件。我已使用this toolhttp://ttl.summerofcode.be/)对其进行了验证,并说乌龟文件有效。但是当使用带有RDFDataMgr.loadModel("https://raw.githubusercontent.com/noorbakerally/ISWC2017Demo/master/ParisGeo.ttl");的Jena加载它时,我收到以下错误,

Exception in thread "main" org.apache.jena.riot.RiotException: [line: 1, col: 1 ] Expected BNode or IRI: Got: [DIRECTIVE:prefix]
    at org.apache.jena.riot.system.ErrorHandlerFactory$ErrorHandlerStd.fatal(ErrorHandlerFactory.java:136)
    at org.apache.jena.riot.lang.LangEngine.raiseException(LangEngine.java:148)
    at org.apache.jena.riot.lang.LangEngine.exceptionDirect(LangEngine.java:143)
    at org.apache.jena.riot.lang.LangEngine.exception(LangEngine.java:137)
    at org.apache.jena.riot.lang.LangNTuple.checkIRIOrBNode(LangNTuple.java:89)
    at org.apache.jena.riot.lang.LangNTriples.parseOne(LangNTriples.java:74)
    at org.apache.jena.riot.lang.LangNTriples.runParser(LangNTriples.java:53)
    at org.apache.jena.riot.lang.LangBase.parse(LangBase.java:41)
    at org.apache.jena.riot.RDFParserRegistry$ReaderRIOTLang.read(RDFParserRegistry.java:194)
    at org.apache.jena.riot.RDFParser.read(RDFParser.java:293)
    at org.apache.jena.riot.RDFParser.parseNotUri(RDFParser.java:283)
    at org.apache.jena.riot.RDFParser.parse(RDFParser.java:233)
    at org.apache.jena.riot.RDFParserBuilder.parse(RDFParserBuilder.java:405)
    at org.apache.jena.riot.RDFDataMgr.process(RDFDataMgr.java:862)
    at org.apache.jena.riot.RDFDataMgr.parse(RDFDataMgr.java:676)
    at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:222)
    at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:103)
    at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:94)
    at org.apache.jena.riot.RDFDataMgr.loadModel(RDFDataMgr.java:336)
    at fr.emse.opensensingcity.main.main(main.java:41)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:498)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

1 个答案:

答案 0 :(得分:1)

该链接返回带有" text / plain"的HTTP标头。使用MIME类型声明,而不是文件扩展名。

您可以通过使用RDFParser生成已配置的Parer来强制语法。

http://jena.apache.org/documentation/io/rdf-input.html#example-3-using-rdfparser

或者在Java中打开一个URL流并使用RDFDataMgr

从命令行riot --syntax TTL ...