[
https://issues.apache.org/jira/browse/JENA-2069?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17303369#comment-17303369
]
Andy Seaborne commented on JENA-2069:
-------------------------------------
jena uses the [jsonld-java|https://github.com/jsonld-java/jsonld-java]
processor for JSON-LD.
You also have a prefix ":" for the same URL so the processor has a choice.
FWIW: I'm not sure that a relative URI is what is best in the example. A prefix
name defines neatly a absolute and stable URI.
{noformat}
BASE <http://base/>
<x> <p> <o> .
{noformat}
produces
{noformat}
{
"@id" : "x",
"p" : "o",
"@context" : {
"p" : {
"@id" : "http://base/p",
"@type" : "@id"
}
}
}
{noformat}
so the base has been used. It is just that the {{@base}} is not explicitly
included in the context.
For Turtle does the same , except the default is to include {{BASE}}. User
feedback was to at least provide the option of not outputting it to the true
URI will be dependent of what the file is located.
This is a feature of the jsonld-java processor. I haven't found a way to ask it
to include the "@base". if you find one, could you let us know? If there is a
way to get jsonld-java to optionally include {{@base}}, then this can be
controlled in the same way from Jena.
The Jena writer is {{org.apache.jena.riot.writer.JsonLDWriter}}. It passes base
to the JSON-LD options.
> JSON-LD serialisation and the base URI
> --------------------------------------
>
> Key: JENA-2069
> URL: https://issues.apache.org/jira/browse/JENA-2069
> Project: Apache Jena
> Issue Type: Bug
> Components: Jena
> Affects Versions: Jena 3.17.0
> Reporter: Goksel Misirli
> Priority: Critical
>
> The Jena JSON-LD serialiser uses the @vocab keyword to represent the default
> namespace when a Jena Model object has the default namespace URI defined.
> However, explicitly setting a base URI does not seem to work and only the
> default namespace is serialised.
> RDFWriterBuilder writerBuilder =
> RDFWriter.create().source(model).format(format);
> writerBuilder.base(baseUri.toString());
> I believe the @base keyword should be used to represent the base URIs. For
> example, in the Turtle representation, the base property can be used to infer
> that the URI for the CodonOptimisationProtocol resource in the example below
> is "https://sbolstandard.org/examples/CodonOptimisationProtocol". As far as I
> understand, in JSON-LD representation, the @vocab term would not be used to
> infer the URIs for individual resources but for type definitions.
> My temporary solution is to remove the default namespace before serialising
> the model to avoid the use of the @vocab keyword for now. The use of the
> @vocab keyword would be ok, if the @base is also saved.
> model.removeNsPrefix("");
> Please let me know if more information is needed.
> Please see below.
> Looking forward to hearing from you.
> Thanks
> -----------------------
> [https://www.w3.org/TR/json-ld11/#default-vocabulary]
> [https://www.w3.org/TR/json-ld11/#base-iri]
> TURTLE - Both the default namespace and the base URI can be defined using
> Jena.
> {noformat}
> @base <https://sbolstandard.org/examples/> .
> @prefix : <https://sbolstandard.org/examples/> .
> @prefix sbol: <http://sbols.org/v3#> .
> @prefix prov: <http://www.w3.org/ns/prov#> .
> :CodonOptimisationProtocol
> a prov:Plan ;
> sbol:description "Optimisation protocol to improve the translation of
> mRNAs." ;
> sbol:displayId "CodonOptimisationProtocol" ;
> sbol:name "Codon Optimisation Protocol" .
> {noformat}
> JSON-LD - Can't define the base URI using Jena.
> {noformat}
> {
> "@id" : "CodonOptimisationProtocol",
> "@type" : "prov:Plan",
> "description" : "Optimisation protocol to improve the translation of mRNAs.",
> "displayId" : "CodonOptimisationProtocol",
> "name" : "Codon Optimisation Protocol",
> "@context" : {
> "description" : { "@id" : "http://sbols.org/v3#description" } ,
> "name" : { "@id" : "http://sbols.org/v3#name" } ,
> "displayId" : { "@id" : "http://sbols.org/v3#displayId" },
> "@vocab" : "https://sbolstandard.org/examples/",
> "sbol" : "http://sbols.org/v3#",
> "prov" : "http://www.w3.org/ns/prov#"
> }
> }
> {noformat}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)