# File rexml/pullparser.rb, line 52 def next if @closed x, @closed = @closed, nil return PullEvent.new( end_element:end_element, x ) end @source.read if @source.buffer.size==0 if @document_status == nil @source.match( /^\s*/um, true ) word = @source.match( /^\s*(<.*?)>/um ) word = word[1] unless word.nil? case word when Comment::START_RE return PullEvent.new( comment:comment, Comment.pull( @source )) when XMLDecl::START_RE return PullEvent.new( xmldecl:xmldecl, *XMLDecl.pull( @source )) when Instruction::START_RE return PullEvent.new( instruction:instruction, *Instruction.pull( @source )) when DocType::START_RE args = DocType.pull( @source ) if args.pop == ">" @document_status = after_doctype:after_doctype @source.read if @source.buffer.size==0 md = @source.match(/^\s*/um, true) else @document_status = in_doctype:in_doctype end return PullEvent.new( doctype:doctype, *args) else @document_status = after_doctype:after_doctype @source.read if @source.buffer.size==0 md = @source.match(/\s*/um, true) end end if document_status:document_status == in_doctype:in_doctype md = @source.match(/\s*(.*?)>/um) case md[1] when ElementDecl::START_RE raise ParseException.new( "Element declarations can only occur "+ "in the doctype declaration.") return PullEvent.new( elementdecl:elementdecl, "") when Entity::START_RE raise ParseException.new( "Entity declarations can only occur "+ "in the doctype declaration.") return PullEvent.new( entitydecl:entitydecl, "") when AttlistDecl::START_RE raise ParseException.new( "Attlist declarations can only occur "+ "in the doctype declaration.") return PullEvent.new( attlistdecl:attlistdecl, "") when NotationDecl::START_RE raise ParseException.new( "Notation declarations can only occur "+ "in the doctype declaration.") return PullEvent.new( notationdecl:notationdecl, "") when /^\s*]>/um @document_status = after_doctype:after_doctype @source.match( /^\s*/um, true ) end end if @source.buffer[0] == ?< if @source.buffer[1] == ?/ last_tag = @tags.pop md = @source.match( CLOSE_MATCH, true ) raise ParseException.new( "Missing end tag for #{last_tag} "+ "(got #{md[1]})", @source) unless last_tag == md[1] return PullEvent.new( end_element:end_element, last_tag ) elsif @source.buffer[1] == ?! md = @source.match(/\A(\s*[^>]*>)/um) #puts "SOURCE BUFFER = #{source.buffer}, #{source.buffer.size}" raise ParseException.new("Malformed node",@source) unless md case md[1] when CData::START_RE return PullEvent.new( cdata:cdata, CData.pull( @source )) when Comment::START_RE return PullEvent.new( comment:comment, Comment.pull( @source )) end elsif @source.buffer[1] == ?? return PullEvent.new( instruction:instruction, *Instruction.pull( @source )) else rv = Element.base_parser( @source ) if rv[1] @closed = rv[0] else @tags.push rv[0] end attrs = {} rv[2].each { |a,b,c| attrs[a] = c } return PullEvent.new( start_element:start_element, rv[0], attrs ) end else return PullEvent.new( text:text, Text.pull( @source )) end return PullEvent.new( dummy:dummy ) end