Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

Changeset 1707

Show
Ignore:
Timestamp:
09/02/06 00:20:10 (2 years ago)
Author:
nahi
Message:

do not dump XML attribute which value is nil. closes #241.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/soap/generator.rb

    r1622 r1707  
    157157 
    158158  def encode_tag(elename, attrs = nil) 
    159     if !attrs or attrs.empty? 
     159    if attrs.nil? or attrs.empty? 
    160160      @buf << "\n#{ @indent }<#{ elename }>" 
    161     elsif attrs.size == 1 
    162       key, value = attrs.shift 
    163       @buf << %Q[\n#{ @indent }<#{ elename } #{ key }="#{ value }">] 
     161      return  
     162    end 
     163    ary = [] 
     164    attrs.each do |key, value| 
     165      ary << %Q[#{ key }="#{ value }"] unless value.nil? 
     166    end 
     167    case ary.size 
     168    when 0 
     169      @buf << "\n#{ @indent }<#{ elename }>" 
     170    when 1 
     171      @buf << %Q[\n#{ @indent }<#{ elename } #{ ary[0] }>] 
    164172    else 
    165173      @buf << "\n#{ @indent }<#{ elename } " << 
    166         attrs.collect { |key, value| 
    167           %Q[#{ key }="#{ value }"] 
    168         }.join("\n#{ @indent }#{ @indentstr * 2 }") << 
     174        ary.join("\n#{ @indent }#{ @indentstr * 2 }") << 
    169175        '>' 
    170176    end