Uploaded image for project: 'Apache Jena'
  1. Apache Jena
  2. JENA-2069

JSON-LD serialisation and the base URI

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • Jena 3.17.0
    • None
    • Jena
    • None

    Description

      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.

      @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" .
       

      JSON-LD - Can't define the base URI using Jena.

       {
       "@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#"
       }
       }
       

      Attachments

        Activity

          People

            Unassigned Unassigned
            goksel Goksel Misirli
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: