* lib/rexml/element.rb (REXML::Attributes#to_a): Support
namespaced attributes. [ruby-dev:47277] [Bug #8301] Patch by Ippei Obayashi. Thanks!!! * test/rexml/test_attributes.rb (AttributesTester#test_to_a_with_namespaces): Add a test of the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40482 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
b486e50434
commit
562648e48c
@ -1,3 +1,12 @@
|
|||||||
|
Fri Apr 26 22:53:55 2013 Kouhei Sutou <kou@cozmixng.org>
|
||||||
|
|
||||||
|
* lib/rexml/element.rb (REXML::Attributes#to_a): Support
|
||||||
|
namespaced attributes. [ruby-dev:47277] [Bug #8301]
|
||||||
|
Patch by Ippei Obayashi. Thanks!!!
|
||||||
|
* test/rexml/test_attributes.rb
|
||||||
|
(AttributesTester#test_to_a_with_namespaces): Add a test of the
|
||||||
|
above change.
|
||||||
|
|
||||||
Fri Apr 26 21:48:29 2013 Kouhei Sutou <kou@cozmixng.org>
|
Fri Apr 26 21:48:29 2013 Kouhei Sutou <kou@cozmixng.org>
|
||||||
|
|
||||||
* lib/rss/atom.rb (RSS::Atom::Entry): Fix indent of document comment.
|
* lib/rss/atom.rb (RSS::Atom::Entry): Fix indent of document comment.
|
||||||
|
@ -987,7 +987,7 @@ module REXML
|
|||||||
end
|
end
|
||||||
|
|
||||||
def to_a
|
def to_a
|
||||||
values.flatten
|
enum_for(:each_attribute).to_a
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns the number of attributes the owning Element contains.
|
# Returns the number of attributes the owning Element contains.
|
||||||
|
@ -195,4 +195,26 @@ class AttributesTester < Test::Unit::TestCase
|
|||||||
doc.add_element 'a', { 'v' => 'x & y' }
|
doc.add_element 'a', { 'v' => 'x & y' }
|
||||||
assert doc.to_s.index(';')
|
assert doc.to_s.index(';')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_to_a_with_namespaces
|
||||||
|
document = Document.new(<<-XML)
|
||||||
|
<root
|
||||||
|
xmlns:ns1="http://example.org/ns1"
|
||||||
|
xmlns:ns2="http://example.org/ns2">
|
||||||
|
<child
|
||||||
|
ns1:attribute="ns1"
|
||||||
|
ns2:attribute="ns2"
|
||||||
|
attribute="no-ns"
|
||||||
|
other-attribute="other-value"/>
|
||||||
|
</root>
|
||||||
|
XML
|
||||||
|
child = document.root.elements["child"]
|
||||||
|
assert_equal([
|
||||||
|
"attribute='no-ns'",
|
||||||
|
"ns1:attribute='ns1'",
|
||||||
|
"ns2:attribute='ns2'",
|
||||||
|
"other-attribute='other-value'",
|
||||||
|
],
|
||||||
|
child.attributes.to_a.collect(&:to_string).sort)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user