Re: Duplicate and shared list nodes in RDF to JSON-LD serialization

> On Nov 13, 2014, at 2:49 PM, Martín Martínez Rivera <martinmr@mit.edu> wrote:
> 
> Good evening.
> 
> I am currently implementing the JSON-LD API for the Go programming language. I am working on RDF to JSON-LD serialization and my code passes all the tests except for the last three (test cases fromRdf20, fromRdf21, and fromRdf22). These three test cases are concerned with list nodes that are duplicate or shared among multiple graphs. I went through the current version of the API implementation but I cannot find any step where it's specified what to do in these situations. 
> 
> Is the current specification of the "Serialize RDF as JSON-LD" able to pass those tests? If that's the case, any hints on which steps of the algorithm to look into would be appreciated.

Well, of course, specifications don’t pass tests, implementations do. The original implementations in Python, Java, JavaScript, PHP and Ruby all pass these tests, as you can see from the implementation report [1].

The fromRdf algorithm specifically looks for nodes which are part of conformant lists (i.e., a node having a single value for rdf:first and rdf:rest with appropriate values and possibly an rdf:List @type) in order to ensure that the lists are conformant. A conformant list implements a linked-list with no shared nodes.

If you try to serialize RDF with shared elements, the appropriate thing is to fall back to use independent node definitions with rdf:first and rdf:rest instead of the @list abbreviation.

For reference, you might look at my Ruby implementation starting about here [2].

For spec text, look at step 4 of the “Serialize RDF as JSON-LD Algorithm” [3].

Great to have more implementations, thanks for the work! When complete, consider submitting an implementation report and a pull-request to be listed in the Developers section on json-ld.org <http://json-ld.org/>.

Gregg

[1] http://json-ld.org/test-suite/reports/ <http://json-ld.org/test-suite/reports/>
[2] https://github.com/ruby-rdf/json-ld/blob/develop/lib/json/ld/from_rdf.rb#L75 <https://github.com/ruby-rdf/json-ld/blob/develop/lib/json/ld/from_rdf.rb#L75>
[3] http://www.w3.org/TR/json-ld-api/#serialize-rdf-as-json-ld-algorithm

> Best,
> 
> -- 
> Martin Martinez Rivera

Received on Friday, 14 November 2014 18:33:47 UTC