Projects
Home     Blog     Install     New Ticket     View Tickets     Browse Source

Ticket #108 (new defect)

Opened 4 months ago

Last modified 3 months ago

Exception parsing XML file using REXML

Reported by: jon.lipsky@… Owned by: lsansonetti@…
Priority: blocker Milestone: MacRuby 0.4
Component: MacRuby Keywords:
Cc:

Description

Hi,

I am getting a "Can't modify immutable string" exception when trying to parse an XML document using the streaming parser included with REXML. I have created a sample script and sample XML file to reproduce the problem:

require "rexml/document"
require "rexml/streamlistener"

include REXML

class Reader
  include StreamListener

  def tag_start(a_name, a_attributes)    
      puts(a_name + " - " + a_attributes.to_s)
  end  
end

reader = Reader.new 
file = File.open("test.xml",File::RDONLY)
Document.parse_stream(file, reader)
<?xml version="1.0" encoding="UTF-8"?>
<test>

</test>

Here is the stack trace that is generated:

/Library/Frameworks/MacRuby.framework/Versions/0.3/usr/lib/ruby/1.9.0/rexml/parsers/baseparser.rb:260:in `force_encoding': can't modify immutable string (RuntimeError)
        from /Library/Frameworks/MacRuby.framework/Versions/0.3/usr/lib/ruby/1.9.0/rexml/parsers/baseparser.rb:260:in `pull'
        from /Library/Frameworks/MacRuby.framework/Versions/0.3/usr/lib/ruby/1.9.0/rexml/parsers/streamparser.rb:16:in `parse'
        from /Library/Frameworks/MacRuby.framework/Versions/0.3/usr/lib/ruby/1.9.0/rexml/document.rb:200:in `parse_stream'
        from /Development/personal/ruby/rbface/src/rb/rexml_test.rb:16:in `<main>'

Thanks and best regards, Jon...

Change History

Changed 3 months ago by lsansonetti@…

  • milestone set to MacRuby 0.4
Note: See TracTickets for help on using tickets.