40
41
42
43
44
45
46
47
48
49
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
84
85
86
87
88
89
90
91
92
|
# File 'lib/fabulator/lib/function.rb', line 40
def compile_xml(xml, context)
super
@actions = [ ]
@wrapper = [ ]
if !xml.nil?
ctx = nil
if xml.name == 'template' && xml.namespaces.namespace.href == FAB_LIB_NS
ctx = @context.merge(xml)
@wrapper = [ '', '' ]
else
ctx = @context.merge
s = ""
if (xml.namespaces.namespace.prefix rescue nil)
s += xml.namespaces.namespace.prefix + ":"
end
s += xml.name
e = "</" + s + ">"
s = "<" + s
xml.each_attr do |attr|
s += " "
if attr.ns?
s += attr.ns.prefix + ":"
end
s += attr.name + "="
if attr.value =~ /"/
s += "'" + attr.value.gsub(/&/, '&').gsub(/</, '<').gsub(/'/, '"') + "'"
else
s += '"' + attr.value.gsub(/&/, '&').gsub(/</, '<') + '"'
end
end
s += ">"
@wrapper = [ s, e ]
end
xml.each_child do |node|
if node.element?
if ctx.action_exists?((node.namespaces.namespace.href rescue nil), node.name)
@actions << ctx.compile_action(node)
else
a = self.class.new
a.compile_xml(node, ctx)
@actions << a
end
elsif node.text? || node.cdata?
@actions << node.content
end
end
end
self
end
|