Ruby REXML XPath バグ

REXMLXPathを使ってみたが、今のところあまり使えない。作者いわく:

Some of the XPath functions are untested8. Any XPath functions that don't work are also bugs... please report them. If you send a unit test that illustrates the problem, I'll try to fix the problem within a couple of days (if I can) and send you a patch, personally.

あとで報告する。 未報告。 tracへのポストの方法がわからず、MLも動いていない模様。

require "rexml/document"  

doc = REXML::Document.new('<div><b>history</b><table><tr><td>hoge</td></tr></table></div>')
names = REXML::XPath.match(doc, '//b[text()="history"]/following-sibling::table/tr')

puts names
p names

期待される結果

<tr><td>hoge</td></tr>
[<tr> ... </>]

実際

[]

所感

作者も述べるとおり現時点ではREXMLのXPath処理系は信用ならない感じ。 descendant_or_selfなんか、FIXMEとか、何で動いてるか分からんから直してくれ的な事が書いてある。
hpricotも似たような感じ。 現時点でrubyではxpath使うな、てことか、残念
というか rubyスクレイピング云々してる人たちはxpathを使っていないのだろうか。普通にメソッドで辿ってるのか。

fix

ちゃんと全部直せればよいのだけど、すぐに分かった部分だけ:

$ diff /usr/lib/ruby/1.8/rexml/xpath_parser.rb.orig  /usr/lib/ruby/1.8/rexml/xpath_parser.rb
360c360
<             results += expr( path_stack.dclone, following_siblings )
---
>             results += following_siblings