Forum: Ruby REXML article on XML.com

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
james_b (Guest)
on 2005-11-14 17:02
(Received via mailing list)
There a nice article by Koen Vervloesem about REXML up on the XML.com
site:

http://www.xml.com/pub/a/2005/11/09/rexml-processi...

James B.


--

http://www.ruby-doc.org       - Ruby Help & Documentation
http://www.artima.com/rubycs/ - Ruby Code & Style: Writers wanted
http://www.rubystuff.com      - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com     - Playing with Better Toys
http://www.30secondrule.com   - Building Better Tools
nohmad (Guest)
on 2005-11-14 20:17
(Received via mailing list)
On 11/14/05, James B. <removed_email_address@domain.invalid> wrote:
> http://www.artima.com/rubycs/ - Ruby Code & Style: Writers wanted
> http://www.rubystuff.com      - The Ruby Store for Ruby Stuff
> http://www.jamesbritt.com     - Playing with Better Toys
> http://www.30secondrule.com   - Building Better Tools
>
>

I'm afraid it's not proper reporting here.

$ 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.
nohmad (Guest)
on 2005-11-14 20:39
(Received via mailing list)
On 11/15/05, Gyoung-Yoon N. <removed_email_address@domain.invalid> wrote:
> > http://www.ruby-doc.org       - Ruby Help & Documentation
> /usr/lib/ruby/site_ruby/rexml/document.rb:187:in `build': undefined
>         from code2.rb:21
>
>
> However, code3.rb worked well.
>
> --
> http://nohmad.sub-port.net
>
>

REXML could not parse DTD.
I could not even run examples including DTD from REXML tutorial page.[1]

Any thought?

[1]: http://www.germane-software.com/software/rexml/doc...
dooby (Guest)
on 2005-11-14 21:20
(Received via mailing list)
James B. wrote:
> There a nice article by Koen Vervloesem about REXML up on the XML.com site:
>
> 
http://www.xml.com/pub/a/2005/11/09/rexml-processi...
>


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 :-?


daz
james_b (Guest)
on 2005-11-14 22:20
(Received via mailing list)
daz wrote:
...
> 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.

But I posted a quick comment on the site.

James

--

http://www.ruby-doc.org       - Ruby Help & Documentation
http://www.artima.com/rubycs/ - Ruby Code & Style: Writers wanted
http://www.rubystuff.com      - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com     - Playing with Better Toys
http://www.30secondrule.com   - Building Better Tools
kevin (Guest)
on 2005-11-14 22:29
(Received via mailing list)
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."
dooby (Guest)
on 2005-11-14 22:50
(Received via mailing list)
James B. wrote:
>
> But I posted a quick comment on the site.
>

Splendid idea!  One of those interactive doo-dahs.
Wish I'd written in English, now.
Barf must be a word I picked up here :)

Thanks,

daz
dooby (Guest)
on 2005-11-14 22:53
(Received via mailing list)
Kevin B. wrote:
>
> Thanks for testing and finding the bug!

It's not a REXML bug - it's an unsupported encoding.

Thanks, any way.

daz
Stephan.Kaemper (Guest)
on 2005-11-14 23:05
(Received via mailing list)
daz wrote:
>
Unsupported? But there's

/ruby/lib/ruby/1.8/rexml/encodings/ISO-8859-15.rb

in my Ruby installation (One-Click-Installer 1.8.2-15 Stable Release).

And over here XML starting with

<?xml version="1.0" encoding="ISO-8859-15"?>

gets read without any hassle. Did I miss something?


Happy rubying

Stephan
dooby (Guest)
on 2005-11-15 00:50
(Received via mailing list)
Stephan Kämper wrote:
> daz wrote:
> >
> > It's not a REXML bug - it's an unsupported encoding.
> >
>
> Unsupported?

Sorry, I was misled by the tutorial page:

 "... other encodings (UTF-8, UTF-16, ISO-8859-1, and UNILE
  are all supported, input and output) ..."


> But there's
> /ruby/lib/ruby/1.8/rexml/encodings/ISO-8859-15.rb
> in my Ruby installation (One-Click-Installer 1.8.2-15 Stable Release).


I have that file on that path and I used 1.8.2-15 also.


>
> And over here XML starting with
> <?xml version="1.0" encoding="ISO-8859-15"?>
> gets read without any hassle. Did I miss something?
>

Now you say so, I think I should get that, too.


p $:.any? {|d| File.exist?(File.join(d,
'rexml/encodings/ISO-8859-15.rb'))}
#-> true

require 'rexml/document'
p REXML::Version
puts 'ruby %s (%s) [%s]' % [RUBY_VERSION, RUBY_RELEASE_DATE,
RUBY_PLATFORM]

string = '<?xml version="1.0" encoding="ISO-8859-1"?>'
doc = REXML::Document.new(string)
puts doc
puts '~'*40
string = '<?xml version="1.0" encoding="ISO-8859-15"?>'
doc = REXML::Document.new(string)
puts doc

=begin

"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
Stephan.Kaemper (Guest)
on 2005-11-15 03:33
(Received via mailing list)
daz wrote:
> #-> true
> doc = REXML::Document.new(string)
>     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

     encoding="ISO-8859-15"

too. But then I can output XML using this:



require 'rexml/document'

# REXML::Attribute.class_eval( %q^
#   def to_string
#     %Q[#@expanded_name="#{to_s().gsub(/"/, '&quot;')}"]
#   end
# ^ )

fn = 'sample.xml'
doc = REXML::Document.new( File.open( fn ) )

puts doc.xml_decl.to_s
puts doc.root


sample.xml is:

<?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.



Happy rubying

Stephan
This topic is locked and can not be replied to.