Class: RXSD::XSD::ComplexType
- Inherits:
-
Object
- Object
- RXSD::XSD::ComplexType
- Defined in:
- lib/rxsd/xsd/complex_type.rb
Overview
XSD ComplexType defintion www.w3schools.com/Schema/el_simpletype.asp
Instance Attribute Summary collapse
-
#abstract ⇒ Object
complex type attribute values.
-
#attribute_groups ⇒ Object
complex type children.
-
#attributes ⇒ Object
complex type children.
-
#choice ⇒ Object
complex type children.
-
#complex_content ⇒ Object
complex type children.
-
#group ⇒ Object
complex type children.
-
#id ⇒ Object
complex type attribute values.
-
#mixed ⇒ Object
complex type attribute values.
-
#name ⇒ Object
complex type attribute values.
-
#parent ⇒ Object
complexType parent.
-
#sequence ⇒ Object
complex type children.
-
#simple_content ⇒ Object
complex type children.
Class Method Summary collapse
-
.from_xml(node) ⇒ Object
node passed in should be a xml node representing the complex type.
-
.tag_name ⇒ Object
xml tag name.
Instance Method Summary collapse
-
#child_attributes ⇒ Object
return all child attributes assocaited w/ complex type.
-
#children ⇒ Object
returns array of all children.
-
#info ⇒ Object
return xsd node info.
-
#resolve(node_objs) ⇒ Object
resolve hanging references given complete xsd node object array.
-
#to_class_builder ⇒ Object
convert complex type to class builder.
Instance Attribute Details
#abstract ⇒ Object
complex type attribute values
14 15 16 |
# File 'lib/rxsd/xsd/complex_type.rb', line 14 def abstract @abstract end |
#attribute_groups ⇒ Object
complex type children
17 18 19 |
# File 'lib/rxsd/xsd/complex_type.rb', line 17 def attribute_groups @attribute_groups end |
#attributes ⇒ Object
complex type children
17 18 19 |
# File 'lib/rxsd/xsd/complex_type.rb', line 17 def attributes @attributes end |
#choice ⇒ Object
complex type children
17 18 19 |
# File 'lib/rxsd/xsd/complex_type.rb', line 17 def choice @choice end |
#complex_content ⇒ Object
complex type children
17 18 19 |
# File 'lib/rxsd/xsd/complex_type.rb', line 17 def complex_content @complex_content end |
#group ⇒ Object
complex type children
17 18 19 |
# File 'lib/rxsd/xsd/complex_type.rb', line 17 def group @group end |
#id ⇒ Object
complex type attribute values
14 15 16 |
# File 'lib/rxsd/xsd/complex_type.rb', line 14 def id @id end |
#mixed ⇒ Object
complex type attribute values
14 15 16 |
# File 'lib/rxsd/xsd/complex_type.rb', line 14 def mixed @mixed end |
#name ⇒ Object
complex type attribute values
14 15 16 |
# File 'lib/rxsd/xsd/complex_type.rb', line 14 def name @name end |
#parent ⇒ Object
complexType parent
22 23 24 |
# File 'lib/rxsd/xsd/complex_type.rb', line 22 def parent @parent end |
#sequence ⇒ Object
complex type children
17 18 19 |
# File 'lib/rxsd/xsd/complex_type.rb', line 17 def sequence @sequence end |
#simple_content ⇒ Object
complex type children
17 18 19 |
# File 'lib/rxsd/xsd/complex_type.rb', line 17 def simple_content @simple_content end |
Class Method Details
.from_xml(node) ⇒ Object
node passed in should be a xml node representing the complex type
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/rxsd/xsd/complex_type.rb', line 41 def self.from_xml(node) complexType = ComplexType.new complexType.parent = node.parent. node. = complexType # TODO complexType attributes: | block, final, anyAttributes complexType.id = node.attrs['id'] complexType.name = node.attrs['name'] complexType.abstract = node.attrs.has_key?('abstract') ? node.attrs['abstract'].to_b : false if node.children.find { |c| c.name == SimpleContent.tag_name }.nil? complexType.mixed = node.attrs.has_key?('mixed') ? node.attrs['mixed'].to_b : false else complexType.mixed = false end # TODO complexType children: | all, anyAttribute, complexType.attributes = node.children_objs Attribute complexType.attribute_groups = node.children_objs AttributeGroup complexType.simple_content = node.child_obj SimpleContent complexType.complex_content = node.child_obj ComplexContent complexType.group = node.child_obj Group complexType.choice = node.child_obj Choice complexType.sequence = node.child_obj Sequence return complexType end |
.tag_name ⇒ Object
xml tag name
25 26 27 |
# File 'lib/rxsd/xsd/complex_type.rb', line 25 def self.tag_name "complexType" end |
Instance Method Details
#child_attributes ⇒ Object
return all child attributes assocaited w/ complex type
122 123 124 125 126 127 128 129 130 131 132 |
# File 'lib/rxsd/xsd/complex_type.rb', line 122 def child_attributes atts = [] atts += @choice.child_attributes unless @choice.nil? atts += @sequence.child_attributes unless @sequence.nil? atts += @group.child_attributes unless @group.nil? atts += @simple_content.child_attributes unless @simple_content.nil? atts += @complex_content.child_attributes unless @complex_content.nil? @attribute_groups.each { |atg| atts += atg.child_attributes } unless @attribute_groups.nil? @attributes.each { |att| atts += att.child_attributes } unless @attributes.nil? return atts end |
#children ⇒ Object
returns array of all children
35 36 37 38 |
# File 'lib/rxsd/xsd/complex_type.rb', line 35 def children (@attributes + @attribute_groups).push(@simple_content). push(@complex_content).push(@choice).push(@group).push(@sequence) end |
#info ⇒ Object
return xsd node info
30 31 32 |
# File 'lib/rxsd/xsd/complex_type.rb', line 30 def info "complexType id: #{@id} name: #{@name}" end |
#resolve(node_objs) ⇒ Object
resolve hanging references given complete xsd node object array
71 72 |
# File 'lib/rxsd/xsd/complex_type.rb', line 71 def resolve(node_objs) end |
#to_class_builder ⇒ Object
convert complex type to class builder
75 76 77 78 79 80 81 82 83 84 85 86 87 88 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 |
# File 'lib/rxsd/xsd/complex_type.rb', line 75 def to_class_builder unless defined? @class_builder # dispatch to simple / complex content to get class builder @class_builder = ClassBuilder.new if !@simple_content.nil? @simple_content.to_class_builder(@class_builder) elsif !@complex_content.nil? @complex_content.to_class_builder(@class_builder) #else #@class_builder = ClassBuilder.new end @class_builder.klass_name = @name.camelize unless @name.nil? @attributes.each { |att| @class_builder.attribute_builders.push att.to_class_builder } @attribute_groups.each { |atg| atg.to_class_builders.each { |atcb| @class_builder.attribute_builders.push atcb } } if !@group.nil? @group.to_class_builders.each { |gcb| @class_builder.attribute_builders.push gcb } end if !@choice.nil? @choice.to_class_builders.each { |ccb| @class_builder.attribute_builders.push ccb } end if !@sequence.nil? @sequence.to_class_builders.each { |scb| @class_builder.attribute_builders.push scb } end end return @class_builder end |