Module: Icl

Defined in:
lib/icl.rb,
lib/icl/version.rb

Constant Summary collapse

VERSION =
'1.0.0'

Class Method Summary collapse

Class Method Details

.transform(xml_file, *stylesheet_files) ⇒ Object



5
6
7
8
9
10
# File 'lib/icl.rb', line 5

def self.transform(xml_file, *stylesheet_files)
  xml_string = File.open("#{xml_file}")
  stylesheet_strings = stylesheet_files.map { |stylesheet_file| File.open("#{stylesheet_file}") }

  puts transform_from_strings(xml_string, *stylesheet_strings)
end

.transform_from_strings(xml_string, *stylesheet_strings) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/icl.rb', line 12

def self.transform_from_strings(xml_string, *stylesheet_strings)
  xml = Nokogiri::XML(xml_string)
  output = xml

  stylesheet_strings.each do |stylesheet_string|
    stylesheet = Nokogiri::XSLT(stylesheet_string)
    output = stylesheet.transform(output)
  end

  output
end