1
# WSDL4R - SOAP complexType definition for WSDL.
2
# Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
4
# This program is copyrighted free software by NAKAMURA, Hiroshi. You can
5
# redistribute it and/or modify it under the same terms of Ruby's license;
6
# either the dual license version in 2003, or any later version.
9
require 'wsdl/xmlSchema/complexType'
10
require 'soap/mapping'
17
class ComplexType < Info
19
@compoundtype ||= check_type
24
if attributes.empty? and
25
content.elements.size == 1 and content.elements[0].maxoccurs != '1'
26
if name == ::SOAP::Mapping::MapQName
35
if complexcontent.base == ::SOAP::ValueArrayName
38
complexcontent.basetype.check_type
42
elsif !attributes.empty?
44
else # empty complexType definition (seen in partner.wsdl of salesforce)
49
def child_type(name = nil)
52
if ele = find_element(name)
54
elsif ele = find_element_by_name(name.name)
58
@contenttype ||= content_arytype
60
item_ele = find_element_by_name("item") or
61
raise RuntimeError.new("'item' element not found in Map definition.")
62
content = item_ele.local_complextype or
63
raise RuntimeError.new("No complexType definition for 'item'.")
64
if ele = content.find_element(name)
66
elsif ele = content.find_element_by_name(name.name)
70
raise NotImplementedError.new("Unknown kind of complexType.")
74
def child_defined_complextype(name)
77
when :TYPE_STRUCT, :TYPE_MAP
78
unless ele = find_element(name)
79
if name.namespace.nil?
80
ele = find_element_by_name(name.name)
84
if content.elements.size == 1
85
ele = content.elements[0]
87
raise RuntimeError.new("Assert: must not reach.")
90
raise RuntimeError.new("Assert: Not implemented.")
93
raise RuntimeError.new("Cannot find #{name} as a children of #{@name}.")
99
unless compoundtype == :TYPE_ARRAY
100
raise RuntimeError.new("Assert: not for array")
103
complexcontent.attributes.each do |attribute|
104
if attribute.ref == ::SOAP::AttrArrayTypeName
105
return attribute.arytype
108
if check_array_content(complexcontent.content)
109
return element_simpletype(complexcontent.content.elements[0])
111
elsif check_array_content(content)
112
return element_simpletype(content.elements[0])
114
raise RuntimeError.new("Assert: Unknown array definition.")
118
unless compoundtype == :TYPE_ARRAY
119
raise RuntimeError.new("Assert: not for array")
122
if check_array_content(complexcontent.content)
123
return complexcontent.content.elements[0]
125
elsif check_array_content(content)
126
return content.elements[0]
128
nil # use default item name
133
def element_simpletype(element)
136
elsif element.local_simpletype
137
element.local_simpletype.base
143
def check_array_content(content)
144
content and content.elements.size == 1 and
145
content.elements[0].maxoccurs != '1'
149
if arytype = find_arytype
150
ns = arytype.namespace
151
name = arytype.name.sub(/\[(?:,)*\]$/, '')
152
XSD::QName.new(ns, name)