Skip to content

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

@eroux

Description

@eroux

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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions