Reputation: 2949
I am using the following steps to read quads into Jena Model
InputStreamin = FileManager.get().open(fn); //fn--filename
Model md = ModelFactory.createDefaultModel();
md.read(in,null,"TTL");
Quads in file are:
@prefix dbpedia: <http://dbpedia.org/resource/> .
dbpedia:53b56e90c8a15fcd48eb5001 dbpedia:type dbpedia:willtest dbpedia:1 .
dbpedia:53b56e90c8a15fcd48eb5001 dbpedia:end dbpedia:1404394351023 dbpedia:1 .
dbpedia:53b56e90c8a15fcd48eb5001 dbpedia:room dbpedia:Room202cen dbpedia:1 .
dbpedia:53debf266ad34658725225ed dbpedia:reading dbpedia:0 dbpedia:2 .
dbpedia:53debf206ad34658725225e5 dbpedia:begining dbpedia:1407106678270 dbpedia:3 .
But on running I get following error:
Exception in thread "main" com.hp.hpl.jena.n3.turtle.TurtleParseException: Encountered " <DECIMAL> "1. "" at line 2, column 60.
Was expecting one of:
";" ...
"," ...
"." ...
Error is generated due to the Quad file only. A triple file is read clearly. Is there any other method to read quads into Jena Model?
UPDATE#1
I did as Christian has mentioned in the answer, but now I get the following errors:
Exception in thread "main" com.hp.hpl.jena.shared.JenaException:
org.xml.sax.SAXParseException; lineNumber: 1; columnNumber: 1;
Content is not allowed in prolog.
Same data file can be found at link.
Upvotes: 2
Views: 706
Reputation: 311
Looks like you are reading a Turtle File, and as of http://www.w3.org/TR/turtle/#abstract , Turtle is not compatible with N-Quads:
This document defines a textual syntax for RDF called Turtle that allows an RDF graph to be completely written in a compact and natural text form, with abbreviations for common usage patterns and datatypes.
Turtle provides levels of compatibility with the N-Triples [N-TRIPLES] format as well as the triple pattern syntax of the SPARQL W3C Recommendation.
What you are basically doing is, you tell the parser that it has to parse a "Triples-syntax" file but you pass down a "Quad-syntax" file.
Change your file ending to .nq
and use md.read(in,null);
instead. This should then automatically detect that it is "Quad-syntax". And of course also make sure that your file is according to the N-Quads syntax, as defined here: http://www.w3.org/TR/n-quads/
Upvotes: 1