Extended maintenance of Ruby 1.9.3 ended on February 23, 2015. Read more

In Files

  • rexml/parsers/streamparser.rb

Parent

Class/Module Index [+]

Quicksearch

REXML::Parsers::StreamParser

Public Class Methods

new(source, listener) click to toggle source
 
               # File rexml/parsers/streamparser.rb, line 4
def initialize source, listener
  @listener = listener
  @parser = BaseParser.new( source )
end
            

Public Instance Methods

add_listener( listener ) click to toggle source
 
               # File rexml/parsers/streamparser.rb, line 9
def add_listener( listener )
  @parser.add_listener( listener )
end
            
parse() click to toggle source
 
               # File rexml/parsers/streamparser.rb, line 13
def parse
  # entity string
  while true
    event = @parser.pull
    case event[0]
    when :end_document
      return
    when :start_element
      attrs = event[2].each do |n, v|
        event[2][n] = @parser.unnormalize( v )
      end
      @listener.tag_start( event[1], attrs )
    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 :start_doctype
      @listener.doctype( *event[1..-1] )
    when :end_doctype
      # FIXME: remove this condition for milestone:3.2
      @listener.doctype_end if @listener.respond_to? :doctype_end
    when :comment, :attlistdecl, :cdata, :xmldecl, :elementdecl
      @listener.send( event[0].to_s, *event[1..-1] )
    when :entitydecl, :notationdecl
      @listener.send( event[0].to_s, event[1..-1] )
    end
  end
end
            

Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.

If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.

If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.

If you want to help improve the Ruby documentation, please visit Documenting-ruby.org.