Reading N-Quads in Jena

I’m trying to read an N-Quads file with Jena, but all I get is an empty model. The file I’m trying to read is taken from the example in N-Quads documentation:
<> <> <> <> .
(I saved it as a file named file.nq).

The way I’m loading the model is using the RDFDataMgr. But it didn’t work with either.

RDFDataMgr.loadModel("file.nq", Lang.NQUADS)
yields an empty model.

What am I missing? Doesn’t Jena support N-Quads out-of-the-box?


Yes, Jena supports N-Quads. Try loadDataset.

N-Quads is for multiple graphs and you have read it into one graph. What you get is just the default graph triples, in this case, none.

There is a warning emitted:

WARN riot :: Only triples or default graph data expected : named graph data ignored

If you didn’t get that then (1) you are running an old copy (2) you have turned logging off (3) the file is empty.

Leave a Reply

Your email address will not be published. Required fields are marked *