Class: WSDL::XMLSchema::Element
- Includes:
- Ref
- Defined in:
- lib/wsdl/soap/element.rb,
lib/wsdl/xmlSchema/element.rb
Instance Attribute Summary collapse
-
#constraint ⇒ Object
writeonly
Sets the attribute constraint.
-
#form ⇒ Object
writeonly
Sets the attribute form.
-
#local_complextype ⇒ Object
writeonly
Sets the attribute local_complextype.
-
#local_simpletype ⇒ Object
writeonly
Sets the attribute local_simpletype.
-
#maxoccurs ⇒ Object
Returns the value of attribute maxoccurs.
-
#minoccurs ⇒ Object
Returns the value of attribute minoccurs.
-
#name ⇒ Object
writeonly
required.
-
#nillable ⇒ Object
writeonly
Sets the attribute nillable.
-
#type ⇒ Object
writeonly
Sets the attribute type.
Attributes included from Ref
Attributes inherited from Info
Instance Method Summary collapse
- #anonymous_type? ⇒ Boolean
- #attributes ⇒ Object
- #elementform ⇒ Object
- #elementformdefault ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(name = nil, type = nil) ⇒ Element
constructor
A new instance of Element.
- #map_as_array? ⇒ Boolean
- #parse_attr(attr, value) ⇒ Object
- #parse_element(element) ⇒ Object
- #targetnamespace ⇒ Object
Methods included from Ref
Methods inherited from Info
Constructor Details
#initialize(name = nil, type = nil) ⇒ Element
Returns a new instance of Element.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/wsdl/xmlSchema/element.rb', line 40 def initialize(name = nil, type = nil) super() @name = name @form = nil @type = type @local_simpletype = @local_complextype = nil @constraint = nil @maxoccurs = 1 @minoccurs = 1 @nillable = nil @default = nil @abstract = false @ref = nil @refelement = nil end |
Instance Attribute Details
#constraint=(value) ⇒ Object (writeonly)
Sets the attribute constraint
25 26 27 |
# File 'lib/wsdl/xmlSchema/element.rb', line 25 def constraint=(value) @constraint = value end |
#form=(value) ⇒ Object (writeonly)
Sets the attribute form
21 22 23 |
# File 'lib/wsdl/xmlSchema/element.rb', line 21 def form=(value) @form = value end |
#local_complextype=(value) ⇒ Object (writeonly)
Sets the attribute local_complextype
24 25 26 |
# File 'lib/wsdl/xmlSchema/element.rb', line 24 def local_complextype=(value) @local_complextype = value end |
#local_simpletype=(value) ⇒ Object (writeonly)
Sets the attribute local_simpletype
23 24 25 |
# File 'lib/wsdl/xmlSchema/element.rb', line 23 def local_simpletype=(value) @local_simpletype = value end |
#maxoccurs ⇒ Object
Returns the value of attribute maxoccurs.
26 27 28 |
# File 'lib/wsdl/xmlSchema/element.rb', line 26 def maxoccurs @maxoccurs end |
#minoccurs ⇒ Object
Returns the value of attribute minoccurs.
27 28 29 |
# File 'lib/wsdl/xmlSchema/element.rb', line 27 def minoccurs @minoccurs end |
#name=(value) ⇒ Object (writeonly)
required
20 21 22 |
# File 'lib/wsdl/xmlSchema/element.rb', line 20 def name=(value) @name = value end |
#nillable=(value) ⇒ Object (writeonly)
Sets the attribute nillable
28 29 30 |
# File 'lib/wsdl/xmlSchema/element.rb', line 28 def nillable=(value) @nillable = value end |
#type=(value) ⇒ Object (writeonly)
Sets the attribute type
22 23 24 |
# File 'lib/wsdl/xmlSchema/element.rb', line 22 def type=(value) @type = value end |
Instance Method Details
#anonymous_type? ⇒ Boolean
22 23 24 |
# File 'lib/wsdl/soap/element.rb', line 22 def anonymous_type? !@ref and @name and @local_complextype end |
#attributes ⇒ Object
26 27 28 |
# File 'lib/wsdl/soap/element.rb', line 26 def attributes @local_complextype.attributes end |
#elementform ⇒ Object
68 69 70 |
# File 'lib/wsdl/xmlSchema/element.rb', line 68 def elementform self.form.nil? ? parent.elementformdefault : self.form end |
#elementformdefault ⇒ Object
64 65 66 |
# File 'lib/wsdl/xmlSchema/element.rb', line 64 def elementformdefault parent.elementformdefault end |
#empty? ⇒ Boolean
56 57 58 |
# File 'lib/wsdl/xmlSchema/element.rb', line 56 def empty? !(local_simpletype || local_complextype || constraint || type) end |
#map_as_array? ⇒ Boolean
17 18 19 20 |
# File 'lib/wsdl/soap/element.rb', line 17 def map_as_array? # parent sequence / choice may be marked as maxOccurs="unbounded" maxoccurs.nil? or maxoccurs != 1 or (parent and parent.map_as_array?) end |
#parse_attr(attr, value) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 |
# File 'lib/wsdl/xmlSchema/element.rb', line 89 def parse_attr(attr, value) case attr when NameAttrName # namespace may be nil if directelement? or elementform == 'qualified' @name = XSD::QName.new(targetnamespace, value.source) else @name = XSD::QName.new(nil, value.source) end when FormAttrName @form = value.source if @form != 'qualified' and @name.namespace @name = XSD::QName.new(nil, @name.name) end @form when TypeAttrName @type = value when RefAttrName @ref = value when MaxOccursAttrName if parent.is_a?(All) if value.source != '1' raise Parser::AttributeConstraintError.new( "cannot parse #{value} for #{attr}") end end if value.source == 'unbounded' @maxoccurs = nil else @maxoccurs = Integer(value.source) end value.source when MinOccursAttrName if parent.is_a?(All) unless ['0', '1'].include?(value.source) raise Parser::AttributeConstraintError.new( "cannot parse #{value} for #{attr}") end end @minoccurs = Integer(value.source) when NillableAttrName @nillable = to_boolean(value) when DefaultAttrName @default = value.source when AbstractAttrName @abstract = to_boolean(value) else nil end end |
#parse_element(element) ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/wsdl/xmlSchema/element.rb', line 72 def parse_element(element) case element when SimpleTypeName @local_simpletype = SimpleType.new @local_simpletype when ComplexTypeName @type = nil @local_complextype = ComplexType.new @local_complextype when UniqueName @constraint = Unique.new @constraint else nil end end |
#targetnamespace ⇒ Object
60 61 62 |
# File 'lib/wsdl/xmlSchema/element.rb', line 60 def targetnamespace parent.targetnamespace end |