Closed OyvindLGjesdal closed 4 years ago
It's a bug in the newer jsonld.js context handling code. It's exposed in the giant data blob above where some @contexts
have type: null
or similar. Or at least I distilled it down to something like that.
A much simpler test case is:
example.jsonld
:
{
"@context": "https://example.com/context.jsonld",
}
context.jsonld
:
{
"@context": {
"t": null
}
}
@dlongley Looks like the issue is in lib/ContextResolver.js
_resolveContextUrls
. What's the best way to fix? Add if(!context) return
at the start? Or if(ctx[term])
in the term loop at the end? I'm unsure if there are other similar bugs with this processing code trying to handle arbitrary context data, so maybe take a quick look?
I think if(!context) { return; }
should suffice to fix this.
I think this is fixed in jsonld.js 2.0.2, and the playground was updated. An empty object using that URL for a context loads now. Please test.
Thank you for the fix! Not sure if the testing comment is for me.
I've tried with https://iiif.spraksamlingane.no/iiif/manifest/8bc611e9-d0d3-320a-b787-a3d76d8d41cd.json
and it loads. Some of the output-views have processing errors (signed with bitcoin, signed with rsa)
Error: The property "id" in the input was not defined in the context.
but still has output in the <div class="codeMirror-code">
@OyvindLGjesdal Yes, I was hoping you could test whatever you were trying to do.
What input are you using to test? I was just trying a basic test that at least loaded and parsed the context. For empty data like this the "signing" examples work:
{
"@context": "https://iiif.spraksamlingane.no/iiif/manifest/8bc611e9-d0d3-320a-b787-a3d76d8d41cd.json"
}
There may be other reasons those signing examples don't work, so I'd not worry about it if your real use case is working ok.
I used the url from your @context
as the remote url document in the web service, which contains both data and context.
I also tried https://oyvindg.no/manifest/test22.jsonld which I downloaded from the Bodleian University Library IIIF service, retrieved from:
curl 'https://iiif.bodleian.ox.ac.uk/iiif/manifest/eb45e6ee-395d-4da1-8337-d8bfdde72ae9.json' -H 'Accept: application/ld+json;profile=http://iiif.io/api/presentation/3/context.json'
My use case is solved, thanks again for the help.
asked for help on this in the IIIF-slack, and received advice from @ahankinson debug using the '@context' inline, which
If I use the web-service for the url https://iiif.spraksamlingane.no/iiif/manifest/8bc611e9-d0d3-320a-b787-a3d76d8d41cd.json (json-ld 1.1) I get
If I edit the jsonld file and add the context inline it passes but has a warning in
Codemirror-lint-arker-warning
Context pasted inline in jsonld: