W3C 2,432/2,432 RDF 1.1 MIT

RDF pipelines,
built the Odin way.

A small, streaming-first RDF toolkit with conformant RDF syntax parsing, bounded JSON-LD document APIs, deterministic formatting, W3C dataset canonicalization, and a loss-aware conversion CLI. Explicit lifetimes. Predictable limits. No graph store attached.

2,432/2,432
Pinned W3C gate cases
3 OS
Linux, macOS, Windows
Bounded
Configurable streaming limits
main.odin
import rdf "odin-rdf/rdf"
import ttl "odin-rdf/rdf/turtle"

consume :: proc(triple: rdf.Triple,
                _: rawptr) -> bool {
  process(triple)
  return true
}

err := ttl.parse(input, consume)
if err.code != .None {
  report(err.line, err.column,
         ttl.parse_error_message(err.code))
}
✓ streaming · ✓ zero-copy paths · ✓ exact locations

A focused foundation for RDF tooling in Odin

N-Triples N-Quads Turtle io.Reader Sink pipelines

Engineered for real input

Small surface. Serious guarantees.

The library stays out of your storage model and concentrates on trustworthy syntax boundaries.

01 / stream

Bounded by design

Parse from an io.Reader with explicit chunk, statement, token, nesting, and triple limits.

02 / own

Explicit lifetimes

Callback string validity is documented precisely, including input-backed and decoded terms.

03 / verify

Conformance first

Every pinned W3C positive and negative syntax case runs through memory and streaming paths.

04 / locate

Actionable diagnostics

Stable error codes, allocation-free messages, and exact one-based line and column locations.

05 / identify

Correct blank nodes

Parsed blank nodes carry document-local scope across both complete and incremental parsing.

06 / format

Readable graphs on demand

Format a complete Turtle graph into stable grouped output with safe prefix inference, while preserving the streaming writer for pipelines.

Standards without overclaiming

Clear about what is—and is not—implemented.

The current work includes bounded JSON-LD-to-RDF, Expansion, Flattening, Compaction, Framing, and explicit Remote Document / HTML JSON-LD entry points. Applications supply their own transport policy; the library has no hidden network client. It also provides bidirectional RDF/XML default-graph processing, conformant TriG parsing and streaming-safe TriG serialization, complete W3C RDFC-1.0 canonicalization with bounded hashes, isomorphism checks, and deterministic dataset diffs.

Read the W3C RDFC-1.0 specification →

Included

  • RDF IRI, blank-node, literal terms
  • Triple position invariants
  • N-Triples parser and writer
  • Quad model and N-Quads syntax
  • Conformant Turtle parser, writer, and formatter
  • Bounded JSON-LD to-RDF, Expand, Flatten, Compact, and Frame APIs
  • Explicit callback-driven Remote Documents and HTML JSON-LD extraction
  • Bounded RDF/XML input, batch writer, and stateful document writer
  • Conformant TriG parser, streaming writer, and dataset formatter
  • W3C RDFC-1.0 canonicalization with SHA-256 and SHA-384
  • Canonical dataset hashing and isomorphism checks
  • Deterministic canonical dataset change diffs
  • Owned, capacity-bounded quad collection
  • Streaming syntax conversion CLI
  • UTF-8 and escape handling
  • W3C syntax conformance suite

Deliberately separate

  • Built-in HTTP transport, authentication, and cache policy
  • RDFS and OWL reasoning
  • SKOS and Dublin Core
  • Graph or dataset storage
  • SPARQL execution

Quick start

From bytes to triples in one callback.

Clone or vendor the repository into your Odin source tree, import the two packages, then choose the in-memory or bounded-reader entry point.

terminal
# verify the core model and syntax package
odin test rdf
odin test rdf/ntriples
odin test rdf/nquads
odin test rdf/turtle
odin test rdf/rdfxml
odin test rdf/canon

# group and normalize a complete Turtle graph
odin-rdf format input.ttl --output formatted.ttl
odin-rdf format input.ttl --max-triples 100000

# stream records or atomically write a bounded RDF/XML graph
odin-rdf convert input.nt --output output.nq --max-records 100000
odin-rdf convert input.nt --output output.rdf --max-records 100000
odin-rdf convert input.trig --to jsonld --max-records 100000 --output output.jsonld
odin-rdf convert input.nt --to jsonld --context context.jsonld --max-records 100000 --output compact.jsonld

# canonicalize, hash, compare, or diff a bounded dataset
odin-rdf canon input.trig --output canonical.nq --max-quads 100000
odin-rdf hash input.ttl --algorithm sha384
odin-rdf compare previous.trig current.trig
odin-rdf diff before.trig after.trig --output changes.nqdiff

# run the official pinned conformance suite
./scripts/run-w3c-tests.sh
./scripts/run-w3c-nquads-tests.sh
./scripts/run-w3c-turtle-tests.sh
./scripts/run-w3c-rdfxml-tests.sh
./scripts/run-w3c-rdf-canon-tests.sh

Pinned core gates:
2,432 pinned W3C cases, 0 failures

Version 0.33.0

Review canonical RDF dataset changes in the shell.

RDFC-1.0 canonical N-Quads gives complete RDF datasets stable blank-node labels. Canonicalize, hash, compare, or produce deterministic change diffs directly from the command line, with an explicit bounded collection policy for adversarial graph shapes.

Explore odin-rdf