class Nokogiri::XML::Builder

def [](ns)

ArgumentError if +ns+ has not been defined higher in the tree.
Build a tag that is associated with namespace +ns+. Raises an
##
def [](ns)
  if @parent != @doc
    @ns = @parent.namespace_definitions.find { |x| x.prefix == ns.to_s }
  end
  return self if @ns
  @parent.ancestors.each do |a|
    next if a == doc
    @ns = a.namespace_definitions.find { |x| x.prefix == ns.to_s }
    return self if @ns
  end
  @ns = { pending: ns.to_s }
  self
end