the following does not (notice that the predicate is now simply <> but could be any unprefixable IRI outside the graph's namespaces, e.g., <http://>):
from rdflib import Graph
g = Graph().parse(data='<a> <> "test"@en .', publicID="http://example.org/")
g.print(format="xml")
Traceback:
Traceback (most recent call last):
File "testing.py", line 7, in <module>
g.print(format="xml")
File "/home/username/.local/lib/python3.8/site-packages/rdflib/graph.py", line 1370, in print
self.serialize(None, format=format, encoding=encoding).decode(encoding),
File "/home/username/.local/lib/python3.8/site-packages/rdflib/graph.py", line 1340, in serialize
serializer.serialize(stream, base=base, encoding=encoding, **args)
File "/home/username/.local/lib/python3.8/site-packages/rdflib/plugins/serializers/rdfxml.py", line 73, in serialize
bindings = list(self.__bindings())
File "/home/username/.local/lib/python3.8/site-packages/rdflib/plugins/serializers/rdfxml.py", line 29, in __bindings
prefix, namespace, name = nm.compute_qname_strict(predicate)
File "/home/username/.local/lib/python3.8/site-packages/rdflib/namespace/__init__.py", line 552, in compute_qname_strict
prefix, namespace, name = self.compute_qname(uri, generate)
File "/home/username/.local/lib/python3.8/site-packages/rdflib/namespace/__init__.py", line 516, in compute_qname
raise e
File "/home/username/.local/lib/python3.8/site-packages/rdflib/namespace/__init__.py", line 510, in compute_qname
namespace, name = split_uri(uri)
File "/home/username/.local/lib/python3.8/site-packages/rdflib/namespace/__init__.py", line 817, in split_uri
raise ValueError("Can't split '{}'".format(uri))
ValueError: Can't split 'http://example.org/'
The same applies for both RDF/XML serializers. TTL output works as expected, though.
Whilst the following works (despite the fact that the base IRI (publicID) should not be saved in prefixes)
output:
the following does not (notice that the predicate is now simply
<>
but could be any unprefixable IRI outside the graph's namespaces, e.g.,<http://
>):Traceback:
The same applies for both RDF/XML serializers. TTL output works as expected, though.