Class REXML::Parsers::LightParser
In: lib/rexml/parsers/lightparser.rb
Parent: Object

Methods

add_listener   new   parse   rewind  

Public Class methods

[Source]

    # File lib/rexml/parsers/lightparser.rb, line 8
 8:                         def initialize stream
 9:                                 @stream = stream
10:                                 @parser = REXML::Parsers::BaseParser.new( stream )
11:                         end

Public Instance methods

[Source]

    # File lib/rexml/parsers/lightparser.rb, line 13
13:       def add_listener( listener )
14:         @parser.add_listener( listener )
15:       end

[Source]

    # File lib/rexml/parsers/lightparser.rb, line 22
22:                         def parse
23:                                 root = context = [ :document ]
24:                                 while true
25:                                         event = @parser.pull
26:                                         case event[0]
27:                                         when :end_document
28:                                                 break
29:                                         when :end_doctype
30:                                                 context = context[1]
31:                                         when :start_element, :start_doctype
32:                                                 new_node = event
33:                                                 context << new_node
34:                                                 new_node[1,0] = [context]
35:                                                 context = new_node
36:                                         when :end_element, :end_doctype
37:                                                 context = context[1]
38:                                         else
39:                                                 new_node = event
40:                                                 context << new_node
41:                                                 new_node[1,0] = [context]
42:                                         end
43:                                 end
44:                                 root
45:                         end

[Source]

    # File lib/rexml/parsers/lightparser.rb, line 17
17:       def rewind
18:         @stream.rewind
19:         @parser.stream = @stream
20:       end

[Validate]