Module: XmlToJson

Defined in:
lib/xml_to_json.rb

Class Method Summary collapse

Class Method Details

.rootObject



10
11
12
# File 'lib/xml_to_json.rb', line 10

def root
  @root ||= Pathname.new(__FILE__).dirname.parent
end

.stylesheetObject



14
15
16
# File 'lib/xml_to_json.rb', line 14

def stylesheet
  @stylesheet ||= Nokogiri::XSLT(root.join('vendor', 'xml2json-xslt', 'xml2json-patched.xslt').read)
end

.transform(xml) ⇒ Object



6
7
8
# File 'lib/xml_to_json.rb', line 6

def transform(xml)
  stylesheet.transform(Nokogiri::XML(xml)).text
end