Class: RXSD::XSD::Extension
- Inherits:
-
Object
- Object
- RXSD::XSD::Extension
- Defined in:
- lib/rxsd/xsd/extension.rb
Overview
XSD Extension defintion www.w3schools.com/Schema/el_extension.asp
Instance Attribute Summary collapse
-
#attribute_groups ⇒ Object
extension group children.
-
#attributes ⇒ Object
extension group children.
-
#base ⇒ Object
extension attributes.
-
#choice ⇒ Object
extension group children.
-
#group ⇒ Object
extension group children.
-
#id ⇒ Object
extension attributes.
-
#parent ⇒ Object
extension parent.
-
#sequence ⇒ Object
extension group children.
Class Method Summary collapse
-
.from_xml(node) ⇒ Object
node passed in should be a xml node representing the extension.
-
.tag_name ⇒ Object
xml tag name.
Instance Method Summary collapse
-
#child_attributes ⇒ Object
return all child attributes assocaited w/ extension.
-
#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(cb = nil) ⇒ Object
convert extension to class builder.
Instance Attribute Details
#attribute_groups ⇒ Object
extension group children
17 18 19 |
# File 'lib/rxsd/xsd/extension.rb', line 17 def attribute_groups @attribute_groups end |
#attributes ⇒ Object
extension group children
17 18 19 |
# File 'lib/rxsd/xsd/extension.rb', line 17 def attributes @attributes end |
#base ⇒ Object
extension attributes
14 15 16 |
# File 'lib/rxsd/xsd/extension.rb', line 14 def base @base end |
#choice ⇒ Object
extension group children
17 18 19 |
# File 'lib/rxsd/xsd/extension.rb', line 17 def choice @choice end |
#group ⇒ Object
extension group children
17 18 19 |
# File 'lib/rxsd/xsd/extension.rb', line 17 def group @group end |
#id ⇒ Object
extension attributes
14 15 16 |
# File 'lib/rxsd/xsd/extension.rb', line 14 def id @id end |
#parent ⇒ Object
extension parent
20 21 22 |
# File 'lib/rxsd/xsd/extension.rb', line 20 def parent @parent end |
#sequence ⇒ Object
extension group children
17 18 19 |
# File 'lib/rxsd/xsd/extension.rb', line 17 def sequence @sequence end |
Class Method Details
.from_xml(node) ⇒ Object
node passed in should be a xml node representing the extension
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/rxsd/xsd/extension.rb', line 44 def self.from_xml(node) extension = Extension.new extension.parent = node.parent. node. = extension # TODO extension attributes: | anyAttributes extension.id = node.attrs["id"] extension.base = node.attrs["base"] # TODO extension children: | anyAttribute extension.group = node.child_obj Group extension.choice = node.child_obj Choice extension.sequence = node.child_obj Sequence extension.attributes = node.children_objs Attribute extension.attribute_groups = node.children_objs AttributeGroup return extension end |
.tag_name ⇒ Object
xml tag name
23 24 25 |
# File 'lib/rxsd/xsd/extension.rb', line 23 def self.tag_name "extension" end |
Instance Method Details
#child_attributes ⇒ Object
return all child attributes assocaited w/ extension
124 125 126 127 128 129 130 131 132 133 |
# File 'lib/rxsd/xsd/extension.rb', line 124 def child_attributes atts = [] atts += @base.child_attributes unless @base.nil? || ![SimpleType, ComplexType].include?(@base.class) atts += @choice.child_attributes unless @choice.nil? atts += @sequence.child_attributes unless @sequence.nil? atts += @group.child_attributes unless @group.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
33 34 35 36 37 38 39 40 41 |
# File 'lib/rxsd/xsd/extension.rb', line 33 def children c = [] c.push @group unless @group.nil? c.push @choice unless @choice.nil? c.push @sequence unless @sequence.nil? c += @attributes unless @attributes.nil? c += @attribute_groups unless @attribute_groups.nil? return c end |
#info ⇒ Object
return xsd node info
28 29 30 |
# File 'lib/rxsd/xsd/extension.rb', line 28 def info "extension id: #{@id} base: #{@base.nil? ? "" : (@base.class == String || Parser.is_builtin?(@base)) ? @base : @base.name }" end |
#resolve(node_objs) ⇒ Object
resolve hanging references given complete xsd node object array
64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/rxsd/xsd/extension.rb', line 64 def resolve(node_objs) unless @base.nil? builtin = Parser.parse_builtin_type @base simple = node_objs[SimpleType].find { |no| no.name == @base } complex = node_objs[ComplexType].find { |no| no.name == @base } if !builtin.nil? @base = builtin elsif !simple.nil? @base = simple elsif !complex.nil? @base = complex end end end |
#to_class_builder(cb = nil) ⇒ Object
convert extension to class builder
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 120 121 |
# File 'lib/rxsd/xsd/extension.rb', line 80 def to_class_builder(cb = nil) unless defined? @class_builder @class_builder = cb.nil? ? ClassBuilder.new : cb # convert extension to builder if Parser.is_builtin? @base @class_builder.base = @base elsif !@base.nil? @class_builder.base_builder = @base.to_class_builder end unless @group.nil? @group.to_class_builders.each { |gcb| @class_builder.attribute_builders.push gcb } end unless @choice.nil? @choice.to_class_builders.each { |ccb| @class_builder.attribute_builders.push ccb } end unless @sequence.nil? @sequence.to_class_builders.each { |scb| @class_builder.attribute_builders.push scb } end @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 } } end return @class_builder end |