rexml error - REXML::Validation

Discussion in 'Ruby' started by Daniel Berger, Oct 12, 2004.

  1. 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
    Daniel Berger, Oct 12, 2004
    #1
    1. Advertising

  2. 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
    why the lucky stiff, Oct 12, 2004
    #2
    1. Advertising

  3. 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
    Henrik Horneber, Oct 12, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lucas Tam
    Replies:
    2
    Views:
    1,088
    Lucas Tam
    Feb 26, 2004
  2. Damphyr
    Replies:
    2
    Views:
    128
    Damphyr
    Jul 16, 2003
  3. Daniel Carrera

    Error in REXML

    Daniel Carrera, Oct 27, 2003, in forum: Ruby
    Replies:
    2
    Views:
    85
    Daniel Carrera
    Oct 27, 2003
  4. Dmitri Borodaenko

    REXML error reporting (XHTML validation)

    Dmitri Borodaenko, Nov 8, 2004, in forum: Ruby
    Replies:
    7
    Views:
    148
    Dmitri Borodaenko
    Nov 11, 2004
  5. Phlip
    Replies:
    0
    Views:
    131
    Phlip
    Jan 15, 2008
Loading...

Share This Page