Hi,
I have got an error around REXML.
I think there is a bug in REXML::Doctype#write().
Sample program :
···
require ‘rexml/document’
XML Document and Declaration
document = REXML::Document.new
xmldecl = REXML::XMLDecl.new(“1.0”, “UTF-8”)
document.add(xmldecl)
XML Doctype
str = ''
source = REXML::Source.new(str)
doctype = REXML::DocType.new(source)
document.add(doctype)
Element
element = REXML::Element.new(“hoge”)
document.add(element)
print
document.write
Result :
$ ruby -v
ruby 1.8.1 (2004-01-01) [i686-linux-gnu]
$ ruby hoge.rb
/usr/lib/ruby/1.8/rexml/doctype.rb:111:in write': undefined method
empty?’ for
nil:NilClass (NoMethodError)
from /usr/lib/ruby/1.8/rexml/document.rb:159:in write' from /usr/lib/ruby/1.8/rexml/document.rb:157:in
each’
from /usr/lib/ruby/1.8/rexml/document.rb:157:in `write’
from hoge.rb:21
<?xml version='1.0' encoding='UTF-8'?><!DOCTYPE
I read source codes of REXML and found that ‘parent.rb’ and
’doctype.rb’ are not matched about ‘@children ’.
rexml/parent.rb :
module REXML
class Parent < Child
…
def initalize parent=nil
super(parent)
@children = [] ## expected to be not nil
end
…
end
end
rexml/doctype.rb :
module REXML
class DocType < Parent
def initialize( first, parent=nil )
…
super( parent ) ## set @children to nil
@name = first.name
@external_id = first.external_id
…
end
…
def write( output, indent=0, transitive=false, ie_hack=false )
…
unless @children.empty ? ## ERROR!
…
end
…
end
end
end
Could you help me?
–
regards,
kwa
SER1
(SER)
6 May 2004 11:44
2
Makoto Kuwata kwa@kuwata-lab.com wrote in message news:A5C432FD7549CFkwa@kuwata-lab.com …
I have got an error around REXML.
I think there is a bug in REXML::Doctype#write().
I’ll check it out, but I probably won’t be able to get to it until tomorrow.
Would you please post the output from:
ruby -rrexml/rexml -ve 'puts REXML::Version'
Thanks.
— SER
SER1
(SER)
6 May 2004 13:29
3
Makoto Kuwata kwa@kuwata-lab.com wrote in message news:A5C432FD7549CFkwa@kuwata-lab.com …
I have got an error around REXML.
I think there is a bug in REXML::Doctype#write().
Yes, this was a bug in Doctype; it should be fixed in the current
release of REXML, as well as in CVS; in fact, it has been fixed for a
couple of months – I believe ti got fixed in version 3.0.2, so I’m
curious which version of REXML and Ruby you’re running.
— SER
Sorry for late reply.
Here is the result:
$ ruby -rrexml/rexml -ve ‘puts REXML::Version’
ruby 1.8.1 (2004-01-01) [i686-linux-gnu]
2.7.3
I think it is a version which is bundled with Ruby1.8.1.
And I download and installed REXML 3.0.4, but I got the
same error at the same position.
···
===================================================================
$ ruby -rrexml/rexml -ve ‘puts REXML::Version’
ruby 1.8.1 (2004-01-01) [i686-linux-gnu]
3.0.4
$ ruby hoge.rb
/usr/lib/ruby/site_ruby/1.8/rexml/doctype.rb:114:in write': undefined method
e
mpty?’ for nil:NilClass (NoMethodError)
from /usr/lib/ruby/site_ruby/1.8/rexml/document.rb:162:in write' from /usr/lib/ruby/site_ruby/1.8/rexml/document.rb:160:in
each’
from /usr/lib/ruby/site_ruby/1.8/rexml/document.rb:160:in `write’
from hoge.rb:21
<?xml version='1.0' encoding='UTF-8'?><!DOCTYPE
===================================================================
See the previous mail I send for details of the test script.
–
regards,
kwa
Sean Russell wrote:
Makoto Kuwata kwa@kuwata-lab.com wrote in message news:<
A5C432FD7549CFkwa@kuwata-lab.com >…
I have got an error around REXML.
I think there is a bug in REXML::Doctype#write().
Yes, this was a bug in Doctype; it should be fixed in the current
release of REXML, as well as in CVS; in fact, it has been fixed for a
couple of months – I believe ti got fixed in version 3.0.2, so I’m
curious which version of REXML and Ruby you’re running.
— SER
Hi,
In 83173408.0405060527.109872e6@posting.google.com
“Re: REXML bug?” on Thu, 6 May 2004 22:29:09 +0900,
···
ser@germane-software.com (Sean Russell) wrote:
Yes, this was a bug in Doctype; it should be fixed in the current
release of REXML, as well as in CVS; in fact, it has been fixed for a
couple of months – I believe ti got fixed in version 3.0.2, so I’m
It seems to be not fixed. REXML::Docutype#initialize doesn’t
call super' when
first’ is REXML::Source.
I attach a patch for the bug, but I don’t like this
solution. I hope SER supply more flexible solution.
–
kou
Index: lib/rexml/doctype.rb
RCS file: /src/ruby/lib/rexml/doctype.rb,v
retrieving revision 1.5
diff -u -p -b -r1.5 doctype.rb
— lib/rexml/doctype.rb 28 Mar 2004 22:36:15 -0000 1.5
+++ lib/rexml/doctype.rb 7 May 2004 13:23:53 -0000
@@ -54,6 +54,15 @@ module REXML
@external_id = first[1]
@long_name = first[2]
@uri = first[3]
elsif first.kind_of? Source
super()
parser = Parsers::BaseParser.new( first )
event = parser.pull
if event[0] == :start_doctype
@name, @external_id, @long_name, @uri, = event[1..-1]
end
else
super()
end
end
SER1
(SER)
12 May 2004 22:13
6
Kouhei Sutou kou@cozmixng.org wrote in message news:20040507.223859.20029445.kou@cozmixng.org …
It seems to be not fixed. REXML::Docutype#initialize doesn’t
call super' when
first’ is REXML::Source.
Yeah, I haven’t had time to work in it. I got married this weekend
instead of working on Ruby projects. Diversity is always good.
I’ll get a fix in shortly. Sorry for the delay.
— SER
SER1
(SER)
16 May 2004 17:33
8
Makoto Kuwata kwa@kuwata-lab.com wrote in message news:ABC4394416FFBCkwa@kuwata-lab.com …
Sean Russell wrote:
I got married this weekend
Congratulations!
Thanks!
— SER