def traverse(sexp, visitor, context=Visitor::Context.new)
      element_name, attrs, children = decompose_sexp(sexp)
      
      non_ns_attrs, ns_bindings = Namespace::non_ns_attrs_ns_bindings(context.ns_stack, element_name, attrs)

      context.ns_stack.push(ns_bindings)

      eelement_name = Namespace::explode_qname(context.ns_stack, element_name)
      eattrs = Namespace::explode_attr_qnames(context.ns_stack, non_ns_attrs)

      begin
        visitor.element(context, eelement_name, eattrs, ns_bindings) do
          children.each_with_index do |child, i|
            if child.is_a?(Array)
              traverse(child, visitor, context)
            else
              visitor.text(context, child)
            end
          end
        end
      ensure
        context.ns_stack.pop
      end

      visitor
    end
def traverse(sexp, visitor, context=Visitor::Context.new)
      element_name, attrs, children = decompose_sexp(sexp)
      
      non_ns_attrs, ns_bindings = Namespace::non_ns_attrs_ns_bindings(context.ns_stack, element_name, attrs)

      context.ns_stack.push(ns_bindings)

      eelement_name = Namespace::explode_qname(context.ns_stack, element_name)
      eattrs = Namespace::explode_attr_qnames(context.ns_stack, non_ns_attrs)

      begin
        visitor.element(context, eelement_name, eattrs, ns_bindings) do
          children.each_with_index do |child, i|
            if child.is_a?(Array)
              traverse(child, visitor, context)
            else
              visitor.text(context, child)
            end
          end
        end
      ensure
        context.ns_stack.pop
      end

      visitor
    end
pre-order traversal of the sexp, calling methods on
 the visitor with each node