def complex_type_to_class(complex_type_xml)
    type = Helpers.get_namespaced_attribute(complex_type_xml, 'type', 'm')

    is_collection = false
    # Extract the class name in case this is a Collection
    if type =~ /\(([^)]*)\)/m
    	type = $~[1]
      is_collection = true
      collection = []
    end

    klass_name = qualify_class_name(type.split('.')[-1])

    if is_collection
      # extract the elements from the collection
      elements = complex_type_xml.xpath(".//d:element", @namespaces)
      elements.each do |e|
        if type.match(/^Edm/)
          collection << parse_value(e.content, type)
        else
          element = @classes[klass_name].new
          fill_complex_type_properties(e, element)
          collection << element
        end
      end
      return collection
    else
      klass = @classes[klass_name].new
      # Fill in the properties
      fill_complex_type_properties(complex_type_xml, klass)
      return klass
    end
  end
def complex_type_to_class(complex_type_xml)
    type = Helpers.get_namespaced_attribute(complex_type_xml, 'type', 'm')

    is_collection = false
    # Extract the class name in case this is a Collection
    if type =~ /\(([^)]*)\)/m
    	type = $~[1]
      is_collection = true
      collection = []
    end

    klass_name = qualify_class_name(type.split('.')[-1])

    if is_collection
      # extract the elements from the collection
      elements = complex_type_xml.xpath(".//d:element", @namespaces)
      elements.each do |e|
        if type.match(/^Edm/)
          collection << parse_value(e.content, type)
        else
          element = @classes[klass_name].new
          fill_complex_type_properties(e, element)
          collection << element
        end
      end
      return collection
    else
      klass = @classes[klass_name].new
      # Fill in the properties
      fill_complex_type_properties(complex_type_xml, klass)
      return klass
    end
  end
Complex Types