11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/xsd/class_maker.rb', line 11
def make_definition(node, target = Object)
return if is_text node
return if node.
return if node.name === 'include'
attrs = node.attributes.to_hash
return unless attrs['name'].present?
name = attrs['name'].value
if is_element(node) || is_choice(node)
type = attrs['type'].value if attrs.key? 'type'
if type.nil?
complex_node = select_children(node, 'complexType').first
defined_class_name = define_class name, complex_node, target
{ name: name, type: defined_class_name }
else
{ name: name, type: sanitize_class_name(type.split(':').last) }
end
elsif is_simple node
unless name.nil?
restrictions = select_children(node, 'restriction').first
Tiss::Generator::ValidatorGenerator.call(@version, name, restrictions, target)
end
elsif is_complex_root node
define_class name, node, target
end
end
|