def explode_qname(ns_stack, qname, attr=false)
      if qname.is_a?(Array)
        local_part, prefix, uri = qname
        if uri
          raise "invalid name: #{qname.inspect}" if !prefix
          bound_uri = find_namespace_uri(ns_stack, prefix)
          raise "namespace conflict: prefix '#{prefix}' refers to '#{uri}' and '#{bound_uri}'" if bound_uri && uri != bound_uri
          return [local_part, prefix, uri]
        elsif prefix
          uri = find_namespace_uri(ns_stack, prefix)
          raise "namespace prefix not bound: '#{prefix}'" if !uri
          return [local_part, prefix, uri]
        else
          return local_part
        end
      end

      local_part, prefix = split_qname(qname)
      if prefix
        if prefix=="xmlns" && attr
          [local_part, prefix]
        else
          uri = find_namespace_uri(ns_stack, prefix)
          raise "namespace prefix not bound: '#{prefix}'" if ! uri
          [local_part, prefix, uri]
        end
      else
        if attr
          local_part
        else
          default_uri = find_namespace_uri(ns_stack, "")
          if default_uri
            [local_part, "", default_uri]
          else
            local_part
          end
        end
      end
    end
def explode_qname(ns_stack, qname, attr=false)
      if qname.is_a?(Array)
        local_part, prefix, uri = qname
        if uri
          raise "invalid name: #{qname.inspect}" if !prefix
          bound_uri = find_namespace_uri(ns_stack, prefix)
          raise "namespace conflict: prefix '#{prefix}' refers to '#{uri}' and '#{bound_uri}'" if bound_uri && uri != bound_uri
          return [local_part, prefix, uri]
        elsif prefix
          uri = find_namespace_uri(ns_stack, prefix)
          raise "namespace prefix not bound: '#{prefix}'" if !uri
          return [local_part, prefix, uri]
        else
          return local_part
        end
      end

      local_part, prefix = split_qname(qname)
      if prefix
        if prefix=="xmlns" && attr
          [local_part, prefix]
        else
          uri = find_namespace_uri(ns_stack, prefix)
          raise "namespace prefix not bound: '#{prefix}'" if ! uri
          [local_part, prefix, uri]
        end
      else
        if attr
          local_part
        else
          default_uri = find_namespace_uri(ns_stack, "")
          if default_uri
            [local_part, "", default_uri]
          else
            local_part
          end
        end
      end
    end
split a QName into [LocalPart, prefix, URI] triple. fill out
 missing uris if necessary, and check QName is well specified