Last active
August 29, 2015 14:07
-
-
Save mriddle/a94c8e6dd32b7be0877e to your computer and use it in GitHub Desktop.
xslt transformation and poi counter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/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}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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