From: "akira yamada / やまだあきら" Date: 2007-10-24T12:46:08+09:00 Subject: [ruby-dev:32141] REXML::Document#write: undefined local variable or method `transitive' trunkのREXMLが元だと思うのですけど REXML::Document.new("").each_child{|e| e.write($stdout,1,true,true) などで例外が上がります。 どこでrequireするといいのか分かりませんが とりあえずこんなんで回避できそうです。 Index: lib/rexml/document.rb =================================================================== --- lib/rexml/document.rb (revision 13760) +++ lib/rexml/document.rb (working copy) @@ -184,7 +184,8 @@ output = Output.new( output, xml_decl.encoding ) end formatter = if indent > -1 - if trans + if transitive + require "rexml/formatters/transitive" REXML::Formatters::Transitive.new( indent, ie_hack ) else REXML::Formatters::Pretty.new( indent, ie_hack ) Index: lib/rexml/element.rb =================================================================== --- lib/rexml/element.rb (revision 13760) +++ lib/rexml/element.rb (working copy) @@ -671,10 +671,11 @@ # out = '' # doc.write( out ) #-> doc is written to the string 'out' # doc.write( $stdout ) #-> doc written to the console - def write(writer=$stdout, indent=-1, transitive=false, ie_hack=false) + def write(output=$stdout, indent=-1, transitive=false, ie_hack=false) Kernel.warn("#{self.class.name}.write is deprecated. See REXML::Formatters") formatter = if indent > -1 if transitive + require "rexml/formatters/transitive" REXML::Formatters::Transitive.new( indent, ie_hack ) else REXML::Formatters::Pretty.new( indent, ie_hack ) Index: lib/rexml/formatters/transitive.rb =================================================================== --- lib/rexml/formatters/transitive.rb (revision 13760) +++ lib/rexml/formatters/transitive.rb (working copy) @@ -12,9 +12,10 @@ # formatted. Since this formatter does not alter whitespace nodes, the # results of formatting already formatted XML will be odd. class Transitive < Default - def initialize( indentation=2 ) + def initialize( indentation=2, ie_hack=false ) @indentation = indentation @level = 0 + @ie_hack = ie_hack end protected @@ -29,6 +30,7 @@ output << "\n" output << ' '*@level if node.children.empty? + output << " " if @ie_hack output << "/" else output << ">"