Skip to content

Longturtle serialisation loses namespace prefixes #3105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ddeschepper opened this issue Mar 31, 2025 · 2 comments
Open

Longturtle serialisation loses namespace prefixes #3105

ddeschepper opened this issue Mar 31, 2025 · 2 comments

Comments

@ddeschepper
Copy link

The introduction of deterministic longturtle serialisation in 7.1.3 introduces a bug where namespace prefixes are no longer applied.

The reproduction below shows the namespace prefixes working correctly in regular Turtle, but not in Longturtle. Downgrading to 7.1.1 makes the namespace prefixes work.

# Using rdflib==7.1.3 or rdflib==7.1.4
from rdflib import Graph, Namespace, URIRef

graph = Graph()
graph.add((
    URIRef("https://example.com/subject"),
    URIRef("https://example.com/predicate"),
    URIRef("https://example.com/object")
))
graph.bind("ex", Namespace("https://example.com/"))

print(graph.serialize(format="turtle"))
# @prefix ex: <https://example.com/> .
# 
# ex:subject ex:predicate ex:object .

print(graph.serialize(format="longturtle"))
# PREFIX ns1: <https://example.com/>
# 
# ns1:subject
#     ns1:predicate ns1:object ;
# .
@ddeschepper
Copy link
Author

My PR #3106 solves this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants
@ddeschepper and others