The content header is right although it would be nice if they handled
"q=" differently.
The problem is the JSON-LD data is wrong.
If the line
"" : "http://viaf.org/viaf/terms#",
is removed, it works.
Andy
On 16/12/2019 11:46, Andreas Kahl wrote:
Andy, Rob,
Thanks for your quick responses. I will try to implement this. The whole
program using this is a little 'follow your nose' spider, so I will have to see
where to integrate custom code for this domain until they fix the erroneus
content type header. But at least I know now what's the reason; that was a huge
help.
I will also try to find out how to report this bug.
Best Regards
Andreas
Andy Seaborne <[email protected]> 16.12.19 11.11 Uhr >>>
On 16/12/2019 09:50, Rob Vesse wrote:
The server does not appear to be sending an appropriate Content-Type header.
Note that if you read the stack trace you can see that Jena thinks the URI is
returning JSON/LD and invoking its JSON/LD parser hence why you hit a parsing
error. I would consider filing a bug report with the server operators about
this
As you note in your email the data is actually RDF/XML so you can force Jena to
request (and treat) the data as that by passing the language parameter to the
RDFDataMgr.loadModel() call e.g.
RDFDataMgr.loadModel("http://viaf.org/viaf/32182557", Lang.RDFXML);
It would if the far end returns no content type. The Lang argument is an
override when no other mechanism to deduce the syntax (and including
"text/plain" being a common situation).
When the server actively sends back JSON-LD, that RDFDataMgr call
follows that. The JSON-LD is reported as bad by jsonld-java.
So many ways things can go wrong!
RDFParser.create()
.httpAccept(WebContent.contentTypeRDFXML)
.source("http://viaf.org/viaf/32182557")
.parse(m);
Rob
On 16/12/2019, 09:24, "Andreas Kahl" <[email protected]> wrote:
Hello everyone,
I got this error while trying to load data from a URI to a Jena model:
http://viaf.org/viaf/32182557 (RDF-URL:
https://viaf.org/viaf/32182557/rdf.xml )
2019-12-16 09:55:09 WARN Spider:490 - Error parsing data from URI:
http://viaf.org/viaf/32182557
org.apache.jena.riot.RiotException: invalid term definition: empty key
for value 'http://viaf.org/viaf/terms#'
at
org.apache.jena.riot.system.ErrorHandlerFactory$ErrorHandlerStd.error(ErrorHandlerFactory.java:140)
at
org.apache.jena.riot.lang.JsonLDReader.read$(JsonLDReader.java:162)
at
org.apache.jena.riot.lang.JsonLDReader.read(JsonLDReader.java:101)
at org.apache.jena.riot.RDFParser.read(RDFParser.java:352)
at org.apache.jena.riot.RDFParser.parseURI(RDFParser.java:321)
at org.apache.jena.riot.RDFParser.parse(RDFParser.java:295)
at
org.apache.jena.riot.RDFParserBuilder.parse(RDFParserBuilder.java:506)
at org.apache.jena.riot.RDFDataMgr.parseFromURI(RDFDataMgr.java:890)
at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:221)
at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:102)
at org.apache.jena.riot.RDFDataMgr.read(RDFDataMgr.java:93)
at org.apache.jena.riot.RDFDataMgr.loadModel(RDFDataMgr.java:335)
If I paste the rdf.xml to W3C's validator, it validates successfully.
(URL: source of https://viaf.org/viaf/32182557/rdf.xml ->
https://www.w3.org/RDF/Validator )
Is there any setting that should be used in order to make Riot more
tolerant to this?
The Jena version used is 3.13.1.
Thanks for your advice.
Best Regards
Andreas