summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-28 21:40:59 +0000
committertenderlove <tenderlove@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-28 21:40:59 +0000
commitd4a2242ce61441d0901cb750d497be08ff5ef4f6 (patch)
tree259042e7c26d2f100881ec4db7eaf68e9909f91a
parentc37753e5a5d49d549255fb6cc60321a3788a4f2a (diff)
downloadruby-d4a2242ce61441d0901cb750d497be08ff5ef4f6.tar.gz
ruby-d4a2242ce61441d0901cb750d497be08ff5ef4f6.tar.xz
ruby-d4a2242ce61441d0901cb750d497be08ff5ef4f6.zip
* lib/rexml/formatters/default.rb (write_attribute): fix an
exception when printing a document when duplicate namespaced attributes exist. Thanks, Alexey Froloff [ruby-core:2389] git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@25956 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog6
-rw-r--r--lib/rexml/formatters/default.rb4
-rw-r--r--test/rexml/test_document.rb19
3 files changed, 28 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index c613855f9..0679e7fbe 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Sun Nov 29 06:37:53 2009 Aaron Patterson <tenderlove@ruby-lang.org>
+
+ * lib/rexml/formatters/default.rb (write_attribute): fix an
+ exception when printing a document when duplicate namespaced
+ attributes exist. Thanks, Alexey Froloff [ruby-core:2389]
+
Sat Nov 28 09:05:53 2009 Yukihiro Matsumoto <matz@ruby-lang.org>
* vm_eval.c (check_funcall_failed): should rescue user raised
diff --git a/lib/rexml/formatters/default.rb b/lib/rexml/formatters/default.rb
index 56a1d9378..db44453e1 100644
--- a/lib/rexml/formatters/default.rb
+++ b/lib/rexml/formatters/default.rb
@@ -63,7 +63,9 @@ module REXML
def write_element( node, output )
output << "<#{node.expanded_name}"
- node.attributes.to_a.sort_by {|attr| attr.name}.each do |attr|
+ node.attributes.to_a.map { |a|
+ Hash === a ? a.values : a
+ }.flatten.sort_by {|attr| attr.name}.each do |attr|
output << " "
attr.write( output )
end unless node.attributes.empty?
diff --git a/test/rexml/test_document.rb b/test/rexml/test_document.rb
index 0261e80b7..a35fce7dc 100644
--- a/test/rexml/test_document.rb
+++ b/test/rexml/test_document.rb
@@ -2,6 +2,25 @@ require "rexml/document"
require "test/unit"
class REXML::TestDocument < Test::Unit::TestCase
+ def test_version_attributes_to_s
+ doc = REXML::Document.new(<<-eoxml)
+ <?xml version="1.0" encoding="UTF-8" standalone="no"?>
+ <svg id="svg2"
+ xmlns:sodipodi="foo"
+ xmlns:inkscape="bar"
+ sodipodi:version="0.32"
+ inkscape:version="0.44.1"
+ >
+ </svg>
+ eoxml
+
+ string = doc.to_s
+ assert_match('xmlns:sodipodi', string)
+ assert_match('xmlns:inkscape', string)
+ assert_match('sodipodi:version', string)
+ assert_match('inkscape:version', string)
+ end
+
def test_new
doc = REXML::Document.new(<<EOF)
<?xml version="1.0" encoding="UTF-8"?>