2

I am quite new to RDF and Jena. I want load a .nt (N- TRIPLE) file to a model. I have tried read(inputStream, "N-TRIPLE") but did not help.

It throws

org.apache.jena.riot.RiotException: Element or attribute do not match QName production: QName::=(NCName':')?NCName.

Can anyone point me out what is wrong?

Here is the link for the N-TRiple file which I tried to load : http://dbpedia.org/data/Berlin.ntriples

Shmwel
  • 1,697
  • 5
  • 26
  • 43
Sajid
  • 53
  • 2
  • 7

1 Answers1

8

read(inputStream, string) uses the string argument as the base URI, not the syntax language. It's trying the default, which is RDF/XML. Check the javadoc for Model#read(InputStream in, String base) and Model#read(InputStream in, String base, String lang) for more information.

model.read(inputStream, null, "N-TRIPLES") ;

or

RDFDataMgr.read(model, inputStream, LANG.NTRIPLES) ;

If you are just opening the stream from a file (or URL) then Apache Jena will sort out the details. E.g.,

RDFDataMgr.read(model, "file:///myfile.nt") ;

There are various related operations. See the javadoc for Model and RDFDataMgr.

Joshua Taylor
  • 84,998
  • 9
  • 154
  • 353
AndyS
  • 16,345
  • 17
  • 21