rdflib.js icon indicating copy to clipboard operation
rdflib.js copied to clipboard

N-Quads serializer cannot deal with default graph.

Open RinkeHoekstra opened this issue 2 years ago • 0 comments

The following valid N-Quad does not contain a graph:

_:b0 <https://example.com/hasExampleProperty> "some literal value" .

This is correctly parsed into a $rdf.Store.

When iterating over the statement, the graph term looks something like:

{
    "termType": "DefaultGraph",
    "value": "",
    "uri": "chrome:theSession"
}

However, the atomicTermToN3 function in serializer.js does not deal with nodes of type DefaultGraph:

https://github.com/linkeddata/rdflib.js/blob/c14dfd57d5159ad5ac1ee2523cc7924968e24f53/src/serializer.js#L522-L567

And fails with the error:

Error: Internal: atomicTermToN3 cannot handle DefaultGraph of termType: DefaultGraph

This should be fixed in atomicTermToN3 function in serializer.js by returning an empty string when the term type is DefaultGraph.

NB this is consistent also with how TriG represents default graphs.

RinkeHoekstra avatar Jul 20 '22 11:07 RinkeHoekstra