Angelo Neves
Angelo Neves

Reputation: 99

Problems reading rdf Jena

I have problem reading certain types of .rdf file. These files are taken from Manhein catalog. Here's a simple code:

 Model model = ModelFactory.createDefaultModel();  
 RDFDataMgr.read(model, "file.rdf");
 model.write(System.out);

For some .rdf type files, I'm getting .nq but Manhein .rdf catalog files is taking place this following error:

Exception in thread "main" org.apache.jena.riot.RiotException: Code: 17/WHITESPACE in PATH: A single whitespace character. These match no grammar rules of URIs/IRIs. These characters are permitted in RDF URI References, XML system identifiers, and XML Schema anyURIs.

I've tried other types of reading as RDFDataMgr. I also tried to create an empty model in fuseki and read the file in rdf and then press the fuseki, but gives the same error. I tried searching for the error and no success. Can someone help me?

thank you

Upvotes: 1

Views: 2539

Answers (2)

Chiheb Guelmami
Chiheb Guelmami

Reputation: 1

Try this...

Model model = ModelFactory.createDefaultModel();
InputStream file = FileManager.get().open( "file.rdf" );
model.read(file,null);
model.write(System.out);

Upvotes: 0

AndyS
AndyS

Reputation: 16700

There is a bad URI in the data. It has a space in it. Spaces are not allowed anywhere in URIs and IRIs. RDF 1.1 uses IRIs.

Try replacing the space with "%20" - note that the IRI will have characters %-2-0 in it. %-encoding is not an escape mechanism.

Fixing the data is by far the best solution - forcing the character in by some devious means will bring problems later.

Upvotes: 1

Related Questions