Title: RE: xpath query - ignore case sensitive

White Shadow,
You don't need a book. Here are some great, web-based, free tutorials on xpath:

http://www.w3schools.com/xpath/

http://www.zvon.org/xxl/XPathTutorial/General/examples.html

Have fun,
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: Thursday, May 09, 2002 10:16 AM
To: [email protected]
Subject: Re: xpath query - ignore case sensitive


Thankyou Mark for such a detailed and good explaination. But since I am new
to XPath and have no book or other resource to grap the details, I have a
couple of more questions to fully understand your reply.

Firstly I would like to know what the equals(=) sign is doing between the
two translate functions. Is it an assignment operator or equality comparison
operator.

Secondly,the translate(string,string,string) gives a string value. SO whats
the complete order of execution of the whole xpath statement

"//person[translate(FirstName,'ABCD','abcd')= translate
('John','ABCD',abcd')]"

Thirdly, in the case of above example, FirstName is the node name. i.e.
<person>
<FirstName>John</FirstName>
.........
</person>

Why are we translating the node name? Shouldn't we be interested only in its
node value?

and finally can you recommend me any online resource on this topic.

Thanks again.




>From: "Mark J. Stang" <[EMAIL PROTECTED]>
>Reply-To: [email protected]
>To: [email protected]
>Subject: Re: xpath query - ignore case sensitive
>Date: Thu, 09 May 2002 09:47:25 -0600
>
>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
>


_________________________________________________________________
Chat with friends online, try MSN Messenger: http://messenger.msn.com

Reply via email to