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.



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

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

Instance Attribute Details

#elementsObject (readonly)

Returns the value of attribute elements.



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

def elements
  @elements
end

#maxoccursObject (readonly)

Returns the value of attribute maxoccurs.



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

def maxoccurs
  @maxoccurs
end

#minoccursObject (readonly)

Returns the value of attribute minoccurs.



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

def minoccurs
  @minoccurs
end

Instance Method Details

#<<(element) ⇒ Object



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

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

#choice?Boolean

Returns:

  • (Boolean)


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

def choice?
  false
end

#elementformdefaultObject



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

def elementformdefault
  parent.elementformdefault
end

#have_any?Boolean

Returns:

  • (Boolean)


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

def have_any?
  false
end

#map_as_array?Boolean

Returns:

  • (Boolean)


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

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

#nested_elementsObject



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

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



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

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



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

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

#targetnamespaceObject



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

def targetnamespace
  parent.targetnamespace
end