我试图运行flightxml2 ruby库来访问flightaware api。(图书馆代码在这里:https://github.com/flightaware/flightxml2-client-ruby
当使用“require'flightxml2.rb'行包含库文件时,发生以下异常:

LoadError: no such file to load -- xsd/qname
    from /...PATH TO GEMS.../activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
    from /...PATH TO GEMS.../activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `block in require'
    from /...PATH TO GEMS.../activesupport-3.2.9/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /...PATH TO GEMS.../activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
    from /...PATH TO GEMS.../lib/FlightXML2.rb:1:in `<top (required)>'
    from /...PATH TO GEMS.../activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
    from /...PATH TO GEMS.../activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `block in require'
    from /...PATH TO GEMS.../activesupport-3.2.9/lib/active_support/dependencies.rb:236:in `load_dependency'
    from /...PATH TO GEMS.../activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require'
    from (irb):2
    from /...PATH TO GEMS.../railties-3.2.9/lib/rails/commands/console.rb:47:in `start'
    from /...PATH TO GEMS.../railties-3.2.9/lib/rails/commands/console.rb:8:in `start'
    from /...PATH TO GEMS.../railties-3.2.9/lib/rails/commands.rb:41:in `<top (required)>'
    from script/rails:6:in `require'
    from script/rails:6:in `<main>'

我怀疑这与Ruby1.9和1.8之间的不兼容有关,而这个库是为Ruby1.9和1.8编写的。有没有办法用Ruby1.9来实现这一点?

最佳答案

为了让flightxml2在我的rails项目中运行,我必须安装'xmlparser'和'soap4r'gems,并添加以下gemfile:

gem 'xmlparser'
gem 'soap4r', :git => 'git://github.com/felipec/soap4r.git'

并添加以下兼容性创可贴:
require 'rexml/document'
require 'continuation'

class Symbol
  def sub(*args)
    to_s.sub(*args)
  end
end

关于ruby-on-rails - 如何修复Ruby“没有此类文件可加载-xsd/qname”错误?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13597351/

10-09 16:02