I am loading a JSON-LD document using Jena:
Model mj = RDFDataMgr.loadModel([filename]);
The actual content being loaded is here: http://build.fhir.org/account-example.jsonld
Jena goes off and resolves the context, and returns an error (LOADING_REMOTE_CONTEXT_FAILED - lovely suppression of the actual cause in the Jena code :-(). But I need to override the context anyway, and use a different source, because I am doing the build for what will be posted at build.fhir.org, and I need to use my local versions instead. I can't see how to override the context resolution
Alternatively, I could use the loading method documented here: https://github.com/jsonld-java/jsonld-java#code-example - but I have no idea how to get to a Jena graph from there (and I haven't figured out how make the custom resolution work in my Eclipse context either)
How can I get to a Jena graph using a context defined in code somewhere?
I think Jena devs are subscribed to the relevant tag RSS streams. They might weigh in on the clarity of
LOADING_REMOTE_CONTEXT_FAILED
error. But it seems pretty clear to me.In order to override the context, you can use
read(Model model, String uri, Context context)
method.ModelFactory.createDefaultModel()
will create a intance of aModel
that you can pass as a first argument. See more examples here: https://github.com/apache/jena/tree/master/jena-arq/src-examples/arq/examples/riotAlternative library is not Jena-compatible (nor RDF4J, which strikes me as rather silly), so there is no easy way to use it with Jena-dependent code.
Finally, you provided the code example for getting a model but now mention a graph – there is a method for that as well:
read(Graph graph, String uri, Context context)
.