[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Case insensitive search



Am Wednesday 06 June 2001 10:02 am schrieb Conny Krappatsch:
> On Tuesday 05 June 2001 19:55, Lars Martin wrote:
> > On Fri, 1 Jun 2001 19:09:31 +0530
> >
> > "Shekhar" <2kshekhar@sun20.datamatics.com> wrote:
> > > Hi
> > >
> > > How can I do a case insensitive search on the contents of a Text Node
> > > using OzoneXpathQuery?
> >
> > Hi.
> > AFAIK, XPath doesn't support case insensitive queries and with this
> > Ozone doesn't support case insensitive queries because Ozone simply
> > executes XPath on persistent DOM instead of in-memory DOM.
>
> There's one way, but it's very ugly.
>
> You can use the 'translate' function (part of XPath) to convert both
> strings to upper case (or lower case if you like it more).
>
> A case insensitive string comparison would look like this:
>
> translate(string1,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ"
>)=translate(string2,"abcdefghijklmnopqrstuvwxyz","ABCDEFGHIJKLMNOPQRSTUVWXYZ
>")
>
> (hope I didn't miss a letter. double check if you're going to use it.)
>
> This results in true if string1 and string2 are equal ignoring case.
> What did I say - UGLY.

In theory Xalan provides the possiblity to write own XPath functions. So, you 
could write a case-insensitive compare function. This would be proprietary, 
but faster than the translate version.

Best Regards,
Gerd



-- 
______________________________________________________________________
Gerd Mueller                                   mailto:gerd@smb-tec.com
SMB GmbH                                        http://www.smb-tec.com