Hi,

There seems to be a problem with writing Dataset into JSON-LD in a case such as 
the following. TRIG input


    @prefix :      <http://www.example.com/resource/100/v1#> .
    @prefix dc:    <http://purl.org/dc/elements/1.1/> .
    :G {
      <http://www.example.com/archive/100/v1> dc:isVersionOf 
<http://www.example.com/resource/100>  .
    }

is read into Dataset and then written in JSON-LD. The resulting JSON-LD looks 
like this:

    {
      "@graph" : [ {
        "@id" : "../../archive/100/v1",
        "dc:isVersionOf" : {
          "@id" : "./"
        }
      } ],
      "@id" : ":G",
      "@context" : {
        "dc" : "http://purl.org/dc/elements/1.1/";,
        "@base" : "http://www.example.com/resource/100/v1#";,
        "" : "http://www.example.com/resource/100/v1#";
      }
    }

The fifth line in this JSON-LD is wrong. The problem occurs if a resource uri 
in a graph is the first part of the base uri (with empty string prefix).Is it a 
bug? Or is it not correct to have an empty string prefix? (if I change prefix 
':' to e.g. 'v1:' everything works fine, but at the same time the empty prefix 
works fine for e.g. TRIG)

My read TRIG and write JSON-LD code:
        InputStream is = this.getClass().getResourceAsStream(RESOURCE_FILE);
        Dataset dataset = DatasetFactory.createMem();
        RDFDataMgr.read(dataset, is, RDFFormat.TRIG.getLang());
        is.close();
        sw = new StringWriter();
        RDFDataMgr.write(sw, dataset, RDFFormat.JSONLD);
        System.out.println(sw.toString());
        

Kind regards,
Yana

Reply via email to