Closed sdevalk closed 11 months ago
Following the JSON-LD document semantics, all @context
values do indeed have to be dereferenced when parsing a document. There's no way to disable this, as this could cause differences in parsing, and thereby lead to wrong parsed data.
What is possible on the other hand, is caching or prefetching these contexts using a custom IDocumentLoader
.
Thanks for the clear explanation, @rubensworks - that makes sense.
Caching or prefetching the contexts sounds perfect. Do you know how I can use a customer document loader?
I use this package in a module of my own that mostly dereferences JSON-LD documents, and occasionally documents in other RDF serializations. Is there a way to pass a custom loader for JSON-LD documents that is ignored for e.g. Turtle or N-Triples documents?
Caching or prefetching the contexts sounds perfect. Do you know how I can use a customer document loader?
@sdevalk I should probably document this at some point, but something like the following should work (untested):
dereference('http://...', { '@comunica/actor-rdf-parse-jsonld:documentLoader': new MyDocumentLoader() });
Where MyDocumentLoader
implements https://github.com/rubensworks/jsonld-context-parser.js/blob/master/lib/IDocumentLoader.ts
@rubensworks Thanks for the pointer! 👍🏻
I use this package - with great pleasure - to dereference IRIs of JSON-LD documents. However, I find the dereferencing to be a bit slow, e.g. when using this IRI.
I get the impression that this package not only dereferences the actual IRIs, but also the IRIs that are mentioned in the
@context
s of the JSON-LD documents. Is that correct? Or when looking at the sample IRI: does it request the@context
IRIs,http://iiif.io/api/presentation/2/context.json
andhttp://iiif.io/api/image/2/context.json
? If so, is it possible to disable this?