4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/isValidTransformation.rb', line 4
def self.check(transformation)
validXml = Nokogiri::XML(transformation).errors.empty?
if validXml
document = Nokogiri::XML('<?xml version="1.0"?><trades><trade><id>2</id><value>3452</value><valuedate>20181206</valuedate></trade><trade><id>6</id><value>45</value><valuedate>54654</valuedate></trade></trades>')
template = Nokogiri::XSLT(transformation)
begin
template.transform(document)
rescue StandardError => e
print e
return false
end
return true
else
return false
end
end
|