[前][次][番号順一覧][スレッド一覧]

ruby-changes:14142

From: tenderlove <ko1@a...>
Date: Sun, 29 Nov 2009 06:41:16 +0900 (JST)
Subject: [ruby-changes:14142] Ruby:r25956 (trunk): * lib/rexml/formatters/default.rb (write_attribute): fix an

tenderlove	2009-11-29 06:40:59 +0900 (Sun, 29 Nov 2009)

  New Revision: 25956

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=25956

  Log:
    * 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]

  Modified files:
    trunk/ChangeLog
    trunk/lib/rexml/formatters/default.rb
    trunk/test/rexml/test_document.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 25955)
+++ ChangeLog	(revision 25956)
@@ -1,3 +1,9 @@
+Sun Nov 29 06:37:53 2009  Aaron Patterson <tenderlove@r...>
+
+	* 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@r...>
 
 	* vm_eval.c (check_funcall_failed): should rescue user raised
Index: lib/rexml/formatters/default.rb
===================================================================
--- lib/rexml/formatters/default.rb	(revision 25955)
+++ lib/rexml/formatters/default.rb	(revision 25956)
@@ -63,7 +63,9 @@
       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?
Index: test/rexml/test_document.rb
===================================================================
--- test/rexml/test_document.rb	(revision 25955)
+++ test/rexml/test_document.rb	(revision 25956)
@@ -2,6 +2,25 @@
 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"?>

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]