mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* lib/rexml/parsers/sax2parser.rb
(REXML::Parsers::SAX2Parser#handle_entitydecl): Extract. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
7e0022bc8e
commit
8328d8a2b7
2 changed files with 33 additions and 24 deletions
|
@ -1,3 +1,8 @@
|
|||
Sun Aug 11 18:42:13 2013 Kouhei Sutou <kou@cozmixng.org>
|
||||
|
||||
* lib/rexml/parsers/sax2parser.rb
|
||||
(REXML::Parsers::SAX2Parser#handle_entitydecl): Extract.
|
||||
|
||||
Sun Aug 11 18:40:25 2013 Kouhei Sutou <kou@cozmixng.org>
|
||||
|
||||
* lib/rexml/parsers/sax2parser.rb (REXML::Parsers::SAX2Parser#parse):
|
||||
|
|
|
@ -176,6 +176,28 @@ module REXML
|
|||
}
|
||||
handle( :characters, copy )
|
||||
when :entitydecl
|
||||
handle_entitydecl( event )
|
||||
when :processing_instruction, :comment, :attlistdecl,
|
||||
:elementdecl, :cdata, :notationdecl, :xmldecl
|
||||
handle( *event )
|
||||
end
|
||||
handle( :progress, @parser.position )
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def handle( symbol, *arguments )
|
||||
tag = @tag_stack[-1]
|
||||
procs = get_procs( symbol, tag )
|
||||
listeners = get_listeners( symbol, tag )
|
||||
# notify observers
|
||||
procs.each { |ob| ob.call( *arguments ) } if procs
|
||||
listeners.each { |l|
|
||||
l.send( symbol.to_s, *arguments )
|
||||
} if listeners
|
||||
end
|
||||
|
||||
def handle_entitydecl( event )
|
||||
@entities[ event[1] ] = event[2] if event.size == 3
|
||||
parameter_reference_p = false
|
||||
case event[2]
|
||||
|
@ -200,24 +222,6 @@ module REXML
|
|||
end
|
||||
event[1, 0] = event.pop if parameter_reference_p
|
||||
handle( event[0], event[1..-1] )
|
||||
when :processing_instruction, :comment, :attlistdecl,
|
||||
:elementdecl, :cdata, :notationdecl, :xmldecl
|
||||
handle( *event )
|
||||
end
|
||||
handle( :progress, @parser.position )
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def handle( symbol, *arguments )
|
||||
tag = @tag_stack[-1]
|
||||
procs = get_procs( symbol, tag )
|
||||
listeners = get_listeners( symbol, tag )
|
||||
# notify observers
|
||||
procs.each { |ob| ob.call( *arguments ) } if procs
|
||||
listeners.each { |l|
|
||||
l.send( symbol.to_s, *arguments )
|
||||
} if listeners
|
||||
end
|
||||
|
||||
# The following methods are duplicates, but it is faster than using
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue