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

Changeset 1956

Show
Ignore:
Timestamp:
09/12/07 19:02:32 (8 months ago)
Author:
nahi
Message:
  • soap4r's XML namespace handler did not handle xmlns="" correctly. it means 'no default namespace'. closes #421.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/xsd/ns.rb

    r1947 r1956  
    5858  def assign(ns, tag = nil) 
    5959    if tag == '' 
    60       @default_namespace = ns 
     60      if ns.empty? 
     61        @default_namespace = nil 
     62      else 
     63        @default_namespace = ns 
     64      end 
    6165      tag 
    6266    else 
  • trunk/lib/xsd/xmlparser.rb

    r1947 r1956  
    2929    newattrs = {} 
    3030    attrs.each do |key, value| 
    31       if (NSParseRegexp =~ key) 
     31      if NSParseRegexp =~ key 
    3232        unless ns_updated 
    3333          ns = ns.clone_ns 
    3434          ns_updated = true 
    3535        end 
    36         # '' means 'default namespace'. 
     36        # tag == '' means 'default namespace' 
     37        # value == '' means 'no default namespace' 
    3738        tag = $1 || '' 
    3839        ns.assign(value, tag) 
  • trunk/test/xsd/test_ns.rb

    r1704 r1956  
    1515    assert_equal("EN", lang) 
    1616  end 
     17 
     18  def test_no_default_namespace 
     19    env = SOAP::Processor.unmarshal(NO_DEFAULT_NAMESPACE) 
     20    array = env.body.root_node["array"] 
     21    item = array["item"] 
     22    assert_equal("urn:ns", array.elename.namespace) 
     23    assert_equal(nil, item.elename.namespace) 
     24  end 
     25 
     26NO_DEFAULT_NAMESPACE = <<__XML__ 
     27<?xml version="1.0" encoding="utf-8"?> 
     28<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> 
     29  <env:Body> 
     30    <response xmlns="urn:ns"> 
     31      <array> 
     32        <item attr="1" xmlns=""/> 
     33      </array> 
     34    </response> 
     35  </env:Body> 
     36</env:Envelope> 
     37__XML__ 
    1738end 
    1839