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

Changeset 1664

Show
Ignore:
Timestamp:
11/07/05 22:14:12 (3 years ago)
Author:
nahi
Message:

classdef definition more pretty printing.
let simpleContent + attribute extension class be derived from String even if it is defined as a double. closes #178.

Files:

Legend:

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

    r1663 r1664  
    151151 
    152152  def dump_simpleclassdef(qname, type_or_element) 
    153     base = create_class_name(type_or_element.simplecontent.base) 
    154     c = ClassDef.new(create_class_name(qname), base) 
    155     c.comment = "#{qname}" 
     153    base = basetype_class(type_or_element.simplecontent.base) 
     154    c = ClassDef.new(create_class_name(qname), '::String') 
     155    c.comment = "#{qname}\n  contains #{base}" 
     156    init_lines = [] 
    156157    unless type_or_element.attributes.empty? 
    157158      define_attribute(c, type_or_element.attributes) 
    158       c.def_method('initialize', '*arg') do 
    159         "super\n" + "@__xmlattr = {}" 
    160       end 
     159      init_lines << "@__xmlattr = {}" 
     160    end 
     161    c.def_method('initialize', '*arg') do 
     162      "super\n" + init_lines.join("\n") 
    161163    end 
    162164    c.dump 
     
    213215      definition.shift 
    214216      "[ :choice,\n" + ' ' * indent + 
    215         dump_schema_element(definition, indent) + ']' 
     217        dump_schema_element(definition, indent) + "\n]" 
    216218    elsif definition[0].is_a?(::Array) 
    217219      "[\n" + ' ' * indent + 
    218         dump_schema_element(definition, indent) + ']' 
     220        dump_schema_element(definition, indent) + "\n]" 
    219221    else 
    220222      varname, name, type = definition 
     
    370372    end 
    371373    c.def_classvar('schema_attribute', 
    372       '{'
     374      "{\n  "
    373375        schema_attribute.collect { |name, type| 
    374376          dqname(name) + ' => ' + ndq(type) 
    375         }.join(', ') + 
    376       '}' 
     377        }.join(",\n  ") + 
     378      "\n}" 
    377379    ) 
    378380  end 
     
    419421    schema_element << [child_element_name.name, child_element_name, type] 
    420422    c.def_classvar('schema_element', 
    421       '[' + 
    422         schema_element.collect { |varname, name, type| 
    423           '[' + 
    424             ( 
    425               if name 
    426                 varname.dump + ', [' + ndq(type) + ', ' + dqname(name) + ']' 
    427               else 
    428                 varname.dump + ', ' + ndq(type) 
    429               end 
    430             ) + 
    431           ']' 
    432         }.join(', ') + 
    433       ']' 
     423      dump_schema_element_definition(schema_element, 2) 
    434424    ) 
    435425    c.dump 
  • trunk/test/wsdl/any/expectedEcho.rb

    r1655 r1664  
    88    ["before", ["SOAP::SOAPString", XSD::QName.new(nil, "before")]], 
    99    ["any", [nil, XSD::QName.new("http://www.w3.org/2001/XMLSchema", "anyType")]], 
    10     ["after", ["SOAP::SOAPString", XSD::QName.new(nil, "after")]]] 
     10    ["after", ["SOAP::SOAPString", XSD::QName.new(nil, "after")]] 
     11  ] 
    1112 
    1213  attr_accessor :before 
  • trunk/test/wsdl/marshal/person_org.rb

    r1655 r1664  
    1010    ["var1", ["SOAP::SOAPInt", XSD::QName.new(nil, "var1")]], 
    1111    ["var2", ["SOAP::SOAPDouble", XSD::QName.new(nil, "var2")]], 
    12     ["var3", ["SOAP::SOAPString", XSD::QName.new(nil, "var3")]]] 
     12    ["var3", ["SOAP::SOAPString", XSD::QName.new(nil, "var3")]] 
     13  ] 
    1314 
    1415  attr_accessor :familyname 
  • trunk/test/wsdl/ref/expectedProduct.rb

    r1663 r1664  
    1212  @@schema_type = "Product-Bag" 
    1313  @@schema_ns = "urn:ref" 
    14   @@schema_attribute = {XSD::QName.new("urn:ref", "version") => "SOAP::SOAPString", XSD::QName.new("urn:ref", "yesno") => "SOAP::SOAPString"} 
     14  @@schema_attribute = { 
     15    XSD::QName.new("urn:ref", "version") => "SOAP::SOAPString", 
     16    XSD::QName.new("urn:ref", "yesno") => "SOAP::SOAPString" 
     17  } 
    1518  @@schema_element = [ 
    1619    ["bag", ["Product[]", XSD::QName.new(nil, "bag")]], 
    1720    ["rating", ["SOAP::SOAPString[]", XSD::QName.new("urn:ref", "Rating")]], 
    1821    ["comment_1", ["[]", XSD::QName.new(nil, "comment_1")]], 
    19     ["comment_2", ["Comment[]", XSD::QName.new(nil, "comment-2")]]] 
     22    ["comment_2", ["Comment[]", XSD::QName.new(nil, "comment-2")]], 
     23    ["v___point", ["C__point", XSD::QName.new(nil, "__point")]] 
     24  ] 
    2025 
    2126  attr_accessor :bag 
     
    2328  attr_accessor :comment_1 
    2429  attr_accessor :comment_2 
     30 
     31  def m___point 
     32    @v___point 
     33  end 
     34 
     35  def m___point=(value) 
     36    @v___point = value 
     37  end 
    2538 
    2639  def xmlattr_version 
     
    4053  end 
    4154 
    42   def initialize(bag = [], rating = [], comment_1 = [], comment_2 = []
     55  def initialize(bag = [], rating = [], comment_1 = [], comment_2 = [], v___point = nil
    4356    @bag = bag 
    4457    @rating = rating 
    4558    @comment_1 = comment_1 
    4659    @comment_2 = comment_2 
     60    @v___point = v___point 
    4761    @__xmlattr = {} 
    4862  end 
     
    5064 
    5165# {urn:ref}Creator 
    52 class Creator < String 
    53   @@schema_attribute = {XSD::QName.new(nil, "Role") => nil} 
     66#   contains SOAP::SOAPString 
     67class Creator < ::String 
     68  @@schema_attribute = { 
     69    XSD::QName.new(nil, "Role") => nil 
     70  } 
    5471 
    5572  def xmlattr_Role 
     
    7996  @@schema_element = [ 
    8097    ["name", ["SOAP::SOAPString", XSD::QName.new(nil, "name")]], 
    81     ["rating", ["SOAP::SOAPString", XSD::QName.new("urn:ref", "Rating")]]] 
     98    ["rating", ["SOAP::SOAPString", XSD::QName.new("urn:ref", "Rating")]] 
     99  ] 
    82100 
    83101  attr_accessor :name 
     
    91109 
    92110# {urn:ref}Comment 
    93 class Comment < String 
    94   @@schema_attribute = {XSD::QName.new(nil, "msgid") => "SOAP::SOAPString"} 
     111#   contains SOAP::SOAPString 
     112class Comment < ::String 
     113  @@schema_attribute = { 
     114    XSD::QName.new(nil, "msgid") => "SOAP::SOAPString" 
     115  } 
    95116 
    96117  def xmlattr_msgid 
     
    107128  end 
    108129end 
     130 
     131# {urn:ref}_point 
     132#   contains SOAP::SOAPInteger 
     133class C__point < ::String 
     134  @@schema_attribute = { 
     135    XSD::QName.new(nil, "unit") => "SOAP::SOAPString" 
     136  } 
     137 
     138  def xmlattr_unit 
     139    (@__xmlattr ||= {})[XSD::QName.new(nil, "unit")] 
     140  end 
     141 
     142  def xmlattr_unit=(value) 
     143    (@__xmlattr ||= {})[XSD::QName.new(nil, "unit")] = value 
     144  end 
     145 
     146  def initialize(*arg) 
     147    super 
     148    @__xmlattr = {} 
     149  end 
     150end 
  • trunk/test/wsdl/ref/product.wsdl

    r1663 r1664  
    2626          <extension base="xsd:string"> 
    2727            <attribute name="msgid" type="xsd:string" use="required"/> 
     28          </extension> 
     29        </simpleContent> 
     30      </complexType> 
     31 
     32      <complexType name="_point"> 
     33        <simpleContent> 
     34          <extension base="xsd:integer"> 
     35            <attribute name="unit" type="xsd:string" use="required"/> 
    2836          </extension> 
    2937        </simpleContent> 
     
    6674            </element> 
    6775            <element name="comment-2" type="tns:Comment" minOccurs="0" maxOccurs="unbounded"/> 
     76            <element name="__point" type="tns:_point" minOccurs="0" maxOccurs="1"/> 
    6877          </sequence> 
    6978          <attribute ref="tns:version"/> 
  • trunk/test/wsdl/ref/test_ref.rb

    r1663 r1664  
    3131        arg.bag[1].name, 
    3232        arg.bag[1].rating, 
     33        arg.xmlattr_version, 
     34        arg.xmlattr_yesno, 
    3335        arg.rating[0], 
    3436        arg.rating[1], 
     
    151153      p2.add(e("name", "bar")) 
    152154      p2.add(e(q(Namespace, "Rating"), "+1")) 
     155    version = "version" 
     156    yesno = "N" 
    153157    r1 = e(q(Namespace, "Rating"), "0") 
    154158    r2 = e(q(Namespace, "Rating"), "+1") 
     
    172176      bag.add(c21) 
    173177      bag.add(c22) 
    174     bag.extraattr["version"] = "version" 
    175     bag.extraattr["yesno"] = "Y" 
     178    bag.extraattr[q(Namespace, "version")] = version 
     179    bag.extraattr[q(Namespace, "yesno")] = yesno 
    176180    ret = @client.echo(bag) 
    177181    assert_equal( 
     
    179183        p1["name"].text, p1["Rating"].text, 
    180184        p2["name"].text, p2["Rating"].text, 
     185        version, yesno, 
    181186        r1.text, r2.text, r3.text, 
    182187        c11.text, c11.extraattr["msgid"], 
     
    197202    p1 = Product.new("foo", Rating::C_0) 
    198203    p2 = Product.new("bar", Rating::C_1) 
     204    version = "version" 
     205    yesno = Yesno::Y 
    199206    r1 = Rating::C_0 
    200207    r2 = Rating::C_1 
     
    209216    c22.xmlattr_msgid = "msgid22" 
    210217    bag = ProductBag.new([p1, p2], [r1, r2, r3], [c11, c12], [c21, c22]) 
    211     bag.xmlattr_version = "version" 
    212     bag.xmlattr_yesno = Yesno::Y 
     218    bag.xmlattr_version = version 
     219    bag.xmlattr_yesno = yesno 
    213220    ret = @client.echo(bag) 
    214221    assert_equal( 
     
    216223        p1.name, p1.rating, 
    217224        p2.name, p2.rating, 
     225        version, yesno, 
    218226        r1, r2, r3, 
    219227        c11.text, c11.extraattr["msgid"], 
     
    232240    p1 = Product.new("foo", Rating::C_0) 
    233241    p2 = Product.new("bar", Rating::C_1) 
     242    version = "version" 
     243    yesno = Yesno::Y 
    234244    r1 = Rating::C_0 
    235245    r2 = Rating::C_1 
     
    243253    c22 = Comment.new("comment22") 
    244254    c22.xmlattr_msgid = "msgid22" 
    245     bag = ProductBag.new([p1, p2], [r1, r2, r3], [c11, c12], [c21, c22]) 
    246     bag.xmlattr_version = "version" 
    247     bag.xmlattr_yesno = Yesno::Y 
     255    pts = C__point.new("123") 
     256    bag = ProductBag.new([p1, p2], [r1, r2, r3], [c11, c12], [c21, c22], pts) 
     257    bag.xmlattr_version = version 
     258    bag.xmlattr_yesno = yesno 
    248259    ret = @client.echo(bag) 
    249260    assert_equal( 
     
    251262        p1.name, p1.rating, 
    252263        p2.name, p2.rating, 
     264        version, yesno, 
    253265        r1, r2, r3, 
    254266        c11.text, c11.extraattr["msgid"], 
  • trunk/test/wsdl/simpletype/rpc/expectedEchoVersion.rb

    r1655 r1664  
    77  @@schema_element = [ 
    88    ["version", ["SOAP::SOAPString", XSD::QName.new(nil, "version")]], 
    9     ["msg", ["SOAP::SOAPString", XSD::QName.new(nil, "msg")]]] 
     9    ["msg", ["SOAP::SOAPString", XSD::QName.new(nil, "msg")]] 
     10  ] 
    1011 
    1112  attr_accessor :version 
  • trunk/test/wsdl/soap/wsdl2ruby/expectedClassdef.rb

    r1655 r1664  
    77  @@schema_element = [ 
    88    ["version", ["SOAP::SOAPString", XSD::QName.new(nil, "version")]], 
    9     ["msg", ["SOAP::SOAPString", XSD::QName.new(nil, "msg")]]] 
     9    ["msg", ["SOAP::SOAPString", XSD::QName.new(nil, "msg")]] 
     10  ] 
    1011 
    1112  attr_accessor :version 
  • trunk/test/wsdl/soap/wsdl2ruby/section/expectedClassdef.rb

    r1655 r1664  
    66  @@schema_ns = "urn:mysample" 
    77  @@schema_element = [ 
    8     ["something", ["SOAP::SOAPString", XSD::QName.new(nil, "something")]]] 
     8    ["something", ["SOAP::SOAPString", XSD::QName.new(nil, "something")]] 
     9  ] 
    910 
    1011  attr_accessor :something 
     
    2425    ["description", ["SOAP::SOAPString", XSD::QName.new(nil, "description")]], 
    2526    ["index", ["SOAP::SOAPInt", XSD::QName.new(nil, "index")]], 
    26     ["firstQuestion", ["Question", XSD::QName.new(nil, "firstQuestion")]]] 
     27    ["firstQuestion", ["Question", XSD::QName.new(nil, "firstQuestion")]] 
     28  ] 
    2729 
    2830  attr_accessor :sectionID 
     
    4547  @@schema_type = "section" 
    4648  @@schema_ns = "urn:mysample" 
    47   @@schema_element = [["item", ["Section", XSD::QName.new(nil, "item")]]] 
     49  @@schema_element = [ 
     50    ["item", ["Section", XSD::QName.new(nil, "item")]] 
     51  ] 
    4852end