rdf4j: Adding a Model to a repository doesn't transfer its namespaces

When adding a Model to a Repository with conn.add(model), its namespaces get lost. Writing the repo to a file like

RDFWriter writer = Rio.createWriter(RDFFormat.TURTLE, outputStream);
conn.export(writer);

produces a very unreadable Turtle file with no prefixes.

Only after manually re-adding them like this

for (Namespace ns : ontologyNamespaces) {
    conn.setNamespace(ns.getPrefix(), ns.getName());
}

does the output actually contain prefixes. It definitely the act of adding the model and not the RDFwriter’s fault.

If this is a bug, I’d be happy to contribute. If this is expected behavior (which is counter-intuitive in my opinion), is there a nicer way to include the namespaces when importing?

VERSION: 3.4.4

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (16 by maintainers)

Commits related to this issue

Most upvoted comments

Not a problem @Dzeri96. If you need a second pair of eyes to figure it out don’t hesitate to shout!

@jeenbroekstra I’m sorry I haven’t started sooner, but as usual some things came up. I’m planing to start working on this in two days, though I can’t estimate how long the actual work will take. I will keep you posted as soon as I have something worthwhile.

If others agree, I’d like to work on this when I have some free time. ETA for a PR is mid-february if the issue is not too complicated