class MultiXml::Parsers::Ox::Handler

def append(key, value)

def append(key, value)
  key = key.to_s
  h = @stack.last
  if h.key?(key)
    v = h[key]
    if v.is_a?(Array)
      v << value
    else
      h[key] = [v, value]
    end
  else
    h[key] = value
  end
end

def attr(name, value)

def attr(name, value)
  append(name, value) unless @stack.empty?
end

def cdata(value)

def cdata(value)
  append(MultiXml::CONTENT_ROOT, value)
end

def doc

def doc
  @stack[0]
end

def end_element(_)

def end_element(_)
  @stack.pop
end

def error(message, line, column)

def error(message, line, column)
  raise(StandardError, "#{message} at #{line}:#{column}")
end

def initialize

def initialize
  @stack = []
end

def start_element(name)

def start_element(name)
  @stack.push({}) if @stack.empty?
  h = {}
  append(name, h)
  @stack.push(h)
end

def text(value)

def text(value)
  append(MultiXml::CONTENT_ROOT, value)
end