REXML translate (XPath?)

Can somebody explain or put me to an explanation of how to use
REXML::Functions::translate ?

I'd like to turn this: group_list.elements["entry[title='#{name}']"]

. . . into a case insensitive lookup. Do I put the translation into
the XPath in that line? Do I need a separate translation line?

Thanks,
Andrew

This would be the correct XPath:

group_list.elements["entry[translate(title,
'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'abcdefghijklmnopqrstuvwxyz')='#{name.downcase}']"]

but I don't know if REXML can handle it, because it's not fully XPath
compliant. I'd use an XPath-compliant parser like Nokogiri if this is
an issue.

-- Mark.

···

On Feb 11, 7:42 pm, "Andrew C." <andrew.c...@gmail.com> wrote:

Can somebody explain or put me to an explanation of how to use
REXML::Functions::translate ?

I'd like to turn this: group_list.elements["entry[title='#{name}']"]

. . . into a case insensitive lookup. Do I put the translation into
the XPath in that line? Do I need a separate translation line?

Thanks,
Andrew

That appears to work for REXML. Thanks Mark.

···

On Feb 12, 12:12 pm, Mark Thomas <m...@thomaszone.com> wrote:

On Feb 11, 7:42 pm, "Andrew C." <andrew.c...@gmail.com> wrote:

> Can somebody explain or put me to an explanation of how to use
> REXML::Functions::translate ?

> I'd like to turn this: group_list.elements["entry[title='#{name}']"]

> . . . into a case insensitive lookup. Do I put the translation into
> the XPath in that line? Do I need a separate translation line?

> Thanks,
> Andrew

This would be the correct XPath:

group_list.elements["entry[translate(title,
'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
'abcdefghijklmnopqrstuvwxyz')='#{name.downcase}']"]

but I don't know if REXML can handle it, because it's not fully XPath
compliant. I'd use an XPath-compliant parser like Nokogiri if this is
an issue.

-- Mark.