Class: Lutaml::Xml::HoistingAlgorithm::Base

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

Overview

Base class for hoisting algorithms

Subclasses implement should_hoist_here? to determine if a namespace should be declared at a given element.

Direct Known Subclasses

FirstUsage, LCA, NamespaceScopeOnly, Preserved

Instance Method Summary collapse

Instance Method Details

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

Determine if namespace should be declared at this element

Parameters:

  • Current element

  • Namespace class to check

  • All namespace needs

  • Context including:

    • :is_root [Boolean] Whether this is root element
    • :parent_hoisted [Hash] Namespaces already declared on ancestors
    • :stored_plan [DeclarationPlan, nil] Stored plan from parsing

Returns:

  • true if namespace should be declared here

Raises:



38
39
40
41
# File 'lib/lutaml/xml/hoisting_algorithm.rb', line 38

def should_hoist_here?(element, namespace_class, needs, context)
  raise NotImplementedError,
        "Subclasses must implement should_hoist_here?"
end