Skip to content

ADR-0021: Deterministic semantic serializers for RDF/XML and OWL/XML

Status: Accepted
Date: 2026-07-13
Target: OntoCode v0.21.0

Context

Turtle and OBO write-back use source-text patches (ADR-0006, ADR-0019). RDF/XML and OWL/XML cannot share that strategy without fragile XML span surgery. v0.21 requires open → edit → save → reload without semantic loss (PRE_1_0_PHASES, BLOCKER_01).

Horned-OWL already provides RDF/XML and OWL/XML writers. OntoCore must adopt them as first-class save backends on top of the semantic transaction layer (ADR-0020).

Decision

  1. Semantic re-serialize RDF/XML (.rdf, .owl) and OWL/XML (.owx) after applying PatchOp transactions to an in-memory Horned ontology.
  2. Semantic fidelity over textual fidelity — whitespace, comment placement, and prefix declaration style may change; catalog/axiom comparison is the acceptance oracle.
  3. Stable emission rules
  4. Preserve ontology IRI / version IRI when present.
  5. Emit imports as Horned Import components.
  6. Prefer prefix maps supplied by the document / workspace namespaces; supplement with standard rdf / rdfs / owl prefixes.
  7. Annotation assertions (including rdfs:label / rdfs:comment) round-trip as Horned AnnotationAssertion.
  8. Round-trip verification uses a cross-format semantic comparator (entity IRIs, labels, parents, imports, ontology IRI) — not byte equality.
  9. Turtle and OBO continue to use existing patch engines; only XML formats use this path.

Consequences

Positive

  • Unlocks inspector / CLI / LSP edit for required Protégé interchange formats.
  • Reuses Horned as the single OWL model for XML serialize (ADR-0013).
  • Aligns with ADR-0020 transaction apply for all formats.

Negative

  • Save may reorder XML elements and rewrite prefixes.
  • Incomplete Horned RDF parses remain a risk; incomplete loads surface as diagnostics rather than silent data loss.

Follow-ups

  • v0.22 closes remaining OWL 2 authoring gaps across serializers.
  • Richer blank-node / anonymous expression coverage as fixture corpus expands.