summaryrefslogtreecommitdiff
path: root/lib/rexml/parsers/baseparser.rb
diff options
context:
space:
mode:
authorser <ser@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-06-10 02:01:04 +0000
committerser <ser@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2004-06-10 02:01:04 +0000
commit3289dfc78b4c5051b0079217a193ce50d5349506 (patch)
tree564ff1057a5341fa9b28cf03218851f8d0255f4f /lib/rexml/parsers/baseparser.rb
parentf2b75020ba193b6d20788c800fde583ca8e900d5 (diff)
-
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@6441 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/rexml/parsers/baseparser.rb')
-rw-r--r--lib/rexml/parsers/baseparser.rb39
1 files changed, 38 insertions, 1 deletions
diff --git a/lib/rexml/parsers/baseparser.rb b/lib/rexml/parsers/baseparser.rb
index fbb1ec06a8..16e5c80237 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