Giter Site home page Giter Site logo

Comments (3)

LvanWissen avatar LvanWissen commented on June 8, 2024

But in Turtle syntax the rdfs: translates to a valid URI.

I don't think there is a way to unbind a prefix from the NamespaceManager, which automatically binds some 'core prefixes':

for prefix, ns in _NAMESPACE_PREFIXES_CORE.items():
self.bind(prefix, ns)
)

Either pick a different serialization format (e.g. nt), or write your own custom NamespaceManager. But keep in mind that the rdfs: bit is valid RDF.

from rdflib.

edmondchuc avatar edmondchuc commented on June 8, 2024

Is this what you want?

from rdflib import Graph, URIRef, Literal, RDF, OWL, DC


graph = Graph()
graph.namespace_manager.bind("rdfs", None, replace=True)

rdfs = URIRef("http://www.w3.org/2000/01/rdf-schema#")

graph.add((
    rdfs, RDF.type, OWL.Ontology
))
graph.add((
    rdfs, DC.title, Literal("The RDF Schema vocabulary (RDFS)")
))

graph.print()

Output:

@prefix dc: <http://purl.org/dc/elements/1.1/> .
@prefix owl: <http://www.w3.org/2002/07/owl#> .

<http://www.w3.org/2000/01/rdf-schema#> a owl:Ontology ;
    dc:title "The RDF Schema vocabulary (RDFS)" .

Looks like binding an existing prefix with None with the optional replace=True will "unbind" the prefix.

from rdflib.

rbuck-som avatar rbuck-som commented on June 8, 2024

from rdflib.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.