Class: RXSD::XSD::Choice
- Inherits:
-
Object
- Object
- RXSD::XSD::Choice
- Defined in:
- lib/rxsd/xsd/choice.rb
Overview
XSD Choice defintion www.w3schools.com/Schema/el_choice.asp
Instance Attribute Summary collapse
-
#choices ⇒ Object
choice children.
-
#elements ⇒ Object
choice children.
-
#groups ⇒ Object
choice children.
-
#id ⇒ Object
choice attributes.
-
#maxOccurs ⇒ Object
choice attributes.
-
#minOccurs ⇒ Object
choice attributes.
-
#parent ⇒ Object
choice parent.
-
#sequences ⇒ Object
choice 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/ choice.
-
#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 choice to array of class builders.
Instance Attribute Details
#choices ⇒ Object
choice children
17 18 19 |
# File 'lib/rxsd/xsd/choice.rb', line 17 def choices @choices end |
#elements ⇒ Object
choice children
17 18 19 |
# File 'lib/rxsd/xsd/choice.rb', line 17 def elements @elements end |
#groups ⇒ Object
choice children
17 18 19 |
# File 'lib/rxsd/xsd/choice.rb', line 17 def groups @groups end |
#id ⇒ Object
choice attributes
14 15 16 |
# File 'lib/rxsd/xsd/choice.rb', line 14 def id @id end |
#maxOccurs ⇒ Object
choice attributes
14 15 16 |
# File 'lib/rxsd/xsd/choice.rb', line 14 def maxOccurs @maxOccurs end |
#minOccurs ⇒ Object
choice attributes
14 15 16 |
# File 'lib/rxsd/xsd/choice.rb', line 14 def minOccurs @minOccurs end |
#parent ⇒ Object
choice parent
20 21 22 |
# File 'lib/rxsd/xsd/choice.rb', line 20 def parent @parent end |
#sequences ⇒ Object
choice children
17 18 19 |
# File 'lib/rxsd/xsd/choice.rb', line 17 def sequences @sequences end |
Class Method Details
.from_xml(node) ⇒ Object
node passed in should be a xml node representing the group
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/rxsd/xsd/choice.rb', line 38 def self.from_xml(node) choice = Choice.new choice.parent = node.parent. node. = choice # TODO choice attributes: | anyAttributes choice.id = node.attrs["id"] choice.maxOccurs = node.attrs.has_key?("maxOccurs") ? (node.attrs["maxOccurs"] == "unbounded" ? "unbounded" : node.attrs["maxOccurs"].to_i) : 1 choice.minOccurs = node.attrs.has_key?("minOccurs") ? (node.attrs["minOccurs"] == "unbounded" ? "unbounded" : node.attrs["minOccurs"].to_i) : 1 # TODO choice children: | any choice.elements = node.children_objs Element choice.groups = node.children_objs Group choice.choices = node.children_objs Choice choice.sequences = node.children_objs Sequence return choice end |
.tag_name ⇒ Object
xml tag name
23 24 25 |
# File 'lib/rxsd/xsd/choice.rb', line 23 def self.tag_name "choice" end |
Instance Method Details
#child_attributes ⇒ Object
return all child attributes assocaited w/ choice
94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/rxsd/xsd/choice.rb', line 94 def child_attributes atts = [] @elements.each { |elem| eca = elem.child_attributes atts += eca unless eca.nil? } unless @elements.nil? @sequences.each { |seq| atts += seq.child_attributes } unless @sequences.nil? @choices.each { |ch| atts += ch.child_attributes } unless @choices.nil? @groups.each { |gr| atts += gr.child_attributes } unless @groups.nil? return atts end |
#children ⇒ Object
returns array of all children
33 34 35 |
# File 'lib/rxsd/xsd/choice.rb', line 33 def children @elements + @groups + @choices + @sequences end |
#info ⇒ Object
return xsd node info
28 29 30 |
# File 'lib/rxsd/xsd/choice.rb', line 28 def info "choice id: #{@id}" end |
#resolve(node_objs) ⇒ Object
resolve hanging references given complete xsd node object array
61 62 |
# File 'lib/rxsd/xsd/choice.rb', line 61 def resolve(node_objs) end |
#to_class_builders ⇒ Object
convert choice to array of class builders
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/rxsd/xsd/choice.rb', line 65 def to_class_builders # FIXME enforce "only one attribute must be set" unless defined? @class_builders @class_builders = [] @elements.each { |e| @class_builders.push e.to_class_builder } @groups.each { |g| g.to_class_builders.each { |gcb| @class_builders.push gcb } } @choices.each { |c| c.to_class_builders.each { |ccb| @class_builders.push ccb } } @sequences.each { |s| s.to_class_builders.each { |scb| @class_builders.push scb } } end return @class_builders end |