Class: RXSD::XSD::ComplexContent

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

Overview

XSD ComplexContent defintion www.w3schools.com/Schema/el_complexcontent.asp

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#extensionObject

complex content children



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

def extension
  @extension
end

#idObject

complex content attributes



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

def id
  @id
end

#mixedObject

complex content attributes



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

def mixed
  @mixed
end

#parentObject

complex content parent



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

def parent
  @parent
end

#restrictionObject

complex content children



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

def restriction
  @restriction
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
# File 'lib/rxsd/xsd/complex_content.rb', line 41

def self.from_xml(node)
   complex_content = ComplexContent.new
   complex_content.parent = node.parent.related
   node.related = complex_content

   # TODO group attributes: | anyAttributes
   complex_content.id       = node.attrs["id"]
   complex_content.mixed    = node.attrs.has_key?("mixed") ? node.attrs["mixed"].to_b : false

   complex_content.restriction   = node.child_obj Restriction
   complex_content.extension     = node.child_obj Extension

   return complex_content
end

.tag_nameObject

xml tag name



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

def self.tag_name
  "complexContent"
end

Instance Method Details

#child_attributesObject

return all child attributes associated w/ complex content



77
78
79
80
81
82
# File 'lib/rxsd/xsd/complex_content.rb', line 77

def child_attributes
   atts = []
   atts += @restriction.child_attributes unless @restriction.nil?
   atts += @extension.child_attributes unless @extension.nil?
   return atts
end

#childrenObject

returns array of all children



33
34
35
36
37
38
# File 'lib/rxsd/xsd/complex_content.rb', line 33

def children
  c = []
  c.push @restriction unless @restriction.nil?
  c.push @extension unless @extension.nil?
  return c
end

#infoObject

return xsd node info



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

def info
  "complexContent id: #{@id}"
end

#resolve(node_objs) ⇒ Object

resolve hanging references given complete xsd node object array



57
58
# File 'lib/rxsd/xsd/complex_content.rb', line 57

def resolve(node_objs)
end

#to_class_builder(cb = nil) ⇒ Object

convert complex content to class builder



61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/rxsd/xsd/complex_content.rb', line 61

def to_class_builder(cb = nil)
  unless defined? @class_builder
    # dispatch to child restriction/extension
    @class_builder = cb

    if !@restriction.nil?
       @class_builder = @restriction.to_class_builder(@class_builder)
    elsif !@extension.nil?
       @class_builder = @extension.to_class_builder(@class_builder)
    end
  end

  return @class_builder
end