class WsdlMapper::Dom::Builder

Public Class Methods

new(xsd_file) click to toggle source
# File lib/wsdl_mapper/dom/builder.rb, line 12
def initialize(xsd_file)
  @xsd_file = xsd_file
end

Public Instance Methods

build() click to toggle source
# File lib/wsdl_mapper/dom/builder.rb, line 16
def build
  schema = Schema.new

  @xsd_file.complex_types.each do |xsd_type|
    schema.add_type build_type(schema, xsd_type)
  end

  schema
end
build_name(qname) click to toggle source
# File lib/wsdl_mapper/dom/builder.rb, line 49
def build_name(qname)
  Name.get qname.namespace, qname.name
end
build_property(_schema, xsd_element) click to toggle source
# File lib/wsdl_mapper/dom/builder.rb, line 39
def build_property(_schema, xsd_element)
  name = build_name xsd_element.name
  type_name = build_name xsd_element.type

  sequence = get_sequence xsd_element
  bounds = get_bounds xsd_element

  Property.new name, type_name, sequence: sequence, bounds: bounds
end
build_type(schema, xsd_type) click to toggle source
# File lib/wsdl_mapper/dom/builder.rb, line 26
def build_type(schema, xsd_type)
  name = build_name xsd_type.name

  type = ComplexType.new name

  xsd_type.elements.each do |element|
    property = build_property schema, element
    type.add_property property
  end

  type
end
get_bounds(xsd_element) click to toggle source
# File lib/wsdl_mapper/dom/builder.rb, line 53
def get_bounds(xsd_element)
  parent_bounds = get_parent_bounds xsd_element.parent
  # bounds = get_attribute_bounds xsd_element

  parent_bounds #.override bounds
end
get_parent_bounds(xsd_element) click to toggle source
# File lib/wsdl_mapper/dom/builder.rb, line 60
def get_parent_bounds(xsd_element)
  case xsd_element
  when WSDL::XMLSchema::Sequence
    Bounds.new min: 1, max: 1
  else
    Bounds.new
  end
end
get_sequence(xsd_element) click to toggle source
# File lib/wsdl_mapper/dom/builder.rb, line 69
def get_sequence(xsd_element)
  parent = xsd_element.parent
  return 0 unless parent.is_a? WSDL::XMLSchema::Sequence

  parent.elements.find_index xsd_element
end