chillibear.com

Ruby xml-mapping: `write': undefined local variable or method `output'

I’ve been working with the XML-Mapping gem and had the following error when trying to generate XML:

/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/rexml/element.rb:685:in `write': undefined local variable or method `output' for <xml_node> ... </>:REXML::Element (NameError)

A bit of digging lead me to this bug report, which lead me to look properly at the code and sure enough correcting the code (line 674) corrects the bug and I can generate XML. i.e. changing

def write(writer=$stdout, indent=-1, transitive=false, ie_hack=false)

to

def write(output=$stdout, indent=-1, transitive=false, ie_hack=false)

Note that writer has now become output. Now since that whole function in REXML is depreciated anyway I should probably modify the XML-Mapping code to use the more modern REXML::Formatters, but this sorted the immediate problem.

Written on 25 Jul 2010 and categorised in NIX and Ruby, tagged as Gem, xml, and REXML

Home, Post archive

site copyright Eric Freeman

Valid XHTML 1.0 Strict