简体   繁体   中英

Exception when parsing structure.rdf.u8, using Jena

 Model model = ModelFactory.createDefaultModel();
 InputStream in = FileManager.get().open( "W:\\structure.rdf.u8" );
 model.read(in, null);
 model.write(System.out);

I use the above code, which is provided in the Jena documentation, to parse the ODP . First it gave some exception, so I added all the jar files in the Jena package and got the following long exception:

    log4j:WARN No appenders could be found for logger (org.apache.jena.riot.system.stream.JenaIOEnvironment).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" org.apache.jena.riot.RiotException: [line: 5, col: 5 ] {E201} The attributes on this property element, are not permitted with any content; expecting end element tag.
    at org.apache.jena.riot.system.ErrorHandlerFactory$ErrorHandlerStd.error(ErrorHandlerFactory.java:128)
    at org.apache.jena.riot.lang.LangRDFXML$ErrorHandlerBridge.error(LangRDFXML.java:246)
    at org.apache.jena.rdfxml.xmlinput.impl.ARPSaxErrorHandler.error(ARPSaxErrorHandler.java:37)
    at org.apache.jena.rdfxml.xmlinput.impl.XMLHandler.warning(XMLHandler.java:196)
    at org.apache.jena.rdfxml.xmlinput.impl.XMLHandler.warning(XMLHandler.java:173)
    at org.apache.jena.rdfxml.xmlinput.impl.XMLHandler.warning(XMLHandler.java:168)
    at org.apache.jena.rdfxml.xmlinput.impl.ParserSupport.warning(ParserSupport.java:194)
    at org.apache.jena.rdfxml.xmlinput.states.Frame.warning(Frame.java:55)
    at org.apache.jena.rdfxml.xmlinput.states.WantEmpty.characters(WantEmpty.java:33)
    at org.apache.jena.rdfxml.xmlinput.impl.XMLHandler.characters(XMLHandler.java:137)
    at org.apache.xerces.parsers.AbstractSAXParser.characters(Unknown Source)
    at org.apache.xerces.impl.XMLNamespaceBinder.characters(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanContent(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)

`

I don't know if I need to remove some of the jar files to fix this or the code provided in the Apache site is wrong?

It's not legal RDF/XML; close but has errors. (at least the one http://rdf.dmoz.org/rdf/structure.rdf.u8.gz isn't)

  1. Top level 'RDF' is not the RDF marker RDF, it's http://dmoz.org/rdf/RDF It should be r:RDF but then ...
  2. The r namespace is wrong (should be http://www.w3.org/1999/02/22-rdf-syntax-ns# , not http://www.w3.org/TR/RDF/ ).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM