Class: Lutaml::Xml::HoistingAlgorithm::LCA

Inherits:
Base
  • Object
show all
Defined in:
lib/lutaml/xml/hoisting_algorithm.rb

Overview

LCA (Lowest Common Ancestor) Algorithm

Declares namespace at the smallest subtree covering all usages. This is more compact XML but wider namespace scope.

Examples:

<parent xmlns:ns="...">     <!-- LCA of child1 and child2 -->
  <ns:child1>...</ns:child1>
  <ns:child2>...</ns:child2>
</parent>

Instance Method Summary collapse

Instance Method Details

#should_hoist_here?(element, namespace_class, _needs, context) ⇒ Boolean

Returns:

  • (Boolean)


83
84
85
86
87
# File 'lib/lutaml/xml/hoisting_algorithm.rb', line 83

def should_hoist_here?(element, namespace_class, _needs, context)
  return false if already_hoisted?(namespace_class, context)

  element_needs_namespace?(element, namespace_class)
end