REXML code no longer works

Ok,
So I have a program that uses REXML. It works. I have working code.
But I think something in rexml changed and now my code is broken.
Either that or my code is broken in such a way that I cannot figure out
the problem.

What I’m doing is storing xml files then loading the data into an
object. The code is equivalent to this.

require 'rexml/document’
include REXML

cfg = File.new( “configfile.xml” )
config = Document.new( cfg )
myObj = myObject.new( config.elements[ “//idtag” ] )

If I try just doing

print config.elements[ “//idtag” ]

I get the same error. so it must be caused by something in the Document
object, maybe its not being made right? Here is the backtrace.

/usr/lib/ruby/site_ruby/rexml/xpath_parser.rb:75:in internal_parse': undefined methodnode_type’ for #REXML::Element:0x40425edc
(NoMethodError)
from /usr/lib/ruby/site_ruby/rexml/xpath_parser.rb:73:in
delete_if' from /usr/lib/ruby/site_ruby/rexml/xpath_parser.rb:73:ininternal_parse’
from /usr/lib/ruby/site_ruby/rexml/xpath_parser.rb:51:in match' from /usr/lib/ruby/site_ruby/rexml/xpath_parser.rb:303:ind_o_s’
from /usr/lib/ruby/site_ruby/rexml/xpath_parser.rb:301:in
each_index' from /usr/lib/ruby/site_ruby/rexml/xpath_parser.rb:301:ind_o_s’
from /usr/lib/ruby/site_ruby/rexml/xpath_parser.rb:294:in
descendant_or_self' from /usr/lib/ruby/site_ruby/rexml/xpath_parser.rb:220:ininternal_parse’
from /usr/lib/ruby/site_ruby/rexml/xpath_parser.rb:51:in match' from /usr/lib/ruby/site_ruby/rexml/xpath_parser.rb:34:inparse’
from /usr/lib/ruby/site_ruby/rexml/xpath.rb:28:in first' from /usr/lib/ruby/site_ruby/1.8/rexml/element.rb:844:in[]’

It says that node_type is undefined. However, if I look in
/usr/lib/ruby/site_ruby/rexml/element.rb I can plainly see that
node_type is indeed defined. I triple checked the XML to make sure it
was valid. And no matter which xpath I use it still breaks. Ideas anyone?

-Scott

Scott Rubin srubin@fsisys.com wrote in message news:40A0F1D7.9010604@fsisys.com

So I have a program that uses REXML. It works. I have working code.
But I think something in rexml changed and now my code is broken.
Either that or my code is broken in such a way that I cannot figure out
the problem.

Yikes! This is not good. Can you tell me which version you WERE
using that worked, and which version that you’re NOW using that
doesn’t?

I’ll check this out soon.

— SER

Scott,

This is bug #25, and you can track it at the REXML bug tracking page:

http://www.germane-software.com/cgi-bin/roundup/rexml

— SER

Scott Rubin srubin@fsisys.com wrote in message news:40A0F1D7.9010604@fsisys.com

Ok,
So I have a program that uses REXML. It works. I have working code.
But I think something in rexml changed and now my code is broken.
Either that or my code is broken in such a way that I cannot figure out
the problem.

I’ve applied Kou’s patch, since it is as good as any.

FYI, the constructor that takes a Source as an argument has been
deprecated, and is no longer supported. This was not documented, so
my bad. Kou’s patch will get your code working, but I’m not going to
extend it to make it more complete.

Please do not use the constructor this way any longer. If you
absolutely need to parse a doctype out of an XML document, use:

d = Document.new( source )
doctype = d.doctype

rather than:

doctype = DocType.new( source )

This backwards-compatability patch will be in Ruby CVS by the end of
day, and will be in REXML 3.0.7.

Thanks.

— SER