diff options
author | nahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-09-02 03:11:02 +0000 |
---|---|---|
committer | nahi <nahi@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2006-09-02 03:11:02 +0000 |
commit | 40cefc9844100474eba84d33ab77362d69321db9 (patch) | |
tree | 22af88ff37e529f750d8b5e0225acd1a0d91a497 | |
parent | 97c6bc5ffd1deb626795057f01efda9ebdd9296f (diff) | |
download | ruby-40cefc9844100474eba84d33ab77362d69321db9.tar.gz |
* lib/soap/generator.rb (SOAP::SOAPGenerator#encode_tag): do not dump
XML attribute which value is nil. value "" and nil both were dumped
as 'attr="value"'. [ruby-dev:29395]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10830 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 6 | ||||
-rw-r--r-- | lib/soap/generator.rb | 20 |
2 files changed, 19 insertions, 7 deletions
@@ -1,3 +1,9 @@ +Sat Sep 2 12:06:35 2006 NAKAMURA, Hiroshi <nahi@ruby-lang.org> + + * lib/soap/generator.rb (SOAP::SOAPGenerator#encode_tag): do not dump + XML attribute which value is nil. value "" and nil both were dumped + as 'attr="value"'. [ruby-dev:29395] + Sat Sep 2 12:00:32 2006 NAKAMURA, Hiroshi <nahi@ruby-lang.org> * lib/csv.rb (CSV::IOReader#initialize): use String#[](pos, len) diff --git a/lib/soap/generator.rb b/lib/soap/generator.rb index f179555e1d..d0c07b058a 100644 --- a/lib/soap/generator.rb +++ b/lib/soap/generator.rb @@ -156,16 +156,22 @@ public end def encode_tag(elename, attrs = nil) - if !attrs or attrs.empty? + if attrs.nil? or attrs.empty? @buf << "\n#{ @indent }<#{ elename }>" - elsif attrs.size == 1 - key, value = attrs.shift - @buf << %Q[\n#{ @indent }<#{ elename } #{ key }="#{ value }">] + return + end + ary = [] + attrs.each do |key, value| + ary << %Q[#{ key }="#{ value }"] unless value.nil? + end + case ary.size + when 0 + @buf << "\n#{ @indent }<#{ elename }>" + when 1 + @buf << %Q[\n#{ @indent }<#{ elename } #{ ary[0] }>] else @buf << "\n#{ @indent }<#{ elename } " << - attrs.collect { |key, value| - %Q[#{ key }="#{ value }"] - }.join("\n#{ @indent }#{ @indentstr * 2 }") << + ary.join("\n#{ @indent }#{ @indentstr * 2 }") << '>' end end |