Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > rexml error - REXML::Validation

Reply
Thread Tools

rexml error - REXML::Validation

 
 
Daniel Berger
Guest
Posts: n/a
 
      10-12-2004
Hi all,

>ruby -v

ruby 1.8.2 (2004-10-11) [sparc-solaris2.9]

This bit of code, that seemed to work fine on 1.8.1, is now choking:

require "rexml/document"
include REXML

file = "some_file"
database = "foo"

doc = Document.new(File.new(file))
ary = doc.elements.to_a("//name[text()='#{database}']")
parent = ary[0].parent

Running this bit of code, I get:

opt/lib/ruby/site_ruby/1.8/rexml/parsers/treeparser.rb:80:in `parse':
uninitialized constant REXML::Validation (NameError)
from /opt/lib/ruby/site_ruby/1.8/rexml/document.rb:175:in
`build'
from /opt/lib/ruby/site_ruby/1.8/rexml/document.rb:45:in
`initialize'
from rexmltest.rb:7:in `new'
from rexmltest.rb:7

I tried installing rexml 3.1.1 from the RAA but I get the same error.
Actual XML is as follows:
<dbrc>
<database>
<name>foo</name>
<user>user1</user>
<password>pwd1</password>
<driver>Oracle</driver>
<interval>60</interval>
<timeout>40</timeout>
<max_reconn>3</max_reconn>
</database>
<database>
<name>foo</name>
<user>user2</user>
<password>pwd2</password>
<driver>OCI8</driver>
<interval>60</interval>
<timeout>60</timeout>
<max_reconn>4</max_reconn>
</database>
<database>
<name>bar</name>
<user>user1</user>
<password>pwd3</password>
<driver>Oracle</driver>
<interval>30</interval>
<timeout>30</timeout>
<max_reconn>2</max_reconn>
</database>
<database>
<name>baz</name>
<user>user3</user.
<password>pwd4</password>
</database>
</dbrc>


Any ideas?

Regards,

Dan
 
Reply With Quote
 
 
 
 
why the lucky stiff
Guest
Posts: n/a
 
      10-12-2004
Daniel Berger wrote:

> ruby 1.8.2 (2004-10-11) [sparc-solaris2.9]
>
>[...]
>
>opt/lib/ruby/site_ruby/1.8/rexml/parsers/treeparser.rb:80:in `parse':
>uninitialized constant REXML::Validation (NameError)
>
>

Refresh your CVS checkout with `cvs update -d'. Rebuild and you'll be
extra-fine.

_why


 
Reply With Quote
 
 
 
 
Henrik Horneber
Guest
Posts: n/a
 
      10-12-2004
Daniel Berger wrote:
> Hi all,
>
>
>>ruby -v

>
> ruby 1.8.2 (2004-10-11) [sparc-solaris2.9]
>
> This bit of code, that seemed to work fine on 1.8.1, is now choking:
>
> require "rexml/document"
> include REXML
>
> file = "some_file"
> database = "foo"
>
> doc = Document.new(File.new(file))
> ary = doc.elements.to_a("//name[text()='#{database}']")

ary = doc.elements["//name[text()='#{database}']"] # does not make a
difference, but I like it better
> parent = ary[0].parent
>
> Running this bit of code, I get:
>
> opt/lib/ruby/site_ruby/1.8/rexml/parsers/treeparser.rb:80:in `parse':
> uninitialized constant REXML::Validation (NameError)
> from /opt/lib/ruby/site_ruby/1.8/rexml/document.rb:175:in
> `build'
> from /opt/lib/ruby/site_ruby/1.8/rexml/document.rb:45:in
> `initialize'
> from rexmltest.rb:7:in `new'
> from rexmltest.rb:7
>
> I tried installing rexml 3.1.1 from the RAA but I get the same error.
> Actual XML is as follows:
> <dbrc>
> <database>
> <name>foo</name>
> <user>user1</user>
> <password>pwd1</password>
> <driver>Oracle</driver>
> <interval>60</interval>
> <timeout>40</timeout>
> <max_reconn>3</max_reconn>
> </database>
> <database>
> <name>foo</name>
> <user>user2</user>
> <password>pwd2</password>
> <driver>OCI8</driver>
> <interval>60</interval>
> <timeout>60</timeout>
> <max_reconn>4</max_reconn>
> </database>
> <database>
> <name>bar</name>
> <user>user1</user>
> <password>pwd3</password>
> <driver>Oracle</driver>
> <interval>30</interval>
> <timeout>30</timeout>
> <max_reconn>2</max_reconn>
> </database>
> <database>
> <name>baz</name>
> <user>user3</user.

^^^^
> <password>pwd4</password>
> </database>
> </dbrc>
>
>
> Any ideas?



hope that helps.

After fixing the </user> typo the script runs without errors, even with
your original line.

C:\>ruby -v
ruby 1.8.2 (2004-07-16) [i386-mswin32]


Henrik



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
REXML::Element.write is deprecated. See REXML::Formatters Phlip Ruby 0 01-15-2008 08:23 PM
ruby - rexml/streamlistner - error: uninitialized constant jsp408@comcast.net Ruby 2 06-15-2006 11:30 AM
REXML error reporting (XHTML validation) Dmitri Borodaenko Ruby 7 11-11-2004 03:50 PM
Error in REXML Daniel Carrera Ruby 2 10-27-2003 11:41 PM
soap4r 1.4.8.1 with REXML 2.7.1 - no REXML::VERSION_MAJOR Damphyr Ruby 2 07-16-2003 09:49 AM



Advertisments