Open fbartusch opened 9 months ago
Thanks for reporting this issue. I am not familiar with riot. Are you able to obtain more details about the “problem encountered”?
I wonder whether riot is refusing to access an http url. Could you instead try with https://openprovenance.org/prov.jsonld ?
-- Professor Luc Moreau, Head of Department Department of Informatics, King’s College London Strand Campus, Bush House, 30 Aldwych, London, WC2B 4BG. Tel: +44 207 848 6808, web: https://nms.kcl.ac.uk/luc.moreau/
From: Felix Bartusch @.> Date: Monday, 18 December 2023 at 06:46 To: lucmoreau/ProvToolbox @.> Cc: Subscribed @.***> Subject: [lucmoreau/ProvToolbox] Other tools have problems with JSON-LD output files (Issue #214)
Hi,
I'm trying to use JSON-LD output files with Apache Jena tools like riot (e.g. converting .jsonld to .ttl). But riot and also JSON-LD Playground have problems with ProvToolbox' output.
Here is a minimal example:
{
@.***" : [ {
"xsd" : "http://www.w3.org/2001/XMLSchema#",
"prov" : "http://www.w3.org/ns/prov#",
"exa" : "https://example.com/"
}, "http://openprovenance.org/prov.jsonld" ],
@.***" : [ {
***@***.***" : "prov:Entity",
***@***.***" : "exa:anatomy-img1",
"prov:label" : [ {
***@***.***" : "anatomy_img1"
} ]
} ]
}
I'm using
riot complains:
$ riot --output=Turtle test.jsonld
07:31:58 ERROR riot :: There was a problem encountered loading a remote context [code=LOADING_REMOTE_CONTEXT_FAILED]
I found that the external context (I hope this term is correct, I'm not experienced with the format) http://openprovenance.org/prov.jsonld causes the problem. When removed both tools don't complain: working JSON-LD playgroundhttps://json-ld.org/playground/#startTab=tab-expanded&json-ld=%7B%22%40context%22%3A%5B%7B%22xsd%22%3A%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23%22%2C%22prov%22%3A%22http%3A%2F%2Fwww.w3.org%2Fns%2Fprov%23%22%2C%22exa%22%3A%22https%3A%2F%2Fexample.com%2F%22%7D%5D%2C%22%40graph%22%3A%5B%7B%22%40type%22%3A%22prov%3AEntity%22%2C%22%40id%22%3A%22exa%3Aanatomy-img1%22%2C%22prov%3Alabel%22%3A%5B%7B%22%40value%22%3A%22anatomy_img1%22%7D%5D%7D%5D%7D
If the external context is replaced with https://json-ld.org/contexts/person.jsonld, it also workshttps://json-ld.org/playground/#startTab=tab-expanded&json-ld=%7B%22%40context%22%3A%5B%7B%22xsd%22%3A%22http%3A%2F%2Fwww.w3.org%2F2001%2FXMLSchema%23%22%2C%22prov%22%3A%22http%3A%2F%2Fwww.w3.org%2Fns%2Fprov%23%22%2C%22exa%22%3A%22https%3A%2F%2Fexample.com%2F%22%7D%2C%22https%3A%2F%2Fjson-ld.org%2Fcontexts%2Fperson.jsonld%22%5D%2C%22%40graph%22%3A%5B%7B%22%40type%22%3A%22prov%3AEntity%22%2C%22%40id%22%3A%22exa%3Aanatomy-img1%22%2C%22prov%3Alabel%22%3A%5B%7B%22%40value%22%3A%22anatomy_img1%22%7D%5D%7D%5D%7D. The replacement doesn't makes sense, it's just an example that the linked JSON-LD file http://openprovenance.org/prov.jsonld somehow breaks other tools.
Kind Regards, Felix
— Reply to this email directly, view it on GitHubhttps://github.com/lucmoreau/ProvToolbox/issues/214, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AABCXQ5UNTLXFMWOYTCCSULYJ7REPAVCNFSM6AAAAABAZAWWW2VHI2DSMVQWIX3LMV43ASLTON2WKOZSGA2DKOBVGI4TINQ. You are receiving this because you are subscribed to this thread.Message ID: @.***>
Same problem with https.
I think both tools I tested (Apache Jena's riot and the JSON-LD playground) expect that the content type returned from the context is application/ld+json
.
But the content type of http://openprovenance.org/prov.jsonld
is text/html
.
$ curl -s -I http://openprovenance.org/prov.jsonld | grep -i "^Content-Type:"
Content-Type: text/html
$ curl -s -I https://json-ld.org/contexts/person.jsonld | grep -i "^Content-Type:"
Content-Type: application/ld+json
@fbartusch thanks for identifying the origin of the problem
@trungdong is this something you could fix on openprovenance.org?
I stumbled upon another problem and hope it's ok to add it here, as it's the same topic:
ProvToolbox currently produces this JSON-LD where the prov
prefix is missing from some elements. The effect is, that other tools omit these information when they parse the file.
The example here is for Generation
. In my more elaborated use case I can see the problem also for Membership
, Derivation
, Association
, and Usage
. Maybe it's also present for other elements that I don't use.
{
"@context" : [ {
"prov" : "http://www.w3.org/ns/prov#",
"exa" : "https://example.com/"
} ],
"@graph" : [
{
"@type" : "prov:Generation",
"entity" : "exa:generatedFile",
"activity" : "exa:ProgramExecution"
} ]
}
When I convert this into Turtle format (again with Apache Jena riot tool), the entity
and activity
information is lost. There is only a blank node:
_:b0 a prov:Generation .
The example in the JSON-LD Playground: click
When I add the prov
prefix to entity
and activity
, it behaves like expected:
{
"@context" : [ {
"prov" : "http://www.w3.org/ns/prov#",
"exa" : "https://example.com/"
} ],
"@graph" : [
{
"@type" : "prov:Generation",
"prov:entity" : "exa:generatedFile",
"prov:activity" : "exa:ProgramExecution"
} ]
}
Converting yields:
_:b a prov:Generation ;
prov:activity "exa:ProgramExecution" ;
prov:entity "exa:generatedFile" .
The example in the JSON-LD Playground: click
Missclick, sorry. I didn't want to close it with the last comment ...
I think that's because the context has not been loaded by the tool properly. You will see that http://openprovenance.org/prov.jsonld
contains the following declarations.
"entity": { "@id": "prov:entity", "@type": "@id" },
"activity": { "@id": "prov:activity", "@type": "@id" },
"agent": { "@id": "prov:agent", "@type": "@id" },
I now realise that this was an old version of the prov-jsonld context.
The definition of prov-jsonld can be found at https://openprovenance.org/prov-jsonld/.
The prov-jsonld context is accessible from https://openprovenance.org/prov-jsonld/context.json and is served with the application/json
type.
The development branch has got a fix, and it will be included in the next release of ProvToolbox.
If you update the context by hand, does it fix the issue you are having with your tool?
If you update the context by hand, does it fix the issue you are having with your tool? No, unfortunately not.
I found a solution now. I took your context.json
and converted it to context.jsonld
.
I put the new context into a local webserver that returns the file with the MIME Type application/ld+json
. 'The conversion tool now converts my files without complaining and the results looks like expected.
Maybe you can use that file on your server?
context.jsonld
Python script for my local webserver
Context used in my jsonld file
@fbartusch thanks for identifying the origin of the problem
@trungdong is this something you could fix on openprovenance.org?
I have fixed the MIME type.
$ curl -s -I -L http://openprovenance.org/prov.jsonld
HTTP/1.1 301 Moved Permanently
Server: nginx/1.24.0
Date: Wed, 03 Jan 2024 12:52:52 GMT
Content-Type: text/html
Content-Length: 169
Connection: keep-alive
Location: https://openprovenance.org/prov.jsonld
HTTP/2 200
server: nginx/1.24.0
date: Wed, 03 Jan 2024 12:52:52 GMT
content-type: application/ld+json
content-length: 1896
last-modified: Thu, 09 Aug 2018 20:56:13 GMT
...
The prov-jsonld context is accessible from https://openprovenance.org/prov-jsonld/context.json and is served with the
application/json
type.The development branch has got a fix, and it will be included in the next release of ProvToolbox.
I would advise against changing the canonical context's location to https://openprovenance.org/prov-jsonld/context.json
since we will not be able to serve it with the correct MIME type, i.e. application/ld+json
(without also serving other JSON files with this MIME type).
We can instead update the file at http://openprovenance.org/prov.jsonld
with the latest, accurate content.
I would suggest keeping the following as a json content https://openprovenance.org/prov-jsonld/context.json
and creating the following with the appropriate media type https://openprovenance.org/prov-jsonld/context.jsonld
given that the spec is at
https://openprovenance.org/prov-jsonld/https://openprovenance.org/prov-jsonld/context.jsonld
-- Professor Luc Moreau, Head of Department Department of Informatics, King’s College London Strand Campus, Bush House, 30 Aldwych, London, WC2B 4BG. Tel: +44 207 848 6808, web: https://nms.kcl.ac.uk/luc.moreau/
From: Dong Huynh @.> Date: Wednesday, 3 January 2024 at 13:02 To: lucmoreau/ProvToolbox @.> Cc: Luc Moreau @.>, Comment @.> Subject: Re: [lucmoreau/ProvToolbox] Other tools have problems with JSON-LD output files (Issue #214)
The prov-jsonld context is accessible from https://openprovenance.org/prov-jsonld/context.json and is served with the application/json type.
The development branch has got a fix, and it will be included in the next release of ProvToolbox.
I would advise against changing the canonical context's location to https://openprovenance.org/prov-jsonld/context.json since we will not be able to serve it with the correct MIME type, i.e. application/ld+json (without also serving other JSON files with this MIME type).
We can instead update the file at http://openprovenance.org/prov.jsonld with the latest, accurate content.
— Reply to this email directly, view it on GitHubhttps://github.com/lucmoreau/ProvToolbox/issues/214#issuecomment-1875338205, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AABCXQ5B2CGBZ5VEUPGSIFDYMVJEZAVCNFSM6AAAAABAZAWWW2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQNZVGMZTQMRQGU. You are receiving this because you commented.Message ID: @.***>
I've made a symlink at /prov-jsonld/context.jsonld
pointing to /prov-jsonld/context.json
$ curl -s -I -L http://openprovenance.org/prov-jsonld/context.jsonld
HTTP/1.1 301 Moved Permanently
Server: nginx/1.24.0
Date: Tue, 09 Jan 2024 14:38:28 GMT
Content-Type: text/html
Content-Length: 169
Connection: keep-alive
Location: https://openprovenance.org/prov-jsonld/context.jsonld
HTTP/2 200
server: nginx/1.24.0
date: Tue, 09 Jan 2024 14:38:28 GMT
content-type: application/ld+json
content-length: 4703
last-modified: Mon, 23 Mar 2020 15:34:15 GMT
Hi,
I'm trying to use JSON-LD output files with Apache Jena tools like riot (e.g. converting .jsonld to .ttl). But riot and also JSON-LD Playground have problems with ProvToolbox' output.
Here is a minimal example:
I'm using
riot complains:
Here is the problem inside the JSON-LD playground
I found that the external context (I hope this term is correct, I'm not experienced with the format)
http://openprovenance.org/prov.jsonld
causes the problem. When removed both tools don't complain: working JSON-LD playgroundIf the external context is replaced with
https://json-ld.org/contexts/person.jsonld
, it also works. The replacement doesn't makes sense, it's just an example that the linked JSON-LD filehttp://openprovenance.org/prov.jsonld
somehow breaks other tools.Kind Regards, Felix