$ ruby code1.rb
/usr/lib/ruby/site_ruby/rexml/document.rb:187:in `build': undefined
method `add_element' for nil:NilClass (NoMethodError)
from /usr/lib/ruby/site_ruby/rexml/document.rb:44:in `initialize'
from code1.rb:4:in `new'
from code1.rb:4
$ ruby code2.rb
/usr/lib/ruby/site_ruby/rexml/document.rb:187:in `build': undefined
method `add_element' for nil:NilClass (NoMethodError)
from /usr/lib/ruby/site_ruby/rexml/document.rb:44:in `initialize'
from code2.rb:21:in `new'
from code2.rb:21
However, code3.rb worked well.
···
On 11/14/05, James Britt <james_b@neurogami.com> wrote:
There a nice article by Koen Vervloesem about REXML up on the XML.com site:
$ ruby code1.rb
/usr/lib/ruby/site_ruby/rexml/document.rb:187:in `build': undefined
method `add_element' for nil:NilClass (NoMethodError)
from /usr/lib/ruby/site_ruby/rexml/document.rb:44:in `initialize'
from code1.rb:4:in `new'
from code1.rb:4
$ ruby code2.rb
/usr/lib/ruby/site_ruby/rexml/document.rb:187:in `build': undefined
method `add_element' for nil:NilClass (NoMethodError)
from /usr/lib/ruby/site_ruby/rexml/document.rb:44:in `initialize'
from code2.rb:21:in `new'
from code2.rb:21
The heredoc input string and two example files
(bibliography.xml and bibliography2.xml) contain:
<?xml version="1.0" encoding="ISO-8859-15"?>
causing REXML to barf. Changing to ISO-8859-1
(or removing) fixes. ISO-8859-15 is unsupported.
I should email Koen but maybe you're in contact, James :-?
No. I just happened to hear about the article and thought it worth a mention here. I skimmed it, but did not read through it, and have no contact with the author.
Thanks for testing and finding the bug! I'm not involved with the project but
did find this on the author's website:
"You can submit bug reports and feature requests, and view the list of known
bugs, at the REXML bug report page. Please do submit bug reports. If you really
want your bug fixed fast, include an runit or Test::Unit method (or methods)
that illustrates the problem. At the very least, send me some XML that REXML
doesn't process properly.
You don't have to send an entire test suite -- just the unit test methods. If
you don't send me a unit test, I'll have to write one myself, which will mean
that your bug will take longer to fix.
When submitting bug reports, please include the version of Ruby and of REXML
that you're using, and the operating system you're running on. Just run: ruby
-vrrexml/rexml -e 'p REXML::Version,PLATFORM' and paste the results in your bug
report."
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
D:/RUBY/lib/ruby/1.8/rexml/output.rb:17:
in `<<': undefined method `encode' for #<REXML::Output:0x4ed44f4> (NoMethodError)
from D:/RUBY/lib/ruby/1.8/rexml/xmldecl.rb:43:in `write'
from D:/RUBY/lib/ruby/1.8/rexml/document.rb:163:in `write'
from D:/RUBY/lib/ruby/1.8/rexml/document.rb:161:in `each'
from D:/RUBY/lib/ruby/1.8/rexml/document.rb:161:in `write'
from D:/RUBY/lib/ruby/1.8/rexml/node.rb:23:in `to_s'
from D:/ruby/DfB/ReXML/rbA163.TMP:14:in `puts'
from D:/ruby/DfB/ReXML/rbA163.TMP:14
"3.1.2.1"
ruby 1.8.2 (2004-12-25) [i386-mswin32]
<?xml version='1.0' encoding='ISO-8859-1'?>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
D:/RUBY/lib/ruby/1.8/rexml/output.rb:17:
in `<<': undefined method `encode' for #<REXML::Output:0x4ed44f4> (NoMethodError)
from D:/RUBY/lib/ruby/1.8/rexml/xmldecl.rb:43:in `write'
from D:/RUBY/lib/ruby/1.8/rexml/document.rb:163:in `write'
from D:/RUBY/lib/ruby/1.8/rexml/document.rb:161:in `each'
from D:/RUBY/lib/ruby/1.8/rexml/document.rb:161:in `write'
from D:/RUBY/lib/ruby/1.8/rexml/node.rb:23:in `to_s'
from D:/ruby/DfB/ReXML/rbA163.TMP:14:in `puts'
from D:/ruby/DfB/ReXML/rbA163.TMP:14
=end
daz
Hmm, now that you mention it... I have that problem with writing XML with
<?xml version="1.0" encoding="ISO-8859-15"?>
<Widget a_tribute='this is OK' and_so="is this" />
This example is the 'essence' of my single/double quoting issue of attributes, of course. Commenting in the 5 lines above will lead to doubly quoted attribute values.