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

Changeset 832

Show
Ignore:
Timestamp:
08/03/03 19:11:47 (5 years ago)
Author:
nahi
Message:

* *.rb: change coding convention.

  • camelCase -> non_camel_case
  • foo( bar ) -> foo(bar)
  • foo[ bar ] -> foo[bar]
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ToDo

    r764 r832  
    11= ToDo 
    22 
     3wsdl4r generates old stub 
     4 
     5add new webrickServer with soaplet. 
    36 
    47mappingRegistryCreator: do not dump a type which is in default mappingRegistry. 
     
    1619�q���v�f��肷�����́A�V���ɐ錾�������ƁA���v�f��Ƃ��������������B���v�f���Ƃ����́Aref������p���܂� 
    1720 
    18 simplify original driver 
    1921 
    20 * encoding/decoding based on type information in WSDL. 
    21   * Support untyped response. 
     22* Follow SOAP/1.2. 
    2223* Support SwA. 
    2324* Parse XML Namespace with xmlscan, not by itself. 
    2425* RAA exception 
    25 * RAA uri-fy 
    2626* Support all derived built-in types in XML Schema Part2 Sec. 3.2. 
    2727* Design and implement SOAPHeader handler API. 
     
    3030    * Messaging sample. 
    3131* Rewrite the interop test client with runit? 
    32 * Follow SOAP/1.2. 
    3332 
    3433 
     
    4342* Add XSD tests to the interop test client. 
    4443* WSDL4R. 
     44* encoding based on type information in WSDL. 
     45* Support untyped response using WSDL. 
     46* RAA uri-fy 
     47* decoding based on type information in WSDL. 
  • trunk/bin/wsdl2ruby.rb

    r761 r832  
    1010require 'wsdl/soap/standaloneServerStubCreator' 
    1111require 'wsdl/soap/cgiStubCreator' 
    12 require 'wsdl/soap/webrickStubCreator' 
    1312 
    1413require 'devel/logger' 
     
    2019    ['--wsdl','-w', GetoptLong::REQUIRED_ARGUMENT], 
    2120    ['--type','-t', GetoptLong::REQUIRED_ARGUMENT], 
    22     ['--classDef','-e', GetoptLong::NO_ARGUMENT], 
    23     ['--clientSkelton','-c', GetoptLong::OPTIONAL_ARGUMENT], 
    24     ['--servantSkelton','-s', GetoptLong::OPTIONAL_ARGUMENT], 
    25     ['--cgiStub','-g', GetoptLong::OPTIONAL_ARGUMENT], 
    26     ['--webrickStub','-b', GetoptLong::OPTIONAL_ARGUMENT], 
    27     ['--standaloneServerStub','-a', GetoptLong::OPTIONAL_ARGUMENT], 
     21    ['--classdef','-e', GetoptLong::NO_ARGUMENT], 
     22    ['--client_skelton','-c', GetoptLong::OPTIONAL_ARGUMENT], 
     23    ['--servant_skelton','-s', GetoptLong::OPTIONAL_ARGUMENT], 
     24    ['--cgi_stub','-g', GetoptLong::OPTIONAL_ARGUMENT], 
     25    ['--standalone_server_stub','-a', GetoptLong::OPTIONAL_ARGUMENT], 
    2826    ['--driver','-d', GetoptLong::OPTIONAL_ARGUMENT], 
    2927    ['--force','-f', GetoptLong::NO_ARGUMENT], 
    30  
     28 
    3129 
    3230  def initialize 
    33     super( 'app'
     31    super('app'
    3432    STDERR.sync = true 
    35     @wsdlLocation = nil 
     33    @wsdl_location = nil 
    3634    @opt = {} 
    3735    @wsdl = nil 
     
    4038 
    4139  def run 
    42     @wsdlLocation, @opt = parseOpt( GetoptLong.new( *OptSet )) 
    43     usageExit unless @wsdlLocation 
    44     @wsdl = import(@wsdlLocation) 
     40    @wsdl_location, @opt = parse_opt(GetoptLong.new(*OptSet)) 
     41    usage_exit unless @wsdl_location 
     42    @wsdl = import(@wsdl_location) 
    4543    @name = @wsdl.name.name || 'default' 
    46     createFile 
     44    create_file 
    4745    0 
    4846  end 
    4947 
    50   def createFile 
    51     createClassDef if @opt.has_key?( 'classDef' ) 
    52     createServantSkelton( @opt[ 'servantSkelton' ] ) if @opt.has_key?( 'servantSkelton' ) 
    53     createCgiStub( @opt[ 'cgiStub' ] ) if @opt.has_key?( 'cgiStub' ) 
    54     createWebrickStub( @opt[ 'webrickStub' ] ) if @opt.has_key?( 'webrickStub' ) 
    55     createStandaloneServerStub( @opt[ 'standaloneServerStub' ] ) if @opt.has_key?( 'standaloneServerStub' ) 
    56     createDriver( @opt[ 'driver' ] ) if @opt.has_key?( 'driver' ) 
    57     createClientSkelton( @opt[ 'clientSkelton' ] ) if @opt.has_key?( 'clientSkelton' ) 
    58   end 
    59  
    60   def usageExit 
     48  def create_file 
     49    create_classdef if @opt.key?('classdef') 
     50    create_servant_skelton(@opt['servant_skelton']) if @opt.key?('servant_skelton') 
     51    create_cgi_stub(@opt['cgi_stub']) if @opt.key?('cgi_stub') 
     52    create_standalone_server_stub(@opt['standalone_server_stub']) if @opt.key?('standalone_server_stub') 
     53    create_driver(@opt['driver']) if @opt.key?('driver') 
     54    create_client_skelton(@opt['client_skelton']) if @opt.key?('client_skelton') 
     55  end 
     56 
     57  def usage_exit 
    6158    puts <<__EOU__ 
    62 Usage: #{ $0 } --wsdl wsdlLocation [options] 
    63   wsdlLocation: filename or URL 
     59Usage: #{ $0 } --wsdl wsdl_location [options] 
     60  wsdl_location: filename or URL 
    6461 
    6562Example: 
    6663  For server side: 
    67     #{ $0 } --wsdl myApp.wsdl --type server 
     64    #{ $0 } --wsdl myapp.wsdl --type server 
    6865  For client side: 
    69     #{ $0 } --wsdl myApp.wsdl --type client 
     66    #{ $0 } --wsdl myapp.wsdl --type client 
    7067 
    7168Options: 
    72   --wsdl wsdlLocation 
     69  --wsdl wsdl_location 
    7370  --type server|client 
    7471    --type server implies; 
    75         --classDef 
    76         --servantSkelton 
    77         --standaloneServerStub 
     72        --classdef 
     73        --servant_skelton 
     74        --standalone_server_stub 
    7875    --type client implies; 
    79         --classDef 
    80         --clientSkelton 
     76        --classdef 
     77        --client_skelton 
    8178        --driver 
    82   --classDef 
    83   --clientSkelton [serviceName] 
    84   --servantSkelton [portTypeName] 
    85   --cgiStub [serviceName] 
    86   --webrickStub [serviceName] 
    87   --standaloneServerStub [serviceName] 
    88   --driver [portTypeName] 
     79  --classdef 
     80  --client_skelton [servicename] 
     81  --servant_skelton [porttypename] 
     82  --cgi_stub [servicename] 
     83  --standalone_server_stub [servicename] 
     84  --driver [porttypename] 
    8985  --force 
    9086 
     
    9894  end 
    9995 
    100   def parseOpt( getOpt
     96  def parse_opt(getoptlong
    10197    opt = {} 
    10298    wsdl = nil 
    10399    begin 
    104       getOpt.each do | name, arg
     100      getoptlong.each do |name, arg
    105101        case name 
    106102        when "--wsdl" 
     
    109105          case arg 
    110106          when "server" 
    111             opt[ 'classDef' ] = nil 
    112             opt[ 'servantSkelton' ] = nil 
    113             opt[ 'standaloneServerStub' ] = nil 
     107            opt['classdef'] = nil 
     108            opt['servant_skelton'] = nil 
     109            opt['standalone_server_stub'] = nil 
    114110          when "client" 
    115             opt[ 'classDef' ] = nil 
    116             opt[ 'driver' ] = nil 
    117             opt[ 'clientSkelton' ] = nil 
     111            opt['classdef'] = nil 
     112            opt['driver'] = nil 
     113            opt['client_skelton'] = nil 
    118114          else 
    119             raise ArgumentError.new( "Unknown type #{ arg }"
     115            raise ArgumentError.new("Unknown type #{ arg }"
    120116          end 
    121         when "--classDef", "--clientSkelton", "--servantSkelton", "--cgiStub", 
    122            "--webrickStub", "--standaloneServerStub", "--driver" 
    123           opt[ name.sub( /^--/, '' ) ] = arg.empty? ? nil : arg 
     117        when "--classdef", "--client_skelton", "--servant_skelton", 
     118           "--cgi_stub", "--standalone_server_stub", "--driver" 
     119          opt[name.sub(/^--/, '')] = arg.empty? ? nil : arg 
    124120        when "--force" 
    125           opt[ 'force' ] = true 
     121          opt['force'] = true 
    126122        else 
    127           raise ArgumentError.new( "Unknown type #{ arg }"
     123          raise ArgumentError.new("Unknown type #{ arg }"
    128124        end 
    129125      end 
    130126    rescue 
    131       usageExit 
     127      usage_exit 
    132128    end 
    133129    return wsdl, opt 
    134130  end 
    135131 
    136   def createClassDef 
    137     log( SEV_INFO ) { "Creating class definition." } 
    138     @classDefFilename = @name + '.rb' 
    139     checkFile( @classDefFilename ) or return 
    140     File.open( @classDefFilename, "w" ) do | f
    141       f << WSDL::SOAP::ClassDefCreator.new( @wsdl ).dump 
    142     end 
    143   end 
    144  
    145   def createClientSkelton( serviceName
    146     log( SEV_INFO ) { "Creating client skelton." } 
    147     serviceName ||= @wsdl.services[ 0 ].name.name 
    148     @clientSkeltonFilename = serviceName + 'Client.rb' 
    149     checkFile( @clientSkeltonFilename ) or return 
    150     File.open( @clientSkeltonFilename, "w" ) do | f
     132  def create_classdef 
     133    log(SEV_INFO) { "Creating class definition." } 
     134    @classdef_filename = @name + '.rb' 
     135    check_file(@classdef_filename) or return 
     136    File.open(@classdef_filename, "w") do |f
     137      f << WSDL::SOAP::ClassDefCreator.new(@wsdl).dump 
     138    end 
     139  end 
     140 
     141  def create_client_skelton(servicename
     142    log(SEV_INFO) { "Creating client skelton." } 
     143    servicename ||= @wsdl.services[0].name.name 
     144    @client_skelton_filename = servicename + 'Client.rb' 
     145    check_file(@client_skelton_filename) or return 
     146    File.open(@client_skelton_filename, "w") do |f
    151147      f << shbang << "\n" 
    152       f << "require '#{ @driverFilename }'\n\n" if @driverFilename 
    153       f << WSDL::SOAP::ClientSkeltonCreator.new( @wsdl ).dump( 
    154         createName( serviceName )) 
    155     end 
    156   end 
    157  
    158   def createServantSkelton( portTypeName
    159     log( SEV_INFO ) { "Creating servant skelton." } 
    160     @servantSkeltonFilename = ( portTypeName || @name + 'Servant' ) + '.rb' 
    161     checkFile( @servantSkeltonFilename ) or return 
    162     File.open( @servantSkeltonFilename, "w" ) do | f
    163       f << "require '#{ @classDefFilename }'\n\n" if @classDefFilename 
    164       f << WSDL::SOAP::ServantSkeltonCreator.new( @wsdl ).dump( 
    165         createName( portTypeName )) 
    166     end 
    167   end 
    168  
    169   def createCgiStub( serviceName
    170     log( SEV_INFO ) { "Creating CGI stub." } 
    171     serviceName ||= @wsdl.services[ 0 ].name.name 
    172     @cgiStubFilename = serviceName + '.cgi' 
    173     checkFile( @cgiStubFilename ) or return 
    174     File.open( @cgiStubFilename, "w" ) do | f
     148      f << "require '#{ @driver_filename }'\n\n" if @driver_filename 
     149      f << WSDL::SOAP::ClientSkeltonCreator.new(@wsdl).dump( 
     150        create_name(servicename)) 
     151    end 
     152  end 
     153 
     154  def create_servant_skelton(porttypename
     155    log(SEV_INFO) { "Creating servant skelton." } 
     156    @servant_skelton_filename = (porttypename || @name + 'Servant') + '.rb' 
     157    check_file(@servant_skelton_filename) or return 
     158    File.open(@servant_skelton_filename, "w") do |f
     159      f << "require '#{ @classdef_filename }'\n\n" if @classdef_filename 
     160      f << WSDL::SOAP::ServantSkeltonCreator.new(@wsdl).dump( 
     161        create_name(porttypename)) 
     162    end 
     163  end 
     164 
     165  def create_cgi_stub(servicename
     166    log(SEV_INFO) { "Creating CGI stub." } 
     167    servicename ||= @wsdl.services[0].name.name 
     168    @cgi_stubFilename = servicename + '.cgi' 
     169    check_file(@cgi_stubFilename) or return 
     170    File.open(@cgi_stubFilename, "w") do |f
    175171      f << shbang << "\n" 
    176       f << "require '#{ @servantSkeltonFilename }'\n\n" if @servantSkeltonFilename 
    177       f << WSDL::SOAP::CGIStubCreator.new( @wsdl ).dump( 
    178         createName( serviceName )) 
    179     end 
    180   end 
    181  
    182   def createWebrickStub( serviceName ) 
    183     log( SEV_INFO ) { "Creating WEBrick SOAPlet stub." } 
    184     serviceName ||= @wsdl.services[ 0 ].name.name 
    185     @webrickStubFilename = 'httpd.rb' 
    186     checkFile( @webrickStubFilename ) or return 
    187     File.open( @webrickStubFilename, "w" ) do | f | 
     172      if @servant_skelton_filename 
     173        f << "require '#{ @servant_skelton_filename }'\n\n" 
     174      end 
     175      f << WSDL::SOAP::CGIStubCreator.new(@wsdl).dump(create_name(servicename)) 
     176    end 
     177  end 
     178 
     179  def create_standalone_server_stub(servicename) 
     180    log(SEV_INFO) { "Creating standalone stub." } 
     181    servicename ||= @wsdl.services[0].name.name 
     182    @standalone_server_stub_filename = servicename + '.rb' 
     183    check_file(@standalone_server_stub_filename) or return 
     184    File.open(@standalone_server_stub_filename, "w") do |f| 
    188185      f << shbang << "\n" 
    189       f << "require '#{ @servantSkeltonFilename }'\n\n" if @servantSkeltonFilename 
    190       f << WSDL::SOAP::WEBrickStubCreator.new( @wsdl ).dump( 
    191         createName( serviceName )) 
    192     end 
    193   end 
    194  
    195   def createStandaloneServerStub( serviceName ) 
    196     log( SEV_INFO ) { "Creating standalone stub." } 
    197     serviceName ||= @wsdl.services[ 0 ].name.name 
    198     @standaloneServerStubFilename = serviceName + '.rb' 
    199     checkFile( @standaloneServerStubFilename ) or return 
    200     File.open( @standaloneServerStubFilename, "w" ) do | f | 
    201       f << shbang << "\n" 
    202       f << "require '#{ @servantSkeltonFilename }'\n\n" if @servantSkeltonFilename 
    203       f << WSDL::SOAP::StandaloneServerStubCreator.new( @wsdl ).dump( 
    204         createName( serviceName )) 
    205     end 
    206   end 
    207  
    208   def createDriver( portTypeName ) 
    209     log( SEV_INFO ) { "Creating driver." } 
    210     @driverFilename = ( portTypeName || @name ) + 'Driver.rb' 
    211     checkFile( @driverFilename ) or return 
    212     File.open( @driverFilename, "w" ) do | f | 
    213       f << "require '#{ @classDefFilename }'\n\n" if @classDefFilename 
    214       f << WSDL::SOAP::DriverCreator.new( @wsdl ).dump( 
    215         createName( portTypeName )) 
    216     end 
    217   end 
    218  
    219   def checkFile( filename ) 
    220     if FileTest.exist?( filename ) 
    221       if @opt.has_key?( 'force' ) 
    222         log( SEV_WARN ) { 
     186      f << "require '#{ @servant_skelton_filename }'\n\n" if @servant_skelton_filename 
     187      f << WSDL::SOAP::StandaloneServerStubCreator.new(@wsdl).dump( 
     188        create_name(servicename)) 
     189    end 
     190  end 
     191 
     192  def create_driver(porttypename) 
     193    log(SEV_INFO) { "Creating driver." } 
     194    @driver_filename = (porttypename || @name) + 'Driver.rb' 
     195    check_file(@driver_filename) or return 
     196    File.open(@driver_filename, "w") do |f| 
     197      f << "require '#{ @classdef_filename }'\n\n" if @classdef_filename 
     198      f << WSDL::SOAP::DriverCreator.new(@wsdl).dump( 
     199        create_name(porttypename)) 
     200    end 
     201  end 
     202 
     203  def check_file(filename) 
     204    if FileTest.exist?(filename) 
     205      if @opt.key?('force') 
     206        log(SEV_WARN) { 
    223207          "File '#{ filename }' exists but overrides it." 
    224208        } 
    225209        true 
    226210      else 
    227         log( SEV_WARN ) { 
     211        log(SEV_WARN) { 
    228212          "File '#{ filename }' exists.  #{ $0 } did not override it." 
    229213        } 
     
    231215      end 
    232216    else 
    233       log( SEV_INFO ) { "Creates file '#{ filename }'." } 
     217      log(SEV_INFO) { "Creates file '#{ filename }'." } 
    234218      true 
    235219    end 
     
    240224  end 
    241225 
    242   def createName( name
    243     name ? XSD::QName.new( @wsdl.targetNamespace, name ) : nil 
     226  def create_name(name
     227    name ? XSD::QName.new(@wsdl.targetnamespace, name) : nil 
    244228  end 
    245229 
     
    250234    else 
    251235      require 'http-access2' 
    252       c = HTTPAccess2::Client.new(ENV[ 'http_proxy' ] || ENV[ 'HTTP_PROXY' ]) 
    253       content = c.getContent(location) 
    254     end 
    255     WSDL::WSDLParser.createParser.parse(content) 
     236      c = HTTPAccess2::Client.new(ENV['http_proxy'] || ENV['HTTP_PROXY']) 
     237      content = c.get_content(location) 
     238    end 
     239    WSDL::WSDLParser.create_parser.parse(content) 
    256240  end 
    257241end 
  • trunk/install.rb

    r819 r832  
    88RV = CONFIG["MAJOR"] + "." + CONFIG["MINOR"] 
    99DSTPATH = CONFIG["sitedir"] + "/" +  RV  
    10 SRCPATH = File.dirname( $0
     10SRCPATH = File.dirname($0
    1111 
    12 def join( *arg
    13   File.join( *arg
     12def join(*arg
     13  File.join(*arg
    1414end 
    1515 
    16 require join( SRCPATH, '_installedFiles' ) 
    17 $installed = InstalledFiles.new( SRCPATH ) 
    18  
    19 def install( from, to ) 
    20   toPath = File.catname( from, to ) 
    21   unless FileTest.exist?( toPath ) and File.compare( from, toPath ) 
    22     File.install( from, toPath, 0644, true ) 
    23     $installed << InstalledFile.new( toPath ) 
     16def install(from, to) 
     17  toPath = File.catname(from, to) 
     18  unless FileTest.exist?(toPath) and File.compare(from, toPath) 
     19    File.install(from, toPath, 0644, true) 
    2420  end 
    2521end 
    2622 
    27 def installDir( from, to
    28   unless FileTest.directory?( from
    29     raise RuntimeError.new( "'#{ from }' not found."
     23def installDir(from, to
     24  unless FileTest.directory?(from
     25    raise RuntimeError.new("'#{ from }' not found."
    3026  end 
    31   File.mkpath( to, true
    32   Dir[ join( from, '*.rb' ) ].each do | name
    33     install( name, to
     27  File.mkpath(to, true
     28  Dir[join(from, '*.rb')].each do |name
     29    install(name, to
    3430  end 
    3531end 
    3632 
    3733begin 
    38   installDir( join( SRCPATH, 'lib', 'soap' ), join( DSTPATH, 'soap' )) 
    39   installDir( join( SRCPATH, 'lib', 'soap', 'rpc' ), 
    40     join( DSTPATH, 'soap', 'rpc' )) 
    41   installDir( join( SRCPATH, 'lib', 'soap', 'mapping' ), 
    42     join( DSTPATH, 'soap', 'mapping' )) 
    43   installDir( join( SRCPATH, 'lib', 'wsdl' ), join( DSTPATH, 'wsdl' )) 
    44   installDir( join( SRCPATH, 'lib', 'wsdl', 'xmlSchema' ), 
    45     join( DSTPATH, 'wsdl', 'xmlSchema' )) 
    46   installDir( join( SRCPATH, 'lib', 'wsdl', 'soap' ), 
    47     join( DSTPATH, 'wsdl', 'soap' )) 
    48   installDir( join( SRCPATH, "redist" ), DSTPATH ) 
    49   installDir( join( SRCPATH, 'redist', 'soap' ), join( DSTPATH, 'soap' )) 
    50  
    51   $installed.dump( SRCPATH ) 
     34  installDir(join(SRCPATH, 'lib', 'soap'), 
     35    join(DSTPATH, 'soap')) 
     36  installDir(join(SRCPATH, 'lib', 'soap', 'rpc'), 
     37    join(DSTPATH, 'soap', 'rpc')) 
     38  installDir(join(SRCPATH, 'lib', 'soap', 'mapping'), 
     39    join(DSTPATH, 'soap', 'mapping')) 
     40  installDir(join(SRCPATH, 'lib', 'wsdl'), 
     41    join(DSTPATH, 'wsdl')) 
     42  installDir(join(SRCPATH, 'lib', 'wsdl', 'xmlSchema'), 
     43    join(DSTPATH, 'wsdl', 'xmlSchema')) 
     44  installDir(join(SRCPATH, 'lib', 'wsdl', 'soap'), 
     45    join(DSTPATH, 'wsdl', 'soap')) 
    5246 
    5347  puts "install succeed!" 
  • trunk/lib/soap/XMLSchemaDatatypes.rb

    r831 r832  
    6262ShortLiteral = 'short' 
    6363 
    64 AttrTypeName = QName.new( InstanceNamespace, AttrType
    65 AttrNilName = QName.new( InstanceNamespace, NilLiteral
    66  
    67 AnyTypeName = QName.new( Namespace, AnyTypeLiteral
    68 AnySimpleTypeName = QName.new( Namespace, AnySimpleTypeLiteral
     64AttrTypeName = QName.new(InstanceNamespace, AttrType
     65AttrNilName = QName.new(InstanceNamespace, NilLiteral
     66 
     67AnyTypeName = QName.new(Namespace, AnyTypeLiteral
     68AnySimpleTypeName = QName.new(Namespace, AnySimpleTypeLiteral
    6969 
    7070class Error < StandardError; end 
     
    7878  @@types = [] 
    7979 
    80 public 
    8180  attr_accessor :type 
    8281 
    83   def self.inherited( klass
     82  def self.inherited(klass
    8483    @@types << klass 
    8584  end 
     
    10099class XSDAnySimpleType < NSDBase 
    101100  include XSD 
    102   Type = QName.new( Namespace, AnySimpleTypeLiteral ) 
    103  
    104 public 
     101  Type = QName.new(Namespace, AnySimpleTypeLiteral) 
    105102 
    106103  # @data represents canonical space (ex. Integer: 123). 
    107104  attr_reader :data 
    108   # @isNil represents this data is nil or not. 
    109   attr_accessor :isNil 
    110  
    111   def initialize( initObj = nil
     105  # @is_nil represents this data is nil or not. 
     106  attr_accessor :is_nil 
     107 
     108  def initialize(value = nil
    112109    super() 
    113110    @type = Type 
    114111    @data = nil 
    115     @isNil = true 
    116     set( initObj ) if initObj 
     112    @is_nil = true 
     113    set(value) if value 
    117114  end 
    118115 
    119116  # set accepts a string which follows lexical space (ex. String: "+123"), or 
    120117  # an object which follows canonical space (ex. Integer: 123). 
    121   def set( newData
    122     if newData.nil? 
    123       @isNil = true 
     118  def set(value
     119    if value.nil? 
     120      @is_nil = true 
    124121      @data = nil 
    125122    else 
    126       @isNil = false 
    127       _set( newData
     123      @is_nil = false 
     124      _set(value
    128125    end 
    129126  end 
     
    131128  # to_s creates a string which follows lexical space (ex. String: "123"). 
    132129  def to_s() 
    133     if @isNil 
     130    if @is_nil 
    134131      "" 
    135132    else 
     
    138135  end 
    139136 
    140 protected 
    141   def trim( data
    142     data.sub( /\A\s*(\S*)\s*\z/, '\1' ) 
    143   end 
    144  
    145 private 
    146   def _set( newObj
    147     @data = newObj 
     137  def trim(data) 
     138    data.sub(/\A\s*(\S*)\s*\z/, '\1'
     139  end 
     140 
     141private 
     142 
     143  def _set(value
     144    @data = value 
    148145  end 
    149146 
     
    154151 
    155152class XSDNil < XSDAnySimpleType 
    156   Type = QName.new( Namespace, NilLiteral
     153  Type = QName.new(Namespace, NilLiteral
    157154  Value = 'true' 
    158155 
    159 public 
    160   def initialize( initNil = nil
    161     super() 
    162     @type = Type 
    163     set( initNil ) 
    164   end 
    165  
    166 private 
    167   def _set( newNil
    168     @data = newNil 
     156  def initialize(value = nil) 
     157    super(
     158    @type = Type 
     159    set(value) 
     160  end 
     161 
     162private 
     163 
     164  def _set(value
     165    @data = value 
    169166  end 
    170167end 
     
    175172# 
    176173class XSDString < XSDAnySimpleType 
    177   Type = QName.new( Namespace, StringLiteral ) 
    178  
    179 public 
    180   def initialize( initString = nil ) 
     174  Type = QName.new(Namespace, StringLiteral) 
     175 
     176  def initialize(value = nil) 
    181177    super() 
    182178    @type = Type 
    183179    @encoding = nil 
    184     set( initString ) if initString 
    185   end 
    186  
    187 private 
    188   def _set( newString ) 
    189     unless SOAP::Charset.isCES( newString, SOAP::Charset.getEncoding ) 
    190       raise ValueSpaceError.new( "#{ type }: cannot accept '#{ newString }'." ) 
    191     end 
    192     @data = newString 
     180    set(value) if value 
     181  end 
     182 
     183private 
     184 
     185  def _set(value) 
     186    unless SOAP::Charset.is_ces(value, SOAP::Charset.encoding) 
     187      raise ValueSpaceError.new("#{ type }: cannot accept '#{ value }'.") 
     188    end 
     189    @data = value 
    193190  end 
    194191end 
    195192 
    196193class XSDBoolean < XSDAnySimpleType 
    197   Type = QName.new( Namespace, BooleanLiteral
    198  
    199 public 
    200   def initialize( initBoolean = nil
    201     super() 
    202     @type = Type 
    203     set( initBoolean ) 
    204   end 
    205  
    206 private 
    207   def _set( newBoolean
    208     if newBoolean.is_a?( String
    209       str = trim( newBoolean
     194  Type = QName.new(Namespace, BooleanLiteral
     195 
     196  def initialize(value = nil) 
     197    super(
     198    @type = Type 
     199    set(value) 
     200  end 
     201 
     202private 
     203 
     204  def _set(value
     205    if value.is_a?(String
     206      str = trim(value
    210207      if str == 'true' || str == '1' 
    211208        @data = true 
     
    213210        @data = false 
    214211      else 
    215         raise ValueSpaceError.new( "#{ type }: cannot accept '#{ str }'."
     212        raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'."
    216213      end 
    217214    else 
    218       @data = newBoolean ? true : false 
     215      @data = value ? true : false 
    219216    end 
    220217  end 
     
    222219 
    223220class XSDDecimal < XSDAnySimpleType 
    224   Type = QName.new( Namespace, DecimalLiteral ) 
    225  
    226 public 
    227   def initialize( initDecimal = nil ) 
     221  Type = QName.new(Namespace, DecimalLiteral) 
     222 
     223  def initialize(value = nil) 
    228224    super() 
    229225    @type = Type 
     
    231227    @number = '' 
    232228    @point = 0 
    233     set( initDecimal ) if initDecimal 
     229    set(value) if value 
    234230  end 
    235231 
    236232  def nonzero? 
    237     ( @number != '0' ) 
    238   end 
    239  
    240 private 
    241   def _set( d ) 
    242     if d.is_a?( String ) 
    243       # Integer( "00012" ) => 10 in Ruby. 
    244       d.sub!( /^([+\-]?)0*(?=\d)/, "\\1" ) 
    245     end 
    246     set_str( d ) 
    247   end 
    248  
    249   def set_str( str ) 
    250     /^([+\-]?)(\d*)(?:\.(\d*)?)?$/ =~ trim( str.to_s ) 
     233    (@number != '0') 
     234  end 
     235 
     236private 
     237 
     238  def _set(d) 
     239    if d.is_a?(String) 
     240      # Integer("00012") => 10 in Ruby. 
     241      d.sub!(/^([+\-]?)0*(?=\d)/, "\\1") 
     242    end 
     243    set_str(d) 
     244  end 
     245 
     246  def set_str(str) 
     247    /^([+\-]?)(\d*)(?:\.(\d*)?)?$/ =~ trim(str.to_s) 
    251248    unless Regexp.last_match 
    252       raise ValueSpaceError.new( "#{ type }: cannot accept '#{ str }'."
     249      raise ValueSpaceError.new("#{ type }: cannot accept '#{ str }'."
    253250    end 
    254251 
    255252    @sign = $1 || '+' 
    256     integerPart = $2 
    257     fractionPart = $3 
    258  
    259     integerPart = '0' if integerPart.empty? 
    260     fractionPart = fractionPart ? fractionPart.sub( /0+$/, '' ) : '' 
    261     @point = - fractionPart.size 
    262     @number = integerPart + fractionPart 
     253    int_part = $2 
     254    frac_part = $3 
     255 
     256