尝试用rexml来解析xml文档的时候出现问题:
undefined local variable or method 'transitive' in document.rb
于是乎查看rexml的document.rb文件,大概在182行附近有一个方法:
def write( output=$stdout, indent=-1, trans=false, ie_hack=false )
if xml_decl.encoding != "UTF-8" && !output.kind_of?(Output)
output = Output.new( output, xml_decl.encoding )
end
formatter = if indent > -1
if transitive
REXML::Formatters::Transitive.new( indent, ie_hack )
else
REXML::Formatters::Pretty.new( indent, ie_hack )
end
else
REXML::Formatters::Default.new( ie_hack )
end
formatter.write( self, output )
end
看到下面有一个if语句与方法后面的形参里面的trans不符合。。。原来是if语句后面的参数写错了,我说的呢,把
if transitive
修改为
if trans
OK,问题解决了,哎,可能ruby以后的版本会修复这个bug吧。。。。。。
呃……又发现了一个问题……
提示:private method `gsub' called for 6:Fixnum
看来gsub这个方法还不能支持数字为属性值的标签转换……打开rexml文件夹下面的text.rb,找到代码,大概在289行
def Text::normalize( input, doctype=nil, entity_filter=nil )
copy = input
# Doing it like this rather than in a loop improves the speed
#copy = copy.gsub( EREFERENCE, '&' )
copy = copy.gsub( "&", "&" )
............省略后面的
修改代码
copy=input
为
ruby = input.to_s
解决!
如果还有错误还得解决……rexml的作者可真粗心呀。。。。
分享到:
相关推荐
ruby1.8.6
Ruby1.8.6 One-Click Installer
ruby1.8.6 + rails2.0.2 + radrails0.7.2 + mysql 安装配置 详细说明
Ruby-doc is a project dedicated to creating and collecting documentation on Ruby. You can find collections of articles and other resources at the website. stdlib-doc is a RubyForge project that ...
ruby1.8.6 windows安装程序
ruby-1.8.6.zip
ruby 1.8.6官方chm文档,做为ruby开发者,这是必备文档.
Ruby 1.8.6 on Rails 2.1.0 Install.txtRuby 1.8.6 on Rails 2.1.0 Install.txt
Ruby1.8.6 One-Click Installer
Ruby1.8.6 One-Click Installer带SciTE
ruby-enterprise-1.8.6-20090201.tar for linux
好用的API chm格式 想要的就下载吧!!!!
Ruby on Rails安装,有人说难,但其实也很方便。要基于ruby开发应用程序,我们必须安装ruby、gem、rails、mongrel。
ruby-1.8.6.tar.bz2
ruby api ruby文档 英文 ruby开发必备
ruby-1.8.6-p114.tar.gz
脚本引擎内核源代码之Ruby-1.8.6.tar.gz。VC6编译通过
找了好久才找到的插件,希望大家能用的上,ruby逐渐走强,但资源始终不好找,希望能帮上您的忙.
ruby 1.8.6 api html格式
ruby方法chm文件、接口、方法描述,学习ruby必备的文件