-
Notifications
You must be signed in to change notification settings - Fork 579
Open
Description
I'm trying to serialize XMLLiterals with canonical XML using rdflib and encountered this unhelpful code:
https://github.com/RDFLib/rdflib/blob/main/rdflib/term.py#L1784
Can we just remove any "normalization" and let the user take care of that?
Code to reproduce:
from rdflib import Graph, Literal, URIRef
from rdflib.namespace import RDF
# C14N XML with explicit closing tag (correct)
xml_input = '<div xmlns="http://www.w3.org/1999/xhtml" class="test"></div>'
print(f"Input XML: {xml_input}")
# Create XMLLiteral
g = Graph()
g.add((URIRef("http://test"), RDF.value, Literal(xml_input, datatype=RDF.XMLLiteral)))
# Serialize to N-Triples
nt = g.serialize(format='nt')
print(f"\nN-Triples output:")
print(nt)Output:
Input XML: <div xmlns="http://www.w3.org/1999/xhtml" class="test"></div>
N-Triples output:
<http://test> <http://www.w3.org/1999/02/22-rdf-syntax-ns#value> "<div xmlns=\"http://www.w3.org/1999/xhtml\" class=\"test\"/>"^^<http://www.w3.org/1999/02/22-rdf-syntax-ns#XMLLiteral> .
In c14n XML there are no self-closing tags.
Metadata
Metadata
Assignees
Labels
No labels