blob: 51441289d9dc8b443436c2cd6a4b188aa0b6cfb2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
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
|