Skip to content

Instantly share code, notes, and snippets.

@mriddle
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mriddle/a94c8e6dd32b7be0877e to your computer and use it in GitHub Desktop.
Save mriddle/a94c8e6dd32b7be0877e to your computer and use it in GitHub Desktop.
xslt transformation and poi counter
#/usr/bin/env ruby
require 'rexml/document'
total_poi_count = 0
Dir.glob("output/*.xml").each do |file|
# extract event information
doc = REXML::Document.new(File.read(file))
poi_count = doc.elements.to_a('//vendor-pois/entry').length
puts "Count: #{poi_count} for #{file}"
total_poi_count += poi_count
end
puts "Total count: #{total_poi_count}"
require 'xml/xslt'
xslt = XML::XSLT.new()
xslt.xsl = "2nokia-transform-5 GC.xslt"
Dir.glob("xml_files/*.xml").each do |file|
xslt.xml = file
new_xml_path = file.split("/")[1]
File.open("output/#{new_xml_path}", 'w') { |f| f.write(xslt.serve()) }
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment