It doesn't have to be stored in lower-case.   What you do is to translate
your search criteria to upper-case or lower and translate the xpath
response to upper-case or lower.   The "translate" function is something
that XPath understands.   If you embed the translate function in your XPath
query, XPath will, on-the-fly evaluate and replace whatever you are translating
with the translated version.   For instance, in my searches, I am passed a 
string

I wrap the string in a translate.   I make a call to the "text()" function in
XPath,
I wrap that in a translate.   Since both my query string and each call to text()
is wrapped in the same translate, if XPath finds a match it returns it.   I 
think
your
query should look something like:

xpath =
"//person[translate(FirstName,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')=

                           translate('John'
,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz') and

translate(City,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')=
                           translate('London'
,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')]";

This should probably work.  My advice would be to start small and build up from
there.

I would try and write this as:

xpath =
"//person/FirstName[translate(text(),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')=

                           translate('John'
,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')] and

//person/City[translate(text(),'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')=

                           translate('London'
,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')] ";

Try some simple case-insensitive searches and then build more complicated ones.

HTH,

Mark

White Shadow wrote:

> So does this means that for your example, the data should also have been
> saved in lowercase in the database? Otherwise there won't be any positive
> comparison result.
>
> Secondly: My xpath string is formed on runtime...selecting only those nodes
> for whcih the user has given some value in the submission form e.g.
>
> xpath = "//person[FirstName='John' and City='London']";
> where FirstName and city are nodes of XML file.
> How can I incorporate the translate function idea in this case?
>
> Will be thankful for your help.
>
> >From: Robin Schoeninger <[EMAIL PROTECTED]>
> >Reply-To: xindice-users@xml.apache.org
> >To: "'xindice-users@xml.apache.org'" <xindice-users@xml.apache.org>
> >Subject: RE: xpath query - ignore case sensitive
> >Date: Tue, 07 May 2002 09:45:56 -0700
> >
> >Xpath is not case sensitive - you have to use the translate function. It is
> >a kludgy fix, but it is the only one. It translates your search term to
> >lower case letters and the node to lower case letters, then it compares.
> >Have fun.
> >
> >example:
> >//dataset[contains(translate(title,'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijk
> >lmnopqrstuvwxyz'),
> >translate('soil','ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz'))
> >]
> >
> >Hope this helps,
> >
> >Robin Schoeninger
> >
> >
> >
> >
> >Robin T. Schoeninger
> >Center For Environmental Studies
> >Arizona State University
> >480-727-7290
> >[EMAIL PROTECTED]
> >
> >
> >
> >
> >
> >-----Original Message-----
> >From: White Shadow [mailto:[EMAIL PROTECTED]
> >Sent: Tuesday, May 07, 2002 8:52 AM
> >To: xindice-users@xml.apache.org
> >Subject: Re: xpath query - ignore case sensitive
> >
> >
> >Hello All
> >A few week ago I asked a question relating to this topic....A friend at the
> >forum gave his help but I could not get it right.
> >I have a form that is filled for first name, last name, address, etc.
> >If I fill the name John (with capital J) and then query the collection for
> >john (with small j), I should get this result but am not getting it, as
> >xpath is distinguishing between small and capital letters.
> >The XPath string is as follow:
> >      xpath = //person[FirstName = 'John']
> >Can someone help me and give any clue of how can the query be generally
> >made
> >
> >for ignoreCase.
> >
> >Thanks.
> >
> > >From: Thomas Rupp <[EMAIL PROTECTED]>
> > >Reply-To: xindice-users@xml.apache.org
> > >To: xindice-users@xml.apache.org
> > >Subject: xpath query - ignore case sensitive
> > >Date: Tue, 7 May 2002 12:08:45 +0200 (MEST)
> > >
> > >It is possible to make a xpath query for strings and ignore upper/lower
> > >characters.
> > >
> > >--
> > >GMX - Die Kommunikationsplattform im Internet.
> > >http://www.gmx.net
> > >
> >
> >
> >_________________________________________________________________
> >Join the world's largest e-mail service with MSN Hotmail.
> >http://www.hotmail.com
>
> _________________________________________________________________
> Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp.

Reply via email to