Changeset 1643
- Timestamp:
- 10/16/05 21:31:00 (3 years ago)
- Files:
-
- trunk/lib/wsdl/parser.rb (modified) (2 diffs)
- trunk/lib/wsdl/soap/complexType.rb (modified) (6 diffs)
- trunk/lib/wsdl/soap/definitions.rb (modified) (2 diffs)
- trunk/lib/wsdl/xmlSchema/all.rb (modified) (2 diffs)
- trunk/lib/wsdl/xmlSchema/choice.rb (modified) (2 diffs)
- trunk/lib/wsdl/xmlSchema/complexContent.rb (modified) (2 diffs)
- trunk/lib/wsdl/xmlSchema/complexExtension.rb (added)
- trunk/lib/wsdl/xmlSchema/complexRestriction.rb (added)
- trunk/lib/wsdl/xmlSchema/complexType.rb (modified) (4 diffs)
- trunk/lib/wsdl/xmlSchema/data.rb (modified) (1 diff)
- trunk/lib/wsdl/xmlSchema/parser.rb (modified) (2 diffs)
- trunk/lib/wsdl/xmlSchema/sequence.rb (modified) (2 diffs)
- trunk/test/wsdl/complexcontent/test_echo.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/wsdl/parser.rb
r1552 r1643 126 126 o = parent.parse_element(elename) 127 127 end 128 unless o128 if o.nil? 129 129 unless @ignored.key?(elename) 130 130 warn("ignored element: #{elename}") … … 141 141 value_ele = ns.parse(value, true) 142 142 value_ele.source = value # for recovery; value may not be a QName 143 unless o.parse_attr(attr_ele, value_ele)143 if o.parse_attr(attr_ele, value_ele).nil? 144 144 unless @ignored.key?(attr_ele) 145 145 warn("ignored attr: #{attr_ele}") trunk/lib/wsdl/soap/complexType.rb
r1582 r1643 22 22 def check_type 23 23 if content 24 if attributes.empty? and25 content.elements.size == 1 and content.elements[0].maxoccurs != '1'24 e = elements 25 if attributes.empty? and e.size == 1 and e[0].maxoccurs != '1' 26 26 if name == ::SOAP::Mapping::MapQName 27 27 :TYPE_MAP … … 33 33 end 34 34 elsif complexcontent 35 if complexcontent.base == ::SOAP::ValueArrayName 36 :TYPE_ARRAY 37 else 38 complexcontent.basetype.check_type 39 end 35 complexcontent.check_type 40 36 elsif simplecontent 41 37 :TYPE_SIMPLE … … 82 78 end 83 79 when :TYPE_ARRAY 84 if content.elements.size == 1 85 ele = content.elements[0] 80 e = elements 81 if e.size == 1 82 ele = e[0] 86 83 else 87 84 raise RuntimeError.new("Assert: must not reach.") … … 101 98 end 102 99 if complexcontent 103 complexcontent.attributes.each do |attribute| 104 if attribute.ref == ::SOAP::AttrArrayTypeName 105 return attribute.arytype 106 end 100 if complexcontent.restriction 101 complexcontent.restriction.attributes.each do |attribute| 102 if attribute.ref == ::SOAP::AttrArrayTypeName 103 return attribute.arytype 104 end 105 end 107 106 end 108 if check_array_content(complexcontent.content) 109 return element_simpletype(complexcontent.content.elements[0]) 110 end 111 elsif check_array_content(content) 112 return element_simpletype(content.elements[0]) 107 end 108 if check_array_content 109 return element_simpletype(elements[0]) 113 110 end 114 111 raise RuntimeError.new("Assert: Unknown array definition.") … … 119 116 raise RuntimeError.new("Assert: not for array") 120 117 end 121 if complexcontent 122 if check_array_content(complexcontent.content) 123 return complexcontent.content.elements[0] 124 end 125 elsif check_array_content(content) 126 return content.elements[0] 118 if check_array_content 119 return elements[0] 127 120 end 128 121 nil # use default item name … … 141 134 end 142 135 143 def check_array_content(content) 144 content and content.elements.size == 1 and 145 content.elements[0].maxoccurs != '1' 136 def check_array_content 137 e = elements 138 e.size == 1 and e[0].maxoccurs != '1' 139 # content and content.elements.size == 1 and 140 # content.elements[0].maxoccurs != '1' 146 141 end 147 142 trunk/lib/wsdl/soap/definitions.rb
r1520 r1643 27 27 type = XMLSchema::ComplexType.new(::SOAP::ValueArrayName) 28 28 type.complexcontent = XMLSchema::ComplexContent.new 29 type.complexcontent.base = ::SOAP::ValueArrayName 29 type.complexcontent.restriction = XMLSchema::ComplexRestriction.new 30 type.complexcontent.restriction.base = ::SOAP::ValueArrayName 30 31 attr = XMLSchema::Attribute.new 31 32 attr.ref = ::SOAP::AttrArrayTypeName … … 33 34 anytype.name += '[]' 34 35 attr.arytype = anytype 35 type.complexcontent. attributes << attr36 type.complexcontent.restriction.attributes << attr 36 37 type 37 38 end trunk/lib/wsdl/xmlSchema/all.rb
r1580 r1643 1 1 # WSDL4R - XMLSchema complexType definition for WSDL. 2 # Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.2 # Copyright (C) 2002, 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>. 3 3 4 4 # This program is copyrighted free software by NAKAMURA, Hiroshi. You can … … 23 23 @minoccurs = '1' 24 24 @maxoccurs = '1' 25 @elements = []25 @elements = XSD::NamedElements.new 26 26 end 27 27 trunk/lib/wsdl/xmlSchema/choice.rb
r1580 r1643 1 1 # WSDL4R - XMLSchema complexType definition for WSDL. 2 # Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.2 # Copyright (C) 2002, 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>. 3 3 4 4 # This program is copyrighted free software by NAKAMURA, Hiroshi. You can … … 23 23 @minoccurs = '1' 24 24 @maxoccurs = '1' 25 @elements = []25 @elements = XSD::NamedElements.new 26 26 end 27 27 trunk/lib/wsdl/xmlSchema/complexContent.rb
r1629 r1643 16 16 17 17 class ComplexContent < Info 18 attr_accessor :base 19 attr_reader :derivetype 20 attr_reader :content 21 attr_reader :attributes 18 attr_accessor :restriction 19 attr_accessor :extension 22 20 23 21 def initialize 24 22 super 25 @base = nil 26 @derivetype = nil 27 @content = nil 28 @attributes = XSD::NamedElements.new 29 @basetype = nil 23 @restriction = nil 24 @extension = nil 30 25 end 31 26 … … 38 33 end 39 34 40 def basetype 41 @basetype ||= root.collect_complextypes[@base] 35 def content 36 @extension || @restriction 37 end 38 39 def elements 40 content.elements 41 end 42 43 def attributes 44 content.attributes 45 end 46 47 def check_type 48 if content 49 content.check_type 50 else 51 raise ArgumentError.new("incomplete complexContent") 52 end 42 53 end 43 54 44 55 def parse_element(element) 45 56 case element 46 when RestrictionName, ExtensionName 47 @derivetype = element.name 48 self 49 when AllName 50 if @derivetype.nil? 51 raise Parser::ElementConstraintError.new("base attr not found.") 52 end 53 @content = All.new 54 @content 55 when SequenceName 56 if @derivetype.nil? 57 raise Parser::ElementConstraintError.new("base attr not found.") 58 end 59 @content = Sequence.new 60 @content 61 when ChoiceName 62 if @derivetype.nil? 63 raise Parser::ElementConstraintError.new("base attr not found.") 64 end 65 @content = Choice.new 66 @content 67 when AttributeName 68 if @derivetype.nil? 69 raise Parser::ElementConstraintError.new("base attr not found.") 70 end 71 o = Attribute.new 72 @attributes << o 73 o 57 when RestrictionName 58 raise ArgumentError.new("incomplete complexContent") if content 59 @restriction = ComplexRestriction.new 60 when ExtensionName 61 raise ArgumentError.new("incomplete complexContent") if content 62 @extension = ComplexExtension.new 74 63 end 75 64 end 76 65 77 66 def parse_attr(attr, value) 78 if @derivetype.nil? 79 return nil 80 end 81 case attr 82 when BaseAttrName 83 @base = value 84 else 85 nil 86 end 67 nil 87 68 end 88 69 end trunk/lib/wsdl/xmlSchema/complexType.rb
r1618 r1643 24 24 attr_accessor :final 25 25 attr_accessor :mixed 26 attr_reader :attributes27 26 28 27 def initialize(name = nil) … … 46 45 parent.elementformdefault 47 46 end 47 48 def elements 49 c = @complexcontent || @content 50 c ? c.elements : nil 51 end 52 53 def attributes 54 if @complexcontent 55 @complexcontent.attributes 56 else 57 @attributes 58 end 59 end 48 60 49 61 AnyAsElement = Element.new(XSD::QName.new(nil, 'any'), XSD::AnyTypeName) 50 62 def each_element 51 if content52 content.elements.each do |element|63 if e = elements 64 e.each do |element| 53 65 if element.is_a?(Any) 54 66 yield(AnyAsElement) … … 61 73 62 74 def find_element(name) 63 if content64 content.elements.each do |element|75 if e = elements 76 e.each do |element| 65 77 if element.is_a?(Any) 66 78 return AnyAsElement if name == AnyAsElement.name … … 74 86 75 87 def find_element_by_name(name) 76 if content77 content.elements.each do |element|88 if e = elements 89 e.each do |element| 78 90 if element.is_a?(Any) 79 91 return AnyAsElement if name == AnyAsElement.name.name trunk/lib/wsdl/xmlSchema/data.rb
r1520 r1643 17 17 require 'wsdl/xmlSchema/complexType' 18 18 require 'wsdl/xmlSchema/complexContent' 19 require 'wsdl/xmlSchema/complexRestriction' 20 require 'wsdl/xmlSchema/complexExtension' 19 21 require 'wsdl/xmlSchema/simpleContent' 20 22 require 'wsdl/xmlSchema/any' trunk/lib/wsdl/xmlSchema/parser.rb
r1552 r1643 124 124 o = parent.parse_element(elename) 125 125 end 126 unless o126 if o.nil? 127 127 unless @ignored.key?(elename) 128 128 warn("ignored element: #{elename} of #{parent.class}") … … 142 142 o.id = value_ele 143 143 else 144 unless o.parse_attr(attr_ele, value_ele)144 if o.parse_attr(attr_ele, value_ele).nil? 145 145 unless @ignored.key?(attr_ele) 146 146 warn("ignored attr: #{attr_ele}") trunk/lib/wsdl/xmlSchema/sequence.rb
r1580 r1643 1 1 # WSDL4R - XMLSchema complexType definition for WSDL. 2 # Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.2 # Copyright (C) 2002, 2003, 2005 NAKAMURA, Hiroshi <nahi@ruby-lang.org>. 3 3 4 4 # This program is copyrighted free software by NAKAMURA, Hiroshi. You can … … 23 23 @minoccurs = '1' 24 24 @maxoccurs = '1' 25 @elements = []25 @elements = XSD::NamedElements.new 26 26 end 27 27 trunk/test/wsdl/complexcontent/test_echo.rb
r1637 r1643 83 83 @client.endpoint_url = "http://localhost:#{Port}/" 84 84 @client.wiredump_dev = STDOUT if $DEBUG 85 assert_instance_of(Echo, @client.echo(Echo.new(Derived.new))) 85 d = Derived.new 86 d.Name = "NaHi" 87 assert_instance_of(Echo, @client.echo(Echo.new(d))) 86 88 end 87 89 end