Skip to content

Remove unused prefixes from serialization #794

@noorbakerally

Description

@noorbakerally

I have a rdflib.Graph object to which I bind several namespaces. The issue is that when serializing the graph, many of the binded namespaces are not used but are still in the serialized text. I want only the used prefixes to be serialized. How is this possible ?

For example, the graph below is generated by rdflib and many unused prefixes are serialized together:

@prefix child: <http://opensensingcity.emse.fr/ldpdfend/paris/d1/catalog/> .
@prefix dcat: <http://www.w3.org/ns/dcat#> .
@prefix dcterms: <http://purl.org/dc/terms/> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix ldp: <http://www.w3.org/ns/ldp#> .
@prefix parent: <http://opensensingcity.emse.fr/ldpdfend/paris/d1/> .
@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#> .

parent:catalog a ldp:BasicContainer,
        ldp:Container,
        ldp:RDFSource ;
    ldp:contains child:datasets ;
    foaf:primaryTopic <https://opendata.paris.fr/api/v2/catalog/exports/ttl> .

<https://opendata.paris.fr/api/v2/catalog/exports/ttl> a dcat:Catalog ;
    dcterms:Language <http://id.loc.gov/vocabulary/iso639-1/en>,
        <http://id.loc.gov/vocabulary/iso639-1/fr> ;
    dcterms:description "Parisdata Catalog" ;
    dcterms:publisher <http://www.opendatasoft.com> ;
    dcterms:title "Parisdata's catalog" ;
    dcat:themeTaxonomy <https://opendata.paris.fr/concept-scheme/themes> ;
    foaf:homepage <https://opendata.paris.fr> .

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions