# File lib/wsdl/xmlSchema/complexType.rb, line 27 27: def initialize(name = nil) 28: super() 29: @name = name 30: @complexcontent = nil 31: @simplecontent = nil 32: @content = nil 33: @final = nil 34: @mixed = false 35: @abstract = false 36: @attributes = XSD::NamedElements.new 37: end
# File lib/wsdl/xmlSchema/complexType.rb, line 137 137: def all_elements=(elements) 138: @content = All.new 139: elements.each do |element| 140: @content << element 141: end 142: end
# File lib/wsdl/xmlSchema/complexType.rb, line 79 79: def attributes 80: attrs = nil 81: if @complexcontent 82: attrs = @complexcontent.attributes + @attributes 83: elsif @simplecontent 84: attrs = @simplecontent.attributes + @attributes 85: else 86: attrs = @attributes 87: end 88: found = XSD::NamedElements.new 89: attrs.each do |attr| 90: case attr 91: when Attribute 92: found << attr 93: when AttributeGroup 94: if attr.attributes 95: found.concat(attr.attributes) 96: end 97: when AnyAttribute 98: # ignored 99: else 100: warn("unknown attribute: #{attr}") 101: end 102: end 103: found 104: end
# File lib/wsdl/xmlSchema/complexType.rb, line 65 65: def base 66: if c = @complexcontent || @simplecontent 67: c.base 68: end 69: end
# File lib/wsdl/soap/complexType.rb, line 22 22: def check_type 23: if have_any? 24: :TYPE_STRUCT 25: elsif content 26: if attributes.empty? and map_as_array? 27: if name == ::SOAP::Mapping::MapQName 28: :TYPE_MAP 29: else 30: :TYPE_ARRAY 31: end 32: else 33: :TYPE_STRUCT 34: end 35: elsif complexcontent 36: complexcontent.check_type 37: elsif simplecontent 38: :TYPE_SIMPLE 39: elsif !attributes.empty? 40: :TYPE_STRUCT 41: else # empty complexType definition (seen in partner.wsdl of salesforce) 42: :TYPE_EMPTY 43: end 44: end
# File lib/wsdl/soap/complexType.rb, line 71 71: def child_defined_complextype(name) 72: ele = nil 73: case compoundtype 74: when :TYPE_STRUCT, :TYPE_MAP 75: unless ele = find_element(name) 76: if name.namespace.nil? 77: ele = find_element_by_name(name.name) 78: end 79: end 80: when :TYPE_ARRAY 81: e = elements 82: if e.size == 1 83: ele = e[0] 84: else 85: raise RuntimeError.new("Assert: must not reach.") 86: end 87: else 88: raise RuntimeError.new("Assert: Not implemented.") 89: end 90: unless ele 91: raise RuntimeError.new("Cannot find #{name} as a children of #{@name}.") 92: end 93: ele.local_complextype 94: end
# File lib/wsdl/soap/complexType.rb, line 46 46: def child_type(name = nil) 47: case compoundtype 48: when :TYPE_STRUCT 49: if ele = find_element(name) 50: ele.type 51: elsif ele = find_element_by_name(name.name) 52: ele.type 53: end 54: when :TYPE_ARRAY 55: @contenttype ||= content_arytype 56: when :TYPE_MAP 57: item_ele = find_element_by_name("item") or 58: raise RuntimeError.new("'item' element not found in Map definition.") 59: content = item_ele.local_complextype or 60: raise RuntimeError.new("No complexType definition for 'item'.") 61: if ele = content.find_element(name) 62: ele.type 63: elsif ele = content.find_element_by_name(name.name) 64: ele.type 65: end 66: else 67: raise NotImplementedError.new("Unknown kind of complexType.") 68: end 69: end
# File lib/wsdl/xmlSchema/complexType.rb, line 57 57: def choice? 58: if c = @complexcontent || @content 59: c.choice? 60: else 61: false 62: end 63: end
# File lib/wsdl/soap/complexType.rb, line 18 18: def compoundtype 19: @compoundtype ||= check_type 20: end
# File lib/wsdl/xmlSchema/complexType.rb, line 45 45: def elementformdefault 46: parent.elementformdefault 47: end
# File lib/wsdl/xmlSchema/complexType.rb, line 71 71: def elements 72: if c = @complexcontent || @content 73: c.elements 74: else 75: XSD::NamedElements::Empty 76: end 77: end
# File lib/wsdl/soap/complexType.rb, line 124 124: def find_aryelement 125: unless compoundtype == :TYPE_ARRAY 126: raise RuntimeError.new("Assert: not for array") 127: end 128: if map_as_array? 129: return nested_elements[0] 130: end 131: nil # use default item name 132: end
# File lib/wsdl/soap/complexType.rb, line 111 111: def find_arytype 112: unless compoundtype == :TYPE_ARRAY 113: raise RuntimeError.new("Assert: not for array") 114: end 115: if arytype = find_soapenc_arytype 116: return arytype 117: end 118: if map_as_array? 119: return element_simpletype(elements[0]) 120: end 121: raise RuntimeError.new("Assert: Unknown array definition.") 122: end
# File lib/wsdl/xmlSchema/complexType.rb, line 114 114: def find_element(name) 115: return nil if name.nil? 116: elements.each do |element| 117: return element if name == element.name 118: end 119: nil 120: end
# File lib/wsdl/xmlSchema/complexType.rb, line 122 122: def find_element_by_name(name) 123: return nil if name.nil? 124: elements.each do |element| 125: return element if name == element.name.name 126: end 127: nil 128: end
# File lib/wsdl/soap/complexType.rb, line 96 96: def find_soapenc_arytype 97: unless compoundtype == :TYPE_ARRAY 98: raise RuntimeError.new("Assert: not for array") 99: end 100: if complexcontent 101: if complexcontent.restriction 102: complexcontent.restriction.attributes.each do |attribute| 103: if attribute.ref == ::SOAP::AttrArrayTypeName 104: return attribute.arytype 105: end 106: end 107: end 108: end 109: end
# File lib/wsdl/xmlSchema/complexType.rb, line 49 49: def have_any? 50: if c = @complexcontent || @content 51: c.have_any? 52: else 53: false 54: end 55: end
# File lib/wsdl/xmlSchema/complexType.rb, line 106 106: def nested_elements 107: if c = @complexcontent || @content 108: c.nested_elements 109: else 110: XSD::NamedElements::Empty 111: end 112: end
# File lib/wsdl/xmlSchema/complexType.rb, line 175 175: def parse_attr(attr, value) 176: case attr 177: when AbstractAttrName 178: @abstract = to_boolean(value) 179: when FinalAttrName 180: @final = value.source 181: when MixedAttrName 182: @mixed = to_boolean(value) 183: when NameAttrName 184: @name = XSD::QName.new(targetnamespace, value.source) 185: else 186: nil 187: end 188: end
# File lib/wsdl/xmlSchema/complexType.rb, line 144 144: def parse_element(element) 145: case element 146: when AllName 147: @content = All.new 148: when SequenceName 149: @content = Sequence.new 150: when ChoiceName 151: @content = Choice.new 152: when GroupName 153: @content = Group.new 154: when ComplexContentName 155: @complexcontent = ComplexContent.new 156: when SimpleContentName 157: @simplecontent = SimpleContent.new 158: when AttributeName 159: o = Attribute.new 160: @attributes << o 161: o 162: when AttributeGroupName 163: o = AttributeGroup.new 164: @attributes << o 165: o 166: when AnyAttributeName 167: o = AnyAttribute.new 168: @attributes << o 169: o 170: else 171: nil 172: end 173: end
# File lib/wsdl/soap/complexType.rb, line 159 159: def content_arytype 160: if arytype = find_arytype 161: ns = arytype.namespace 162: name = arytype.name.sub(/\[(?:,)*\]$/, '') 163: XSD::QName.new(ns, name) 164: else 165: nil 166: end 167: end
# File lib/wsdl/soap/complexType.rb, line 136 136: def element_simpletype(element) 137: case element 138: when XMLSchema::Element 139: if element.type 140: element.type 141: elsif element.local_simpletype 142: element.local_simpletype.base 143: else 144: # element definition 145: nil 146: end 147: when XMLSchema::Any 148: XSD::AnyTypeName 149: else 150: nil 151: end 152: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.