From 689984ddd3a482b5c0986fdf1889323f096050fa Mon Sep 17 00:00:00 2001 From: Willem van Bergen Date: Fri, 1 Jan 2010 13:44:42 +0100 Subject: Fixed some bugs and fixed some tests in new SAX-based XmlMini backends. [#3636 state:committed] Signed-off-by: Jeremy Kemper --- activesupport/lib/active_support/xml_mini/libxmlsax.rb | 14 +++++++------- activesupport/lib/active_support/xml_mini/nokogirisax.rb | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'activesupport/lib/active_support') diff --git a/activesupport/lib/active_support/xml_mini/libxmlsax.rb b/activesupport/lib/active_support/xml_mini/libxmlsax.rb index dba1f8755a..d7b2f4c5be 100644 --- a/activesupport/lib/active_support/xml_mini/libxmlsax.rb +++ b/activesupport/lib/active_support/xml_mini/libxmlsax.rb @@ -21,16 +21,13 @@ module ActiveSupport end def on_start_document - @hash = {} + @hash = { CONTENT_KEY => '' } @hash_stack = [@hash] end def on_end_document - raise "Parse stack not empty!" if @hash_stack.size > 1 - end - - def on_error(error_message) - raise LibXML::XML::Error, error_message + @hash = @hash_stack.pop + @hash.delete(CONTENT_KEY) end def on_start_element(name, attrs = {}) @@ -73,8 +70,11 @@ module ActiveSupport {} else data.ungetc(char) - document = self.document_class.new + + LibXML::XML::Error.set_handler(&LibXML::XML::Error::QUIET_HANDLER) parser = LibXML::XML::SaxParser.io(data) + document = self.document_class.new + parser.callbacks = document parser.parse document.hash diff --git a/activesupport/lib/active_support/xml_mini/nokogirisax.rb b/activesupport/lib/active_support/xml_mini/nokogirisax.rb index 42a44897ba..d538a9110f 100644 --- a/activesupport/lib/active_support/xml_mini/nokogirisax.rb +++ b/activesupport/lib/active_support/xml_mini/nokogirisax.rb @@ -28,7 +28,7 @@ module ActiveSupport end def error(error_message) - raise Nokogiri::XML::SyntaxError, error_message + raise error_message end def start_element(name, attrs = []) -- cgit v1.2.3