Hi Yana,

Thank you for the report. Poking around, I found that writing then reading your data through JSON-LD leads to alteration of the data, presumably due to the @id you highlighted.

I've raised a Jena JIRA issue; Jena uses the java-jsonld:java-jsonld engine to handled JSON-LD and I don't see any part of the Jena code being sensitive to the empty URI - I wonder if there is some interaction with "@base" and "@prefix :" as well as the "@id" : "./". I created an issue for java-jsonld with test cases.

https://issues.apache.org/jira/browse/JENA-758
==>
https://github.com/jsonld-java/jsonld-java/issues/122

and test case:
https://gist.github.com/afs/6474bd26a5e9f4c9aeb7#file-jsonld-java-issue-122

        Andy


On 05/08/14 22:05, Yana Panchenko wrote:
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