class Lutaml::Model::XmlAdapter::Builder::Ox

def self.build(options = {})

def self.build(options = {})
  if block_given?
    ::Ox::Builder.new(options) do |xml|
      yield(new(xml))
    end
  else
    new(::Ox::Builder.new(options))
  end
end

def <<(text)

def <<(text)
  xml.text(text)
end

def add_element(element, child)

def add_element(element, child)
  element << child
end

def add_namespace_prefix(prefix)

current namespace prefix to add it to the element's name later.
Ox doesn't support XML namespaces so we only save the

Add XML namespace to document
def add_namespace_prefix(prefix)
  @current_namespace = prefix
  self
end

def add_text(element, text)

def add_text(element, text)
  element << text
end

def create_and_add_element(element_name, prefix: nil, attributes: {})

def create_and_add_element(element_name, prefix: nil, attributes: {})
  prefixed_name = if prefix
                    "#{prefix}:#{element_name}"
                  elsif @current_namespace && !element_name.start_with?("#{@current_namespace}:")
                    "#{@current_namespace}:#{element_name}"
                  else
                    element_name
                  end
  if block_given?
    xml.element(prefixed_name, attributes) do |element|
      yield(self.class.new(element))
    end
  else
    xml.element(prefixed_name, attributes)
  end
  @current_namespace = nil
end

def create_element(name, attributes = {})

def create_element(name, attributes = {})
  if @current_namespace && !name.start_with?("#{@current_namespace}:")
    name = "#{@current_namespace}:#{name}"
  end
  if block_given?
    xml.element(name, attributes) do |element|
      yield(self.class.new(element))
    end
  else
    xml.element(name, attributes)
  end
end

def initialize(xml)

def initialize(xml)
  @xml = xml
  @current_namespace = nil
end

def method_missing(method_name, *args)

def method_missing(method_name, *args)
  if block_given?
    xml.public_send(method_name, *args) do
      yield(xml)
    end
  else
    xml.public_send(method_name, *args)
  end
end

def parent

def parent
  xml
end

def respond_to_missing?(method_name, include_private = false)

def respond_to_missing?(method_name, include_private = false)
  xml.respond_to?(method_name) || super
end