First, the '=' is because your query was equals('City'='London'). Second, XPath works from the inside out. So, if you wrap a text() call in a translate, XPath executes the text(), which retrieves the text from the Element. Then if that is wrapped in a translate(), then the text is translated.
In your example, the document is traversed until it gets to //person/FirstName. The Text is retrieved from the Element and ANY ABCD in the Text is translated to abcd. The Text John is translated such that Any ABCD is translated to abcd. The two text strings are compared for equality, the '='. Since, ABCD will never match "John", the only matches that Xindice will return are "John". And third, we are not translating FirstName, we are translating the text Element of the FirstName to lowercase. There are at least two syntaxes you can use for searches: //person[FirstName='John'] or //person/FirstName[text()='John'] Try the second from the command-line. It makes more sense with the translate, because you would "wrap" the result of "text()" inside a translate. //person/FirstName[translate(text(), 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz') = translate('John', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ','abcdefghijklmnopqrstuvwxyz')] Try these from the command-line. First, get it to work without the translate, then put in the translate. HTH, Mark White Shadow wrote: > 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: xindice-users@xml.apache.org > >To: xindice-users@xml.apache.org > >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