Trig serialiser writing empty named graph name for default graph · Issue #433 · RDFLib/rdflib (original) (raw)
When parsing then serialising TriG, the serialiser fails to correctly detect when it's dealing with the default graph, so attempts to serialise it as a named graph (which ends up with 'None' instead of a URI or qname).
E.g.:
import rdflib
data = """
@prefix : <http://example.com/> .
<:a> <:b> <:c> .
"""
g = rdflib.ConjunctiveGraph()
g.parse(data=data, format='trig')
print g.serialize(format='trig')
Produces the output:
@prefix : <http://example.com/> .
@prefix ns1: <:> .
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xml: <http://www.w3.org/XML/1998/namespace> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
<None> {
ns1:a ns1:b ns1:c .
}
whereas for latter part of the output, it should produce either:
or
I've added a unit test for this to #431 .