Skip to content

N-Quads serializer ignores default graph #1842

@edmondchuc

Description

@edmondchuc

The following script can be run as-is:

from rdflib import Dataset

data = """
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .

{
	_:b0 <http://www.w3.org/ns/prov#generatedAtTime> "2012-04-09"^^xsd:date .
}

_:b0 {
	<http://greggkellogg.net/foaf#me> a <http://xmlns.com/foaf/0.1/Person> ;
		<http://xmlns.com/foaf/0.1/knows> "http://manu.sporny.org/about#manu" ;
		<http://xmlns.com/foaf/0.1/name> "Gregg Kellogg" .

	<http://manu.sporny.org/about#manu> a <http://xmlns.com/foaf/0.1/Person> ;
		<http://xmlns.com/foaf/0.1/knows> "http://greggkellogg.net/foaf#me" ;
		<http://xmlns.com/foaf/0.1/name> "Manu Sporny" .
}


"""

g = Dataset()
g.parse(data=data, format="trig")

g.print(format="nquads")

Output:

_:nde95dc418226482f9fb7b0242109b9a3b1 <http://www.w3.org/ns/prov#generatedAtTime> "2012-04-09"^^<http://www.w3.org/2001/XMLSchema#date> _:Neae5d6b422ed4d1d872dd9674af22f8f .
<http://greggkellogg.net/foaf#me> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> _:nde95dc418226482f9fb7b0242109b9a3b1 .
<http://manu.sporny.org/about#manu> <http://xmlns.com/foaf/0.1/name> "Manu Sporny" _:nde95dc418226482f9fb7b0242109b9a3b1 .
<http://manu.sporny.org/about#manu> <http://xmlns.com/foaf/0.1/knows> "http://greggkellogg.net/foaf#me" _:nde95dc418226482f9fb7b0242109b9a3b1 .
<http://greggkellogg.net/foaf#me> <http://xmlns.com/foaf/0.1/knows> "http://manu.sporny.org/about#manu" _:nde95dc418226482f9fb7b0242109b9a3b1 .
<http://manu.sporny.org/about#manu> <http://www.w3.org/1999/02/22-rdf-syntax-ns#type> <http://xmlns.com/foaf/0.1/Person> _:nde95dc418226482f9fb7b0242109b9a3b1 .
<http://greggkellogg.net/foaf#me> <http://xmlns.com/foaf/0.1/name> "Gregg Kellogg" _:nde95dc418226482f9fb7b0242109b9a3b1 .

Issue

I would have expected the first statement of the output to omit the graph label as it is a statement in the default graph.

_:nde95dc418226482f9fb7b0242109b9a3b1 <http://www.w3.org/ns/prov#generatedAtTime> "2012-04-09"^^<http://www.w3.org/2001/XMLSchema#date> _:Neae5d6b422ed4d1d872dd9674af22f8f .

See https://www.w3.org/TR/n-quads/#simple-triples for reference.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingconcept: RDF datasetRelates to the RDF datasets concept.concept: default graphcoreRelates to core functionality of RDFLib, i.e. `rdflib.{graph,store,term}`criticalformat: N-QuadsRelated to N-Quads format.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions