-
Notifications
You must be signed in to change notification settings - Fork 577
Description
I have found that rdflib's handling of cURIEs for entities within an ontology's own namespace is somewhat difficult.
One of the issues is already documented (#2077) - namely, that NamesapceManager does not handle mapping multiple prefixes to a single URI.
I also see that a cURIE like :my_class
is rejected by expand_curie()
as invalid. It seems like it should be valid though, based on https://www.w3.org/TR/curie/#s_syntax, in particular
A host language MAY declare a default prefix value, or MAY provide a mechanism for defining a default prefix value. In such a host language, when the prefix is omitted from a CURIE, the default prefix value MUST be used.
rdflib does record the default prefix value, mapping it to the empty string, as can be seen by examining NamespaceManager.namespaces() - but that default value is never used in expand_curie()
. The problematic code appears to be
rdflib/rdflib/namespace/__init__.py
Line 618 in 5c3c78a
if len(parts) != 2 or len(parts[0]) < 1: |
namespaces()
.
The two issues make it difficult (impossible?) to expand a CURIE for an entity in the default namespace of an ontology:
- The default namespace prefix is inaccessible per the above
- A substitute prefix, mapping to the same namespace, is dropped by NamespaceManager, per rdflib 6.2.0 SPARQL parsing regression: multiple prefixes for same IRI not supported? #2077.
Is there a workaround via which I could write a CURIE that maps to an item in a parsed ontology (e.g. one stored in RDF/XML), such that rdflib could expand it to the correct URI?