[Aaron-devel-cvs] CVS: aaron/src/test/xml well_formed_xml_check.rb,NONE,1.1
Status: Pre-Alpha
Brought to you by:
thetitan
From: Sean C. <the...@us...> - 2001-06-29 05:30:11
|
Update of /cvsroot/aaron/aaron/src/test/xml In directory usw-pr-cvs1:/tmp/cvs-serv23471 Added Files: well_formed_xml_check.rb Log Message: Added a small ruby script that tests for well formed XML configuration files --- NEW FILE: well_formed_xml_check.rb --- #! /usr/local/bin/ruby ## XML well formedness checker # # Notes: # $< is a kick ass varible! Check it out (wish perl had this) # http://sean.chittenden.org/programming/ruby/programming_ruby/language.html#file_cat_obj print "Loading xmlparser..." require 'xmlparser' print "done\n" def testxml (file) # Begin exception handling begin xml = File.new(file) parser = XMLParser.new parser.parse(xml) # If you're here, then the document is well formed rescue XMLParserError line = parser.line column = parser.column print "\n" print "File:\t#{file}\n" print "Line:\t#{line}\n" print "Char:\t#{column}\n" print "Error:\t#{$!}\n" exit 1 end end ARGV.each { |file| testxml(file) } print "\nWell formed documents:\n" ARGV.each { |file| print "\t#{file}\n" } |