Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Trig serialiser writing empty named graph name for default graph #433

Closed
dschallis opened this issue Oct 31, 2014 · 2 comments
Closed

Trig serialiser writing empty named graph name for default graph #433

dschallis opened this issue Oct 31, 2014 · 2 comments
Labels
bug Something isn't working serialization Related to serialization.
Milestone

Comments

@dschallis
Copy link

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:

ns1:a ns1:b ns1:c .

or

{ ns1:a ns1:b ns1:c . }

I've added a unit test for this to #431 .

@niklasl
Copy link
Member

niklasl commented Aug 4, 2016

This has been partially fixed. The erroneous graph identifier syntax was fixed in bd57db7 and f167ecf.

The expected result can be achieved by parsing datasets into the default_context of the conjunctive graph (or dataset), like:

g = rdflib.ConjunctiveGraph()
g.default_context.parse(data=data, format='trig')
print g.serialize(format='trig')

Should we close this (and leave the remaining details to the eventual improvements outlined in #436)?

@gromgull gromgull added bug Something isn't working serialization Related to serialization. labels Jan 19, 2017
@gromgull gromgull added this to the rdflib 4.2.2 milestone Jan 24, 2017
@gromgull
Copy link
Member

Should we close this (and leave the remaining details to the eventual improvements outlined in #436)?

yes :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working serialization Related to serialization.
Projects
None yet
Development

No branches or pull requests

3 participants