Class: WsdlMapper::DomParsing::AttributeParser

Inherits:
ParserBase show all
Defined in:
lib/wsdl_mapper/dom_parsing/attribute_parser.rb

Constant Summary

Constants included from Xsd

Xsd::ALL, Xsd::ANNOTATION, Xsd::ANY_ATTRIBUTE, Xsd::APPINFO, Xsd::ATTRIBUTE, Xsd::ATTRIBUTE_FORM_DEFAULT, Xsd::CHOICE, Xsd::COMPLEX_CONTENT, Xsd::COMPLEX_TYPE, Xsd::DEFAULT_BOUNDS, Xsd::DOCUMENTATION, Xsd::ELEMENT, Xsd::ELEMENT_FORM_DEFAULT, Xsd::ENUMERATION, Xsd::EXTENSION, Xsd::FRACTION_DIGITS, Xsd::IMPORT, Xsd::MAX_INCLUSIVE, Xsd::MAX_LENGTH, Xsd::MIN_INCLUSIVE, Xsd::MIN_LENGTH, Xsd::NS, Xsd::PATTERN, Xsd::RESTRICTION, Xsd::SCHEMA, Xsd::SEQUENCE, Xsd::SIMPLE_CONTENT, Xsd::SIMPLE_TYPE, Xsd::TOTAL_DIGITS, Xsd::UNIQUE

Constants inherited from Parsing::Base

Parsing::Base::NS_DECL_PREFIX, Parsing::Base::TARGET_NS

Instance Attribute Summary

Attributes included from Parsing::Logging

#log_msgs

Instance Method Summary collapse

Methods inherited from Parsing::Base

get_name, #initialize

Methods included from Parsing::Logging

#log_msg

Constructor Details

This class inherits a constructor from WsdlMapper::Parsing::Base

Instance Method Details

#parse(node) ⇒ Object

Parameters:

  • node (Nokogiri::XML::Node)


8
9
10
# File 'lib/wsdl_mapper/dom_parsing/attribute_parser.rb', line 8

def parse(node)
  parse_attribute node, @base.schema
end

#parse_attribute(node, container) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/wsdl_mapper/dom_parsing/attribute_parser.rb', line 12

def parse_attribute(node, container)
  name = parse_name_in_attribute 'name', node
  ref = parse_name_in_attribute 'ref', node

  attr = if name
    type_name = parse_name_in_attribute 'type', node

    Attribute.new name, type_name,
      default: fetch_attribute_value('default', node),
      use: fetch_attribute_value('use', node, 'optional'),
      fixed: fetch_attribute_value('fixed', node),
      form: fetch_attribute_value('form', node)
  elsif ref
    Attribute::Ref.new ref
  else
    log_msg node, :invalid_attribute
  end

  container.add_attribute attr

  each_element node do |child|
    case get_name child
    when ANNOTATION
      parse_annotation child, attr
    when SIMPLE_TYPE
      # TODO: test
      attr.type = @base.parsers[SIMPLE_TYPE].parse child
      attr.type.containing_property = attr
    else
      log_msg child, :unknown
    end
  end
end