Guarantees and verification for perfect DOCX round-trip preservation.

1. Round-Trip Guarantee

Uniword achieves 100% round-trip fidelity for DOCX documents through complete OOXML modeling. Every OOXML element is represented as a Ruby object via lutaml-model, ensuring that load-modify-save cycles preserve all original content.

Guarantee Details

Content preservation

All text, formatting, and structure maintained

Element coverage

All 760 OOXML elements from 22 namespaces modeled

Namespace compliance

All required OOXML namespaces supported

Encoding

UTF-8 encoding maintained throughout

Model-driven

All XML structures represented as Ruby objects

2. Round-Trip Example

# Load document
original = Uniword::Document.open('complex.docx')

# Modify it
original.add_paragraph("New content")

# Save back -- EVERYTHING preserved
original.save('modified.docx')

# Verify: modified.docx has ALL original content + new paragraph

3. Test Results

Test Case Result

ISO 8601 DOCX (295KB)

100% fidelity

MHTML documents

Content preserved

Math equations

Preserved via m: namespace

Bookmarks

Native support with ID preservation

Complex documents

Perfect round-trip with schema-driven architecture

4. Verification with the CLI

Use the uniword verify command to validate document structure:

# Full verification (OPC + semantic)
uniword verify document.docx

# Enable XSD schema validation (slower, thorough)
uniword verify document.docx --xsd

# Machine-readable output
uniword verify document.docx --json

The verifier runs three layers of checks:

  1. OPC Package — ZIP integrity, content types, relationships, part presence

  2. XSD Schema — XML schema validation against 40 bundled XSD schemas

  3. Word Document — 10 built-in semantic rules for cross-references, styles, numbering, footnotes, headers, bookmarks, images, tables, fonts, theme, and settings

5. Custom Validation

Register custom validation rules for domain-specific checks:

Uniword::Validation::Rules.register(MyCustomRule)