Class: RXSD::XSD::List
- Inherits:
-
Object
- Object
- RXSD::XSD::List
- Defined in:
- lib/rxsd/xsd/list.rb
Overview
XSD List defintion www.w3schools.com/Schema/el_list.asp
Instance Attribute Summary collapse
-
#id ⇒ Object
list attributes.
-
#itemType ⇒ Object
list attributes.
-
#parent ⇒ Object
list parent.
-
#simple_type ⇒ Object
list children.
Class Method Summary collapse
-
.from_xml(node) ⇒ Object
node passed in should be a xml node representing the list.
-
.tag_name ⇒ Object
xml tag name.
Instance Method Summary collapse
-
#child_attributes ⇒ Object
return all child_attributes associated w/ simple 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 list to class builder.
Instance Attribute Details
#id ⇒ Object
list attributes
14 15 16 |
# File 'lib/rxsd/xsd/list.rb', line 14 def id @id end |
#itemType ⇒ Object
list attributes
14 15 16 |
# File 'lib/rxsd/xsd/list.rb', line 14 def itemType @itemType end |
#parent ⇒ Object
list parent
20 21 22 |
# File 'lib/rxsd/xsd/list.rb', line 20 def parent @parent end |
#simple_type ⇒ Object
list children
17 18 19 |
# File 'lib/rxsd/xsd/list.rb', line 17 def simple_type @simple_type end |
Class Method Details
.from_xml(node) ⇒ Object
node passed in should be a xml node representing the list
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rxsd/xsd/list.rb', line 40 def self.from_xml(node) list = List.new list.parent = node.parent. node. = list # TODO list attributes: | anyAttributes list.id = node.attrs["id"] if node.children.find { |c| c.name == SimpleType.tag_name }.nil? list.itemType = node.attrs["itemType"] else list.simple_type = node.child_obj SimpleType end return list end |
.tag_name ⇒ Object
xml tag name
23 24 25 |
# File 'lib/rxsd/xsd/list.rb', line 23 def self.tag_name "list" end |
Instance Method Details
#child_attributes ⇒ Object
return all child_attributes associated w/ simple type
90 91 92 93 94 95 96 |
# File 'lib/rxsd/xsd/list.rb', line 90 def child_attributes if !@itemType.nil? && @itemType.class == SimpleType return @itemType.child_attributes elsif !@simple_type.nil? return @simple_type.child_attributes end end |
#children ⇒ Object
returns array of all children
33 34 35 36 37 |
# File 'lib/rxsd/xsd/list.rb', line 33 def children c = [] c.push @simple_type unless @simple_type.nil? return c end |
#info ⇒ Object
return xsd node info
28 29 30 |
# File 'lib/rxsd/xsd/list.rb', line 28 def info "list id: #{@id}" end |
#resolve(node_objs) ⇒ Object
resolve hanging references given complete xsd node object array
59 60 61 62 63 64 |
# File 'lib/rxsd/xsd/list.rb', line 59 def resolve(node_objs) unless @itemType.nil? builtin = Parser.parse_builtin_type @itemType @itemType = !builtin.nil? ? builtin : node_objs[SimpleType].find { |no| no.name == @itemType } end end |
#to_class_builder ⇒ Object
convert list to class builder
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'lib/rxsd/xsd/list.rb', line 67 def to_class_builder unless defined? @class_builder # convert list to builder producing array of classes specified by item type or simple type @class_builder = ClassBuilder.new :klass => Array if !@itemType.nil? if @itemType.class == SimpleType @class_builder.associated_builder = @itemType.to_class_builder else @class_builder.associated_builder = ClassBuilder.new :klass => @itemType end elsif !@simple_type.nil? @class_builder.associated_builder = @simple_type.to_class_builder end end return @class_builder end |