Class: RXSD::XSD::Group
- Inherits:
-
Object
- Object
- RXSD::XSD::Group
- Defined in:
- lib/rxsd/xsd/group.rb
Overview
XSD Group defintion www.w3schools.com/Schema/el_group.asp
Instance Attribute Summary collapse
-
#choice ⇒ Object
group children.
-
#id ⇒ Object
group attributes.
-
#maxOccurs ⇒ Object
group attributes.
-
#minOccurs ⇒ Object
group attributes.
-
#name ⇒ Object
group attributes.
-
#parent ⇒ Object
group parent.
-
#ref ⇒ Object
group attributes.
-
#sequence ⇒ Object
group children.
Class Method Summary collapse
-
.from_xml(node) ⇒ Object
node passed in should be a xml node representing the group.
-
.tag_name ⇒ Object
xml tag name.
Instance Method Summary collapse
-
#child_attributes ⇒ Object
return all child attributes assocaited w/ group.
-
#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_builders ⇒ Object
convert group to array of class builders.
Instance Attribute Details
#choice ⇒ Object
group children
17 18 19 |
# File 'lib/rxsd/xsd/group.rb', line 17 def choice @choice end |
#id ⇒ Object
group attributes
14 15 16 |
# File 'lib/rxsd/xsd/group.rb', line 14 def id @id end |
#maxOccurs ⇒ Object
group attributes
14 15 16 |
# File 'lib/rxsd/xsd/group.rb', line 14 def maxOccurs @maxOccurs end |
#minOccurs ⇒ Object
group attributes
14 15 16 |
# File 'lib/rxsd/xsd/group.rb', line 14 def minOccurs @minOccurs end |
#name ⇒ Object
group attributes
14 15 16 |
# File 'lib/rxsd/xsd/group.rb', line 14 def name @name end |
#parent ⇒ Object
group parent
20 21 22 |
# File 'lib/rxsd/xsd/group.rb', line 20 def parent @parent end |
#ref ⇒ Object
group attributes
14 15 16 |
# File 'lib/rxsd/xsd/group.rb', line 14 def ref @ref end |
#sequence ⇒ Object
group children
17 18 19 |
# File 'lib/rxsd/xsd/group.rb', line 17 def sequence @sequence end |
Class Method Details
.from_xml(node) ⇒ Object
node passed in should be a xml node representing the group
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/rxsd/xsd/group.rb', line 41 def self.from_xml(node) group = Group.new group.parent = node.parent. node. = group # TODO group attributes: | anyAttributes group.id = node.attrs["id"] group.name = node.attrs["name"] group.ref = node.attrs["ref"] group.maxOccurs = node.attrs.has_key?("maxOccurs") ? (node.attrs["maxOccurs"] == "unbounded" ? "unbounded" : node.attrs["maxOccurs"].to_i) : 1 group.minOccurs = node.attrs.has_key?("minOccurs") ? (node.attrs["minOccurs"] == "unbounded" ? "unbounded" : node.attrs["minOccurs"].to_i) : 1 # TODO group children: | element(?) group.choice = node.child_obj Choice group.sequence = node.child_obj Sequence return group end |
.tag_name ⇒ Object
xml tag name
23 24 25 |
# File 'lib/rxsd/xsd/group.rb', line 23 def self.tag_name "group" end |
Instance Method Details
#child_attributes ⇒ Object
return all child attributes assocaited w/ group
90 91 92 93 94 95 |
# File 'lib/rxsd/xsd/group.rb', line 90 def child_attributes atts = [] atts += @sequence.child_attributes unless @sequence.nil? atts += @choice.child_attributes unless @choice.nil? return atts end |
#children ⇒ Object
returns array of all children
33 34 35 36 37 38 |
# File 'lib/rxsd/xsd/group.rb', line 33 def children c = [] c.push @choice unless @choice.nil? c.push @sequence unless @sequence.nil? return c end |
#info ⇒ Object
return xsd node info
28 29 30 |
# File 'lib/rxsd/xsd/group.rb', line 28 def info "group id: #{@id} name: #{@name} ref: #{ref.nil? ? "" : ref.class == String ? ref : ref.name} " end |
#resolve(node_objs) ⇒ Object
resolve hanging references given complete xsd node object array
65 66 67 68 69 |
# File 'lib/rxsd/xsd/group.rb', line 65 def resolve(node_objs) unless @ref.nil? @ref = node_objs[Group].find { |no| no.name == @ref } end end |
#to_class_builders ⇒ Object
convert group to array of class builders
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/rxsd/xsd/group.rb', line 72 def to_class_builders unless defined? @class_builder # just dispatch to ref or child @class_builder = [] if !@ref.nil? @class_builder = @ref.to_class_builders elsif !@choice.nil? @class_builder = @choice.to_class_builders elsif !@sequence.nil? @class_builder = @sequence.to_class_builders end end return @class_builder end |