Module: Uniword::Docx::Reconciler::ReferentialIntegrity

Included in:
Uniword::Docx::Reconciler
Defined in:
lib/uniword/docx/reconciler/referential_integrity.rb

Overview

Cross-part referential integrity enforcement.

Verifies and repairs references between document.xml and other package parts. Both the allocator (builder) path and the legacy (template-loaded) path repair by stripping: identical input yields identical referential outcome regardless of path. Unrepairable leftovers are rejected by the write-time PackageIntegrityChecker.

  • For removable inline refs (notes, hyperlinks, drawings): strip
  • For structural refs (styles, numbering): strip
  • For relationship refs (rId): reconcile against actual parts
  • For relationship targets: strip rels whose target part the package does not carry (the part is never re-emitted, so the rel would dangle in the saved package)
  • For uniqueness constraints: deduplicate with deterministic resolution

Instance Method Summary collapse

Instance Method Details

#reconcile_referential_integrityObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/uniword/docx/reconciler/referential_integrity.rb', line 21

def reconcile_referential_integrity
  return unless package.document&.body

  reconcile_note_body_references(:footnote)
  reconcile_note_body_references(:endnote)
  reconcile_sect_pr_references
  reconcile_image_references
  reconcile_hyperlink_references
  ensure_para_id_uniqueness
  ensure_rid_uniqueness
  reconcile_relationship_targets

  reconcile_style_references
  reconcile_style_inheritance
  reconcile_numbering_body_references
end