Class: WsdlMapper::Dom::Builder

Inherits:
Object
  • Object
show all
Defined in:
lib/wsdl_mapper/dom/builder.rb

Instance Method Summary (collapse)

Constructor Details

- (Builder) initialize(xsd_file)

Returns a new instance of Builder



12
13
14
# File 'lib/wsdl_mapper/dom/builder.rb', line 12

def initialize(xsd_file)
  @xsd_file = xsd_file
end

Instance Method Details

- (Object) build



16
17
18
19
20
21
22
23
24
# 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

- (Object) build_name(qname)



49
50
51
# File 'lib/wsdl_mapper/dom/builder.rb', line 49

def build_name(qname)
  Name.get qname.namespace, qname.name
end

- (Object) build_property(schema, xsd_element)



39
40
41
42
43
44
45
46
47
# 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

- (Object) build_type(schema, xsd_type)



26
27
28
29
30
31
32
33
34
35
36
37
# 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

- (Object) get_attribute_bounds(xsd_element)



60
61
62
63
64
65
66
67
# File 'lib/wsdl_mapper/dom/builder.rb', line 60

def get_attribute_bounds(xsd_element)
  min = nil
  max = nil
  byebug
  xsd_element.attributes.each do |attr|

  end
end

- (Object) get_bounds(xsd_element)



53
54
55
56
57
58
# 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

- (Object) get_parent_bounds(xsd_element)



69
70
71
72
73
74
75
76
# File 'lib/wsdl_mapper/dom/builder.rb', line 69

def get_parent_bounds(xsd_element)
  case xsd_element
  when WSDL::XMLSchema::Sequence
    Bounds.new min: 1, max: 1
  else
    Bounds.new
  end
end

- (Object) get_sequence(xsd_element)



78
79
80
81
82
83
# File 'lib/wsdl_mapper/dom/builder.rb', line 78

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