Search code examples
apache-jena

Apache Jena RIOT Exception when loading external RDF or Turtle File


I am trying to load an external vocabulary (http://purl.org/eis/vocab/daq#) - this vocabulary has valid syntax and can be dereferenced and has both an RDF/XML and TURTLE serialisation - using the RDFDataMgr, however, I am getting a RIOTException:

org.apache.jena.riot.RiotException: [line: 23, col: 1 ] Broken token (newline): The Dataset Quality Vocabulary (daQ) is a lightweight, extensible core vocabulary for attaching the result of quality benchmarking of a linked open 

This exception is only happening when I try to load it externally. Loading works when I use my local copy of the vocabulary. I was using the 2.11.1 version of Jena, but yesterday I updated the code to the latest 3.3.0, but I still had the same exception. I am thinking that this might be a problem related to how the Jena mechanics and external libraries are reading non-local sources. Does anyone have an idea how this can be fixed?

Thanks Jeremy


Solution

  • The endpoint returns Turtle that is broken and not valid syntax. There are raw newlines in the string around line 23. Replace with """-quoting or fix the data.

    The RDF/XML is OK.

    Use RDFParser to build a parser process that sets the "accept" header to "application/rdf+xml". The default used by RDFDataMgr prefers Turtle.