class MultiXml::Parsers::Ox::Handler

def append(key, value)

def append(key, value)
  key = key.to_s
  h = @stack.last
  if h.has_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)
  unless @stack.empty?
    append(name, value)
  end
end

def cdata(value)

def cdata(value)
  append('__content__', value)
end

def doc

def doc
  @stack[0]
end

def end_element(name)

def end_element(name)
  @stack.pop()
end

def error(message, line, column)

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

def initialize()

def initialize()
  @stack = []
end

def start_element(name)

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

def text(value)

def text(value)
  append('__content__', value)
end