Class: RXSD::XSD::AttributeGroup

Inherits:
Object
  • Object
show all
Defined in:
lib/rxsd/xsd/attribute_group.rb

Overview

XSD AttributeGroup defintion www.w3schools.com/Schema/el_attributegroup.asp

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#attribute_groupsObject

attribute group children



17
18
19
# File 'lib/rxsd/xsd/attribute_group.rb', line 17

def attribute_groups
  @attribute_groups
end

#attributesObject

attribute group children



17
18
19
# File 'lib/rxsd/xsd/attribute_group.rb', line 17

def attributes
  @attributes
end

#idObject

attribute group attributes



14
15
16
# File 'lib/rxsd/xsd/attribute_group.rb', line 14

def id
  @id
end

#nameObject

attribute group attributes



14
15
16
# File 'lib/rxsd/xsd/attribute_group.rb', line 14

def name
  @name
end

#parentObject

attribute group parent



20
21
22
# File 'lib/rxsd/xsd/attribute_group.rb', line 20

def parent
  @parent
end

#refObject

attribute group attributes



14
15
16
# File 'lib/rxsd/xsd/attribute_group.rb', line 14

def ref
  @ref
end

Class Method Details

.from_xml(node) ⇒ Object

node passed in should be a xml node representing the attribute group



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rxsd/xsd/attribute_group.rb', line 38

def self.from_xml(node)
   attribute_group = AttributeGroup.new
   attribute_group.parent = node.parent.related
   node.related = attribute_group

   # TODO attribute group attributes: | anyAttributes
   attribute_group.id       = node.attrs["id"]
   attribute_group.name     = node.attrs["name"]
   attribute_group.ref      = node.attrs["ref"]

   # TODO attribute group children: | anyAttribute
   attribute_group.attributes        = node.children_objs Attribute
   attribute_group.attribute_groups = node.children_objs AttributeGroup

   return attribute_group
end

.tag_nameObject

xml tag name



23
24
25
# File 'lib/rxsd/xsd/attribute_group.rb', line 23

def self.tag_name
  "attributeGroup"
end

Instance Method Details

#child_attributesObject

return all child attributes associated w/ attribute group



80
81
82
83
84
85
# File 'lib/rxsd/xsd/attribute_group.rb', line 80

def child_attributes
   atts = []
   @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

#childrenObject

returns array of all children



33
34
35
# File 'lib/rxsd/xsd/attribute_group.rb', line 33

def children
   @attributes + @attribute_groups
end

#infoObject

return xsd node info



28
29
30
# File 'lib/rxsd/xsd/attribute_group.rb', line 28

def info
  "attributeGroup 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



56
57
58
59
60
# File 'lib/rxsd/xsd/attribute_group.rb', line 56

def resolve(node_objs)
  unless @ref.nil?
    @ref = node_objs[AttributeGroup].find { |no| no.name == @ref }
  end
end

#to_class_buildersObject

convert attribute group to array of class builders



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/rxsd/xsd/attribute_group.rb', line 63

def to_class_builders
  unless defined? @class_builders
    @class_builders = []
    @attributes.each { |att|
       @class_builders.push att.to_class_builder
    }
    @attribute_groups.each { |atg|
       atg.to_class_builders.each { |atcb|
          @class_builders.push atcb
       }
    }
  end

  return @class_builders
end