diff options
author | ser <ser@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-06-10 02:01:04 +0000 |
---|---|---|
committer | ser <ser@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2004-06-10 02:01:04 +0000 |
commit | a5246fbccaf3a4afd4c9c5982b331b335b69f2ff (patch) | |
tree | 564ff1057a5341fa9b28cf03218851f8d0255f4f /lib/rexml/parsers/baseparser.rb | |
parent | 35d79021ec3d4692b0178d5fbeb8a4c00bb0c65d (diff) | |
download | ruby-a5246fbccaf3a4afd4c9c5982b331b335b69f2ff.tar.gz ruby-a5246fbccaf3a4afd4c9c5982b331b335b69f2ff.tar.xz ruby-a5246fbccaf3a4afd4c9c5982b331b335b69f2ff.zip |
-
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@6441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rexml/parsers/baseparser.rb')
-rw-r--r-- | lib/rexml/parsers/baseparser.rb | 39 |
1 files changed, 38 insertions, 1 deletions
diff --git a/lib/rexml/parsers/baseparser.rb b/lib/rexml/parsers/baseparser.rb index fbb1ec06a..16e5c8023 100644 --- a/lib/rexml/parsers/baseparser.rb +++ b/lib/rexml/parsers/baseparser.rb @@ -100,6 +100,23 @@ module REXML self.stream = source end + def add_listener( listener ) + if !defined?(@listeners) or !@listeners + @listeners = [] + instance_eval <<-EOL + alias :_old_pull :pull + def pull + event = _old_pull + @listeners.each do |listener| + listener.receive event + end + event + end + EOL + end + @listeners << listener + end + attr_reader :source def stream=( source ) @@ -162,11 +179,11 @@ module REXML # Returns the next event. This is a +PullEvent+ object. def pull - return [ :end_document ] if empty? if @closed x, @closed = @closed, nil return [ :end_element, x ] end + return [ :end_document ] if empty? return @stack.shift if @stack.size > 0 @source.read if @source.buffer.size<2 if @document_status == nil @@ -411,3 +428,23 @@ module REXML end end end + +=begin + case event[0] + when :start_element + when :text + when :end_element + when :processing_instruction + when :cdata + when :comment + when :xmldecl + when :start_doctype + when :end_doctype + when :externalentity + when :elementdecl + when :entity + when :attlistdecl + when :notationdecl + when :end_doctype + end +=end |