apache / apache/jena

More granular control over Blank node serialization

Open
#2,549 1 comment 1 reaction 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
1.4k
Forks
712
Avg merge
15h 41m
Merged PRs (30d)
53

Description

### Version

4.10.0

### Feature

When serializing a `DatasetGraph` into NQ format, I find that all blank nodes with specified labels get a "B" prepended to the label, e.g. a blank node with a label "students" would be serialized as "_:Bstudents".
This is somewhat annoying for my use case: an RML engine needs to follow a particular spec, including filling in blank node patterns.

My workaround currently consists of Regex replacing, but this is far from ideal.

I'd like to suggest a more granular control of how the NQ writer (and all writers in general) handle Blank nodes: give the user an option to preserve the original blank node without prepending a "B" in front of the label.

Code example that performs the serialization:
```java
DatasetGraph graph = ...; // some graph
OutputStream out = new ByteArrayOutputStream();
RDFWriter.source(graph)
.lang(Lang.NQ)
.output(out);
String serialized = out.toString().replaceAll("_:B", "_:");
```

### Are you interested in contributing a solution yourself?

Perhaps?

Contributor guide

Open the contributing guide

Research direction

Start with the RDFWriter.source(graph).lang(Lang.NQ).output(out) entry point and the DatasetGraph serialization path described in the example. Determine where blank-node labels receive the "B" prefix and how writer options are exposed. Done means NQ and other writers offer a documented granular option that preserves the original blank-node label without requiring regex replacement.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.