Class: RXSD::XSD::Restriction
- Inherits:
-
Object
- Object
- RXSD::XSD::Restriction
- Defined in:
- lib/rxsd/xsd/restriction.rb
Overview
XSD Restriction defintion www.w3schools.com/Schema/el_restriction.asp
Instance Attribute Summary collapse
-
#attribute_groups ⇒ Object
restriction group children.
-
#attributes ⇒ Object
restriction group children.
-
#base ⇒ Object
restriction attributes.
-
#choice ⇒ Object
restriction group children.
-
#enumerations ⇒ Object
restrictions.
-
#fraction_digits ⇒ Object
restrictions.
-
#group ⇒ Object
restriction group children.
-
#id ⇒ Object
restriction attributes.
-
#length ⇒ Object
restrictions.
-
#max_exclusive ⇒ Object
restrictions.
-
#max_inclusive ⇒ Object
restrictions.
-
#max_length ⇒ Object
restrictions.
-
#min_exclusive ⇒ Object
restrictions.
-
#min_inclusive ⇒ Object
restrictions.
-
#min_length ⇒ Object
restrictions.
-
#parent ⇒ Object
restriction parent.
-
#pattern ⇒ Object
restrictions.
-
#sequence ⇒ Object
restriction group children.
-
#simple_type ⇒ Object
restriction group children.
-
#total_digits ⇒ Object
restrictions.
-
#whitespace ⇒ Object
restrictions.
Class Method Summary collapse
-
.from_xml(node) ⇒ Object
node passed in should be a xml node representing the restriction.
-
.tag_name ⇒ Object
xml tag name.
Instance Method Summary collapse
-
#child_attributes ⇒ Object
return all child attributes assocaited w/ restriction.
-
#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 restriction to class builder.
Instance Attribute Details
#attribute_groups ⇒ Object
restriction group children
17 18 19 |
# File 'lib/rxsd/xsd/restriction.rb', line 17 def attribute_groups @attribute_groups end |
#attributes ⇒ Object
restriction group children
17 18 19 |
# File 'lib/rxsd/xsd/restriction.rb', line 17 def attributes @attributes end |
#base ⇒ Object
restriction attributes
14 15 16 |
# File 'lib/rxsd/xsd/restriction.rb', line 14 def base @base end |
#choice ⇒ Object
restriction group children
17 18 19 |
# File 'lib/rxsd/xsd/restriction.rb', line 17 def choice @choice end |
#enumerations ⇒ Object
restrictions
20 21 22 |
# File 'lib/rxsd/xsd/restriction.rb', line 20 def enumerations @enumerations end |
#fraction_digits ⇒ Object
restrictions
20 21 22 |
# File 'lib/rxsd/xsd/restriction.rb', line 20 def fraction_digits @fraction_digits end |
#group ⇒ Object
restriction group children
17 18 19 |
# File 'lib/rxsd/xsd/restriction.rb', line 17 def group @group end |
#id ⇒ Object
restriction attributes
14 15 16 |
# File 'lib/rxsd/xsd/restriction.rb', line 14 def id @id end |
#length ⇒ Object
restrictions
20 21 22 |
# File 'lib/rxsd/xsd/restriction.rb', line 20 def length @length end |
#max_exclusive ⇒ Object
restrictions
20 21 22 |
# File 'lib/rxsd/xsd/restriction.rb', line 20 def max_exclusive @max_exclusive end |
#max_inclusive ⇒ Object
restrictions
20 21 22 |
# File 'lib/rxsd/xsd/restriction.rb', line 20 def max_inclusive @max_inclusive end |
#max_length ⇒ Object
restrictions
20 21 22 |
# File 'lib/rxsd/xsd/restriction.rb', line 20 def max_length @max_length end |
#min_exclusive ⇒ Object
restrictions
20 21 22 |
# File 'lib/rxsd/xsd/restriction.rb', line 20 def min_exclusive @min_exclusive end |
#min_inclusive ⇒ Object
restrictions
20 21 22 |
# File 'lib/rxsd/xsd/restriction.rb', line 20 def min_inclusive @min_inclusive end |
#min_length ⇒ Object
restrictions
20 21 22 |
# File 'lib/rxsd/xsd/restriction.rb', line 20 def min_length @min_length end |
#parent ⇒ Object
restriction parent
25 26 27 |
# File 'lib/rxsd/xsd/restriction.rb', line 25 def parent @parent end |
#pattern ⇒ Object
restrictions
20 21 22 |
# File 'lib/rxsd/xsd/restriction.rb', line 20 def pattern @pattern end |
#sequence ⇒ Object
restriction group children
17 18 19 |
# File 'lib/rxsd/xsd/restriction.rb', line 17 def sequence @sequence end |
#simple_type ⇒ Object
restriction group children
17 18 19 |
# File 'lib/rxsd/xsd/restriction.rb', line 17 def simple_type @simple_type end |
#total_digits ⇒ Object
restrictions
20 21 22 |
# File 'lib/rxsd/xsd/restriction.rb', line 20 def total_digits @total_digits end |
#whitespace ⇒ Object
restrictions
20 21 22 |
# File 'lib/rxsd/xsd/restriction.rb', line 20 def whitespace @whitespace end |
Class Method Details
.from_xml(node) ⇒ Object
node passed in should be a xml node representing the restriction
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/rxsd/xsd/restriction.rb', line 50 def self.from_xml(node) restriction = Restriction.new restriction.parent = node.parent. node. = restriction # TODO restriction attributes: | anyAttributes restriction.id = node.attrs["id"] restriction.base = node.attrs["base"] if node.parent.name == ComplexContent.tag_name # TODO restriction children: | anyAttribute restriction.group = node.child_obj Group restriction.choice = node.child_obj Choice restriction.sequence = node.child_obj Sequence restriction.attributes = node.children_objs Attribute restriction.attribute_groups = node.children_objs AttributeGroup elsif node.parent.name == SimpleContent.tag_name # TODO restriction children: | anyAttribute restriction.attributes = node.children_objs Attribute restriction.attribute_groups = node.children_objs AttributeGroup restriction.simple_type = node.child_obj SimpleType parse_restrictions(restriction, node) else # SimpleType restriction.attributes = [] restriction.attribute_groups = [] restriction.simple_type = node.child_obj SimpleType parse_restrictions(restriction, node) end return restriction end |
.tag_name ⇒ Object
xml tag name
28 29 30 |
# File 'lib/rxsd/xsd/restriction.rb', line 28 def self.tag_name "restriction" end |
Instance Method Details
#child_attributes ⇒ Object
return all child attributes assocaited w/ restriction
152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/rxsd/xsd/restriction.rb', line 152 def child_attributes atts = [] atts += @base.child_attributes unless @base.nil? || ![SimpleType, ComplexType].include?(@base.class) atts += @sequence.child_attributes unless @sequence.nil? atts += @choice.child_attributes unless @choice.nil? atts += @group.child_attributes unless @group.nil? atts += @simple_type.child_attributes unless @simple_type.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
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rxsd/xsd/restriction.rb', line 38 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? c.push @simple_type unless @simple_type.nil? return c end |
#info ⇒ Object
return xsd node info
33 34 35 |
# File 'lib/rxsd/xsd/restriction.rb', line 33 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
86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/rxsd/xsd/restriction.rb', line 86 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 restriction to class builder
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 139 140 141 142 143 144 145 146 147 148 149 |
# File 'lib/rxsd/xsd/restriction.rb', line 102 def to_class_builder(cb = nil) unless defined? @class_builder @class_builder = cb.nil? ? ClassBuilder.new : cb # convert restriction 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 } } unless @simple_type.nil? @class_builder.attribute_builders.push @simple_type.to_class_builder end # FIXME add facets end return @class_builder end |