Open edmondchuc opened 2 years ago
Python version 3.10.0 RDFLib version 6.1.1
Round-tripping Turtle removes prefix declaration for
rdf
and results in an invalid Turtle file.
Thanks for providing a useful example, I was able to confirm the issue. Glad you have a workaround to resolve your immediate problem.
I suspect there must be some logic in the Turtle serialiser where it ignores the "existence" of
rdf:type
because usually it is used asa
in the predicate position. However, the serialiser should not ignorerdf:type
when it is in the object position.
Happily, I can report that the repos master (6.2alpha) is free of the issue. Looks like LoC#260 of the turtle serializer may be implicated, in 6.2 it's been changed from:
if node in self.keywords:
continue
to
if i == VERB and node in self.keywords:
# predicate is a keyword
continue
and locally making that one change to 6.1.1 enables your example to execute without issue.
Python version 3.10.0 RDFLib version 6.1.1
Round-tripping Turtle removes prefix declaration for
rdf
and results in an invalid Turtle file.I have the following Turtle file
meta.shacl.ttl
:Round-tripping it with rdflib:
Result:
If I attempt to call
Graph.parse()
again, I get:My workaround is to refer to something else besides
rdf:type
in therdf
namespace.Round-tripping now works correctly because I am referring to
rdf:Property
.I suspect there must be some logic in the Turtle serialiser where it ignores the "existence" of
rdf:type
because usually it is used asa
in the predicate position. However, the serialiser should not ignorerdf:type
when it is in the object position.