Bounded by design
Parse from an io.Reader with explicit chunk, statement, token, nesting, and triple limits.
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.
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))
}
A focused foundation for RDF tooling in Odin
Engineered for real input
The library stays out of your storage model and concentrates on trustworthy syntax boundaries.
Parse from an io.Reader with explicit chunk, statement, token, nesting, and triple limits.
Callback string validity is documented precisely, including input-backed and decoded terms.
Every pinned W3C positive and negative syntax case runs through memory and streaming paths.
Stable error codes, allocation-free messages, and exact one-based line and column locations.
Parsed blank nodes carry document-local scope across both complete and incremental parsing.
Format a complete Turtle graph into stable grouped output with safe prefix inference, while preserving the streaming writer for pipelines.
Standards without overclaiming
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
Deliberately separate
Quick start
Clone or vendor the repository into your Odin source tree, import the two packages, then choose the in-memory or bounded-reader entry point.
# 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
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.