managing the RDFLib NamespaceManager

Adam Funk a24061 at ducksburg.com
Tue Mar 14 09:50:12 EDT 2017


I'm using RDFLib 4.2.2 (installed with pip3) in Python 3.5.2, and the
automatic behaviour of the NamespaceManager is giving me conniptions,
because the automatically generated namespaces go too far to the right
in the URIs and make the right-hand parts of the QNames meaningless.

For example, I have this code:

nsMgr     = NamespaceManager(rdflib.Graph())
nsMgr.bind('dbpedia', Namespace('http://dbpedia.org/resource/'))
# plus some others


but in the serialized RDF I get these (and some other ns-numbered
ones):

@prefix dbpedia: <http://dbpedia.org/resource/> .
@prefix ns3: <http://dbpedia.org/resource/Category%3> .
@prefix ns5: <http://dbpedia.org/resource/2> .

and obviously the QName outputs are wrong.  Is there any way to make
an RDFLib NamespaceManager *not* generate any namespaces
automatically?

Thanks,
Adam


More information about the Python-list mailing list