Skip to content
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

Graph.serialize strips some prefixes when emitting RDF/XML, but not turtle #2364

Open
jclerman opened this issue Apr 18, 2023 · 0 comments
Open
Labels
core Relates to core functionality of RDFLib, i.e. `rdflib.{graph,store,term}`

Comments

@jclerman
Copy link
Contributor

rdflib version 6.3.2 (latest)

This problem seems like it might be related to #1997, but is different inasmuch as it is affected by serialization step of a parsed graph, rather than the parsing step.

I have an RDF file (in RDF/XML format, and a *.owl filename extension in case that matters) with several prefixes defined at the beginning. All of the prefixes are preserved in the result of:

from rdflib import Graph

g = Graph().parse("myfile.owl")
list(g.namespaces)

If I serialize via `g.serialize(format="xml") then some of the prefixes are lost - it looks like any prefixes that aren't actually used in the input RDF are dropped, which is surprising (after parsing, does the Graph object retain that information?). The presence of the mapped namespaces in URIs used in the RDF does not seem to matter (i.e., those namespaces are found in some of the URIs in the content).

If I serialize via `g.serialize(format="turtle") then my original prefixes are preserved. Yay, but... eh?

@aucampia aucampia added the core Relates to core functionality of RDFLib, i.e. `rdflib.{graph,store,term}` label May 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Relates to core functionality of RDFLib, i.e. `rdflib.{graph,store,term}`
Projects
None yet
Development

No branches or pull requests

2 participants