Skip to content

[IO] Add formatting and serialization options to RDF serializers #616

Description

@remiceres

Summary

Introduce configurable formatting and serialization options to RDF serializers in core.next.io (CoreseIO), allowing callers to control layout, density, determinism, and syntax optimizations according to target use cases (streaming, human inspection, reproducible diffs).

Objectives and Technical Scope

1. Layout and Density Profiles

• Compact single-line mode: Minimal whitespace, single statement per line, stripped comments, optimized for network streaming, REST endpoints, and IPC.
• Pretty-print indented mode: Human-friendly indentation, aligned predicate-object blocks, and grouped subject declarations.

2. Deterministic and Canonical Sorting

• Sorted / Canonical mode: Deterministic lexicographical ordering of subjects, predicates, and objects (crucial for reproducible builds, content hashing, and clean git diffs).

3. Prefix and Namespace Management Strategies

• Inlined full IRIs vs Abbreviated prefixes: Option to omit prefix headers and emit expanded IRIs (lowering parser state overhead) or greedily abbreviate common prefixes.
• Base IRI handling: Relative vs absolute IRI resolution policies.

4. Blank Node Presentation Policies

• Anonymous tree syntax: Nest blank nodes using bracket notation [ ... ] where acyclic.
• Explicit blank node identifiers: Force explicit labeled blank nodes (_:b0, _:b1) for predictable round-tripping.

5. String Literal Representation

• Multi-line triple-quoted strings vs escaped single-line strings.

6. Configuration API

• Expose formatting options via a builder pattern in CoreseIO serialization parameters.
• Apply uniformly across standard RDF formats (Turtle, TriG, N-Triples, N-Quads).

Acceptance Criteria

[ ] Serializer configuration builder exposes layout, sorting, prefix, and blank node options.
[ ] Compact profile produces valid, dense syntax with minimal character overhead.
[ ] Canonical mode produces byte-for-byte identical output for equivalent graph contents.
[ ] Pretty-print mode formats nested blank nodes and aligned predicate lists cleanly.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureNew feature or capability

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions