aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/xml_mini
diff options
context:
space:
mode:
authorWillem van Bergen <willem@vanbergen.org>2010-01-01 13:44:42 +0100
committerJeremy Kemper <jeremy@bitsweat.net>2010-01-01 13:18:03 -0800
commit689984ddd3a482b5c0986fdf1889323f096050fa (patch)
treefdccbe76a57e6ef2847da5375ae586a462acea7a /activesupport/lib/active_support/xml_mini
parent96a2b3905ce14df8f25b1646d3b110505bf8820b (diff)
downloadrails-689984ddd3a482b5c0986fdf1889323f096050fa.tar.gz
rails-689984ddd3a482b5c0986fdf1889323f096050fa.tar.bz2
rails-689984ddd3a482b5c0986fdf1889323f096050fa.zip
Fixed some bugs and fixed some tests in new SAX-based XmlMini backends.
[#3636 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
Diffstat (limited to 'activesupport/lib/active_support/xml_mini')
-rw-r--r--activesupport/lib/active_support/xml_mini/libxmlsax.rb14
-rw-r--r--activesupport/lib/active_support/xml_mini/nokogirisax.rb2
2 files changed, 8 insertions, 8 deletions
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 = [])