# frozen_string_literal: false
require 'xmlscan/scanner'
class XMLScanParser < BaseParser
input = StringIO.new(@rss)
scanner = XMLScan::XMLScanner.new(@listener)
rescue XMLScan::Error => e
lineno = e.lineno || scanner.lineno || input.lineno
raise NotWellFormedError.new(lineno){e.message}
class XMLScanListener < BaseListener
def on_xmldecl_version(str)
def on_xmldecl_encoding(str)
def on_xmldecl_standalone(str)
xmldecl(@version, @encoding, @standalone == "yes")
alias_method(:on_pi, :instruction)
alias_method(:on_chardata, :text)
alias_method(:on_cdata, :text)
alias_method(:on_charref_hex, :on_charref)
@attrs[name] = @current_attr = ''
def on_attr_entityref(ref)
@current_attr << entity(ref)
def on_attr_charref(code)
@current_attr << [code].pack('U')
alias_method(:on_attr_charref_hex, :on_attr_charref)
def on_stag_end_empty(name)
wellformed_error("undefined entity: #{ref}")