Rexml xpath question

H

Han Holl

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,
 
S

Sean Russell

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
 
G

Gavin Sinclair

(e-mail address removed) (Han Holl) 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.


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
 
H

Han Holl

(e-mail address removed) (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
 
S

Sean Russell

Gavin Sinclair said:
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
 
S

Sean Russell

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
 
G

Gavin Sinclair

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

Han Holl

(e-mail address removed) (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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top