class XSD::XMLParser::OxParser
Public Instance Methods
do_parse(string_or_readable)
click to toggle source
# File lib/xsd/xmlparser/oxparser.rb, line 15 def do_parse(string_or_readable) $stderr.puts "XSD::XMLParser::OxParser.do_parse" if $DEBUG begin require 'htmlentities' # Used to unescape html-escaped chars, if available @decoder = ::HTMLEntities.new(:expanded) rescue LoadError @decoder = nil end handler = OxDocHandler.new(self, @decoder) string = string_or_readable.respond_to?(:read) ? string_or_readable.read : StringIO.new(string_or_readable) if @decoder.nil? # Use the built-in conversion with Ox. ::Ox.sax_parse(handler, string, {:symbolize=> false, :convert_special=> true, :skip=> :skip_return} ) else # Use HTMLEntities Decoder. Leave the special-character conversion alone and let HTMLEntities decode it for us. ::Ox.sax_parse(handler, string, {:skip=> :skip_none}) end end