Hi, I'm trying to write a RESTful web service in Rails. Before processing each POST request, I want to validate the XML against an XSD schema. It does not make sense to re-read the schema each time a request is processed. Therefore, I tried loading the schema once in a global variable ($schema) at application startup (from environment.rb).
However, only the first schema validation works. Whenever I post a second request, the xml.validate_schema($schema) call given in the code snippet below causes a segfault. I've tried storing loading the schema into a constant (SCHEMA) directly from environment.rb, but that too, causes a segfault. --- Code snippet --- module HelperMethods require 'xml/libxml' def self.read_schema $schema = XML::Schema.from_string(File.read('lib/schemas/trip.xsd')) end def self.do_xsd_validation(xml) error_message = "" puts("ABOUT TO VALIDATE") xml.validate_schema($schema) { |message, error| error_message += message } end end --- Relevant output, though I don't know how much it'll help --- ABOUT TO VALIDATE ./lib/helper_methods.rb:15: [BUG] Segmentation fault ruby 1.8.5 (2006-08-25) [i486-linux] Aborted (core dumped) --- in environment.rb I've put the following --- HelperMethods.read_schema Saurabh. -- http://nandz.blogspot.com http://foodieforlife.blogspot.com _______________________________________________ libxml-devel mailing list libxml-devel@rubyforge.org http://rubyforge.org/mailman/listinfo/libxml-devel