# File rexml/quickpath.rb, line 20 def QuickPath::match element, path, namespaces=EMPTY_HASH raise "nil is not a valid xpath" unless path results = nil Functions::namespace_context = namespaces case path when /^\([^\]|$)/u # match on root path = path[1..-1] return [element.root.parent] if path == '' results = filter([element.root], path) when /^[-\]*::/u results = filter([element], path) when /^\/u results = filter(element.to_a, path) when /^[[!\_:]/u # match on child matches = [] children = element.to_a results = filter(children, path) else results = filter([element], path) end return results end