Rexml xpath question

Discussion in 'Ruby' started by Han Holl, Feb 22, 2004.

  1. Han Holl

    Han Holl Guest

    Hi,

    The following program:

    require 'rexml/document'
    require 'rexml/xpath'
    require 'pp'

    doc = REXML::Document.new('
    <program>
    <item rnum="1"/>
    <item rnum="1:abc"/>
    </program>')

    REXML::XPath.each(doc.root, '/program/item[@rnum="1"]') do |el|
    puts el
    end
    # end of example program

    produces:

    <item rnum='1'/>
    <item rnum='1:abc'/>

    Is this correct? I would have expected only the first item to be returned.

    Cheers,
    Han Holl, Feb 22, 2004
    #1
    1. Advertising

  2. Han Holl

    Sean Russell Guest

    (Han Holl) wrote in message news:<>...
    > Hi,
    >
    > The following program:

    ....
    > produces:
    >
    > <item rnum='1'/>
    > <item rnum='1:abc'/>
    >
    > Is this correct? I would have expected only the first item to be returned.


    Nope. That's a bug. Thanks for finding that; in the future, you
    might want to post the bug to the REXML bug page; I'm not reliable
    about reading this newsgroup.


    --- SER
    Sean Russell, Feb 23, 2004
    #2
    1. Advertising

  3. On Tuesday, February 24, 2004, 7:04:48 AM, Sean wrote:

    > (Han Holl) wrote in message
    > news:<>...
    >> Hi,
    >>
    >> The following program:

    > ....
    >> produces:
    >>
    >> <item rnum='1'/>
    >> <item rnum='1:abc'/>
    >>
    >> Is this correct? I would have expected only the first item to be returned.


    > Nope. That's a bug. Thanks for finding that; in the future, you
    > might want to post the bug to the REXML bug page; I'm not reliable
    > about reading this newsgroup.



    REXML is distributed with Ruby, so you'll never be able to prevent
    people from posting issues here, and nor should you. The only
    reasonable process that can mitigate your lack of full attention to
    this forum (which I'm not criticising) is to ask somebody else to keep
    an eye out for you.

    That, or set a mail/NG filter that copies messages matching /rexml/i to a
    separate folder :)

    Cheers,
    Gavin
    Gavin Sinclair, Feb 24, 2004
    #3
  4. Han Holl

    Han Holl Guest

    (Sean Russell) wrote in message

    > Nope. That's a bug. Thanks for finding that; in the future, you
    > might want to post the bug to the REXML bug page; I'm not reliable
    > about reading this newsgroup.
    >
    >
    > --- SER


    Now that REXML is included in Ruby, I think (possible) bugs are of
    interest to the readers of this list. I might try to crosspost in
    the future, because it's not possible for people interested in Ruby
    to follow all specialized mailing lists.

    The irony is that this bug is just the behaviour that I wanted!
    Now I'll have to find out how to use starts-with. I'm afraid I
    don't find XPath syntax to be very intuitive.

    Cheers,

    Han Holl
    Han Holl, Feb 24, 2004
    #4
  5. Han Holl

    Sean Russell Guest

    Gavin Sinclair <> wrote in message news:<>...
    > > Nope. That's a bug. Thanks for finding that; in the future, you
    > > might want to post the bug to the REXML bug page; I'm not reliable
    > > about reading this newsgroup.

    >
    >
    > REXML is distributed with Ruby, so you'll never be able to prevent
    > people from posting issues here, and nor should you. The only


    Oh, I couldn't prevent people from posting here. What I'm saying is
    that if you post your bug report to this newsgroup, it may be a long
    while before I see it, and it may get lost entirely.

    If someone wants to give me access to an NNTP server that carries this
    newsgroup, with posting permissions, my ability to scan for bug
    reports would improve. However, it is unlikely that anybody is going
    to be successful at forcing me to spend more time trolling the
    newsgroups for bug reports anytime soon.

    REXML, like most open source projects, has an official bug reporting
    mechanism. Bugs posted there have a much better chance of being
    addressed.

    > reasonable process that can mitigate your lack of full attention to
    > this forum (which I'm not criticising) is to ask somebody else to keep
    > an eye out for you.


    Are you volunteering? That is, after all, what Ruby (and REXML) is:
    volunteer work. Things would be different if I were being paid for
    this :)

    --- SER
    Sean Russell, Feb 25, 2004
    #5
  6. Han Holl

    Sean Russell Guest

    (Han Holl) wrote in message news:<>...
    > Now that REXML is included in Ruby, I think (possible) bugs are of
    > interest to the readers of this list. I might try to crosspost in


    Yeah, that's the downside to REXML in Ruby. There is a dedicated
    REXML mailing list, a dedicated bug tracking system, and a dedicated
    web page. There is a bunch of documentation that isn't included in
    the Ruby CVS system. I'm reluctant to cross-post from the REXML
    mailing list to the newsgroup simply because I think there's enough
    noise in the group as it is; that wouldn't solve the core problem that
    people using REXML these days may not even realize that there exists a
    separate forum for it.

    > The irony is that this bug is just the behaviour that I wanted!
    > Now I'll have to find out how to use starts-with. I'm afraid I
    > don't find XPath syntax to be very intuitive.


    Yeah, XPath can be tricky, but it is pretty simple once you get the
    hang of it, until you start doing complex filtering.

    You had it almost right, though:

    /program/item[ starts-with( @rnum ) = "1"]

    --- SER
    Sean Russell, Feb 25, 2004
    #6
  7. On Thursday, February 26, 2004, 12:29:51 AM, Sean wrote:

    > REXML, like most open source projects, has an official bug reporting
    > mechanism. Bugs posted there have a much better chance of being
    > addressed.


    Good point.

    >> reasonable process that can mitigate your lack of full attention to
    >> this forum (which I'm not criticising) is to ask somebody else to keep
    >> an eye out for you.


    > Are you volunteering? That is, after all, what Ruby (and REXML) is:
    > volunteer work. Things would be different if I were being paid for
    > this :)


    What about my other suggestion: create a mail folder that collects
    only messages with /rexml/i in them?

    Cheers,
    Gavin
    Gavin Sinclair, Feb 28, 2004
    #7
  8. Han Holl

    Han Holl Guest

    (Sean Russell) wrote in message >
    > You had it almost right, though:
    >
    > /program/item[ starts-with( @rnum ) = "1"]
    >

    You _also_ had it almost right <g>:
    /program/item[ starts-with( @rnum, "1")]

    Cheers,

    Han Holl
    Han Holl, Mar 6, 2004
    #8
    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. Damphyr
    Replies:
    2
    Views:
    132
    Damphyr
    Jul 16, 2003
  2. Alexey Verkhovsky
    Replies:
    0
    Views:
    169
    Alexey Verkhovsky
    Aug 3, 2004
  3. Daniel Berger

    rexml error - REXML::Validation

    Daniel Berger, Oct 12, 2004, in forum: Ruby
    Replies:
    2
    Views:
    145
    Henrik Horneber
    Oct 12, 2004
  4. Ja Ha

    REXML XPath question

    Ja Ha, Jun 25, 2007, in forum: Ruby
    Replies:
    2
    Views:
    97
    Ja Ha
    Jun 25, 2007
  5. Phlip
    Replies:
    0
    Views:
    135
    Phlip
    Jan 15, 2008
Loading...

Share This Page