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

can't get rid of default prefix definition in trig serialization #2154

Closed
eroux opened this issue Nov 12, 2022 · 1 comment · Fixed by #2160
Closed

can't get rid of default prefix definition in trig serialization #2154

eroux opened this issue Nov 12, 2022 · 1 comment · Fixed by #2160

Comments

@eroux
Copy link
Contributor

eroux commented Nov 12, 2022

I have a trig file with just one graph like this:

@prefix adm: <http://purl.bdrc.io/ontology/admin/> .
@prefix bda: <http://purl.bdrc.io/admindata/> .
@prefix bdg: <http://purl.bdrc.io/graph/> .

bdg:W1NLM5228 {
    bda:W1NLM5228 a adm:AdminData ;
        adm:status bda:StatusReleased .
}

In my use case I need to be able to read it, modify it and then write it with the same prefix definitions, but when I do something very simple like

import rdflib
from rdflib import Literal, Graph, Dataset, URIRef
import os

ds = Dataset()
ds.parse("bug.trig", format="trig", publicID=URIRef("http://purl.bdrc.io/graph/W1NLM5228"))
ds.remove_graph(URIRef("urn:x-rdflib:default")) # doesn't work
ds.serialize(filepath+"-bug", format="trig")

the output I get is

@prefix adm: <http://purl.bdrc.io/ontology/admin/> .
@prefix bda: <http://purl.bdrc.io/admindata/> .
@prefix bdg: <http://purl.bdrc.io/graph/> .
@prefix ns1: <urn:x-rdflib:> .

bdg:W1NLM5228 {
    bda:W1NLM5228 a adm:AdminData ;
        adm:status bda:StatusReleased .
}

and I seem unable to remove the ns1: <urn:x-rdflib:> prefix definition. Is there any way to do so? Thanks!

eroux added a commit to eroux/rdflib that referenced this issue Nov 18, 2022
@eroux
Copy link
Contributor Author

eroux commented Nov 22, 2022

addressed in #2160

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant