1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00
ruby--ruby/lib/rexml/parsers/streamparser.rb
ser ea7a527a2a Initial revision
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@3925 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-06-10 01:31:01 +00:00

33 lines
800 B
Ruby

module REXML
module Parsers
class StreamParser
def initialize source, listener
@listener = listener
@parser = BaseParser.new( source )
end
def parse
# entity string
while true
event = @parser.pull
case event[0]
when :end_document
return
when :start_element
@listener.tag_start( event[1], event[2] )
when :end_element
@listener.tag_end( event[1] )
when :text
normalized = @parser.unnormalize( event[1] )
@listener.text( normalized )
when :processing_instruction
@listener.instruction( *event[1,2] )
when :comment, :doctype, :attlistdecl,
:elementdecl, :entitydecl, :cdata, :notationdecl, :xmldecl
@listener.send( event[0].to_s, *event[1..-1] )
end
end
end
end
end
end