diff --git a/lib/rexml/xpath_parser.rb b/lib/rexml/xpath_parser.rb
index 821cca95..279ba05a 100644
--- a/lib/rexml/xpath_parser.rb
+++ b/lib/rexml/xpath_parser.rb
@@ -199,7 +199,7 @@ def expr( path_stack, nodeset, context=nil )
nodeset = [nodeset.first.root_node]
when :self
nodeset = step(path_stack) do
- [:iterate_nodesets, [nodeset]]
+ [:iterate_nodesets, nodeset.map {|node| [node] }]
end
when :child
nodeset = step(path_stack) do
diff --git a/test/xpath/test_base.rb b/test/xpath/test_base.rb
index 43fe3e99..4d464869 100644
--- a/test/xpath/test_base.rb
+++ b/test/xpath/test_base.rb
@@ -276,6 +276,12 @@ def test_axe_self
assert_equal "c", XPath::first( c, "self::node()" ).name
end
+ def test_axe_self_order
+ doc = REXML::Document.new ""
+ assert_equal(["b", "c", "d"], XPath.match(doc, "a/*/self::*[1]").map(&:name))
+ assert_equal([], XPath.match(doc, "a/*/self::*[2]").map(&:name))
+ end
+
def test_axe_ancestor
doc = REXML::Document.new "