Class: WSDL::XMLSchema::Content

Inherits:
Info show all
Defined in:
lib/wsdl/xmlSchema/content.rb

Direct Known Subclasses

All, Choice, Sequence

Instance Attribute Summary collapse

Attributes inherited from Info

#id, #parent, #root

Instance Method Summary collapse

Methods inherited from Info

#inspect, #parse_epilogue

Constructor Details

#initializeContent

Returns a new instance of Content.



22
23
24
25
26
27
# File 'lib/wsdl/xmlSchema/content.rb', line 22

def initialize
  super()
  @minoccurs = 1
  @maxoccurs = 1
  @elements = XSD::NamedElements.new
end

Instance Attribute Details

#elementsObject (readonly)

Returns the value of attribute elements.



20
21
22
# File 'lib/wsdl/xmlSchema/content.rb', line 20

def elements
  @elements
end

#maxoccursObject (readonly)

Returns the value of attribute maxoccurs.



19
20
21
# File 'lib/wsdl/xmlSchema/content.rb', line 19

def maxoccurs
  @maxoccurs
end

#minoccursObject (readonly)

Returns the value of attribute minoccurs.



18
19
20
# File 'lib/wsdl/xmlSchema/content.rb', line 18

def minoccurs
  @minoccurs
end

Instance Method Details

#<<(element) ⇒ Object



61
62
63
# File 'lib/wsdl/xmlSchema/content.rb', line 61

def <<(element)
  @elements << element
end

#choice?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/wsdl/xmlSchema/content.rb', line 41

def choice?
  false
end

#elementformdefaultObject



33
34
35
# File 'lib/wsdl/xmlSchema/content.rb', line 33

def elementformdefault
  parent.elementformdefault
end

#have_any?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/wsdl/xmlSchema/content.rb', line 37

def have_any?
  false
end

#map_as_array?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/wsdl/xmlSchema/content.rb', line 45

def map_as_array?
  maxoccurs.nil? or maxoccurs != 1
end

#nested_elementsObject



49
50
51
52
53
54
55
56
57
58
59
# File 'lib/wsdl/xmlSchema/content.rb', line 49

def nested_elements
  elements = XSD::NamedElements.new
  @elements.each do |ele|
    if ele.respond_to?(:nested_elements)
      elements.concat(ele.nested_elements)
    else
      elements << ele
    end
  end
  elements
end

#parse_attr(attr, value) ⇒ Object



77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/wsdl/xmlSchema/content.rb', line 77

def parse_attr(attr, value)
  case attr
  when MaxOccursAttrName
    if value.source == 'unbounded'
      @maxoccurs = nil
    else
      @maxoccurs = Integer(value.source)
    end
    value.source
  when MinOccursAttrName
    @minoccurs = Integer(value.source)
  else
    nil
  end
end

#parse_element(element) ⇒ Object



65
66
67
68
69
70
71
72
73
74
75
# File 'lib/wsdl/xmlSchema/content.rb', line 65

def parse_element(element)
  case element
  when ElementName
    o = Element.new
    o.form = elementformdefault
    @elements << o
    o
  else
    nil
  end
end

#targetnamespaceObject



29
30
31
# File 'lib/wsdl/xmlSchema/content.rb', line 29

def targetnamespace
  parent.targetnamespace
end