Skip to content

Longturtle serialisation loses namespace prefixes #3105

Open
@ddeschepper

Description

@ddeschepper

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 ;
# .

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions