0

Possible Duplicate:
org.xml.sax.SAXParseException: Content is not allowed in prolog

I would like to import a skos (rdf/xml) thesaurus in Jena model. The skos thesaurus is available in http://www.culturaitalia.it/pico/thesaurus/4.2/thesaurus_4.2.0.skos.xml. I copied that to a local file (in picoFileName) and I used this code to import it in a Model:

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

I receive this error:

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

The skos thesaurus is validated in w3c rdf/xml validator and in skos validator. What is wrong?

Community
  • 1
  • 1
Alessandra
  • 467
  • 2
  • 6
  • 24

2 Answers2

0

What exactly is in "picoFileName"? Works for me if I call a parser on the downloaded content. Which version of Jena is this?

AndyS
  • 16,345
  • 17
  • 21
  • In picoFileName there is the file full path, and it works because it doesn't throw IllegalArgumentException: I followed it with debug and the crash statement is: pico.read(new InputStreamReader(in), ""); – Alessandra Dec 29 '12 at 12:39
0

Sorry, there was something wrong in the input file. I copied file content in an other file and it works.

Alessandra
  • 467
  • 2
  • 6
  • 24