我正在使用Jena导入skos词库,但它不起作用

时间:2012-12-29 09:17:39

标签: xml rdf jena

  

可能重复:
  org.xml.sax.SAXParseException: Content is not allowed in prolog

我想在Jena模型中导入一个skos(rdf / xml)同义词库。 skos同义词库可在http://www.culturaitalia.it/pico/thesaurus/4.2/thesaurus_4.2.0.skos.xml中找到。我将其复制到本地文件(在picoFileName中),我使用此代码将其导入模型中:

    ...
    pico = ModelFactory.createDefaultModel();
    InputStream in = FileManager.get().open(picoFileName);
    if (in == null) {
        throw new IllegalArgumentException( "File: " + picoFileName + " not found");
    }
    pico.read(new InputStreamReader(in), "");
    ... 

我收到此错误:

Exception in thread "main" com.hp.hpl.jena.shared.JenaException:   org.xml.sax.SAXParseException: Content is not allowed in prolog.
at com.hp.hpl.jena.rdf.model.impl.RDFDefaultErrorHandler.fatalError(RDFDefaultErrorHandler.java:60)
at com.hp.hpl.jena.rdf.arp.impl.ARPSaxErrorHandler.fatalError(ARPSaxErrorHandler.java:51)
at com.hp.hpl.jena.rdf.arp.impl.XMLHandler.warning(XMLHandler.java:211)
at com.hp.hpl.jena.rdf.arp.impl.XMLHandler.fatalError(XMLHandler.java:241)
at org.apache.xerces.util.ErrorHandlerWrapper.fatalError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLErrorReporter.reportError(Unknown Source)
at org.apache.xerces.impl.XMLScanner.reportFatalError(Unknown Source)
at org.apache.xerces.impl.XMLDocumentScannerImpl$PrologDispatcher.dispatch(Unknown Source)
at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.DTDConfiguration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at com.hp.hpl.jena.rdf.arp.impl.RDFXMLParser.parse(RDFXMLParser.java:155)
at com.hp.hpl.jena.rdf.arp.JenaReader.read(JenaReader.java:173)
at com.hp.hpl.jena.rdf.arp.JenaReader.read(JenaReader.java:160)
at com.hp.hpl.jena.rdf.arp.JenaReader.read(JenaReader.java:199)
at com.hp.hpl.jena.rdf.model.impl.ModelCom.read(ModelCom.java:229)
at it.etc.rdf.LodWithPico.<init>(LodWithPico.java:24)
at it.etc.rdf.TestLodWithPico.main(TestLodWithPico.java:6)
    Caused by: org.xml.sax.SAXParseException: Content is not allowed in prolog.
at org.apache.xerces.util.ErrorHandlerWrapper.createSAXParseException(Unknown Source)
... 18 more

skos同义词库在w3c rdf / xml验证程序和skos验证程序中验证。有什么问题?

2 个答案:

答案 0 :(得分:0)

“picoFileName”究竟是什么?如果我在下载的内容上调用解析器,则适用于我。 这是哪个版本的Jena?

答案 1 :(得分:0)

抱歉,输入文件中出现了问题。我将文件内容复制到另一个文件中并且可以正常工作。