views:

973

answers:

3

Hi, I am trying to get a xpath query using the xpath function lower-case or uppper-case, but they seem to not work in selenium (where I test my xpath before I apply it).

Example that does NOT work: //*[.=upper-case('some text')]

I have no problem locating the nodes I need in complex path and even using aggregated functions, as long as I don't use the upper and lower case.

Has anyone encountered this before? Does it make sense?

Thanks.

+3  A: 

upper-case() and lower-case() are XPath 2.0 functions. Chances are your platform supports XPath 1.0 only.

Try:

translate('some text','abcdefghijklmnopqrstuvwxyz','ABCDEFGHIJKLMNOPQRSTUVWXYZ')

which is the XPath 1.0 way to do it. Unfortunately, this requires knowledge of the alphabet the text uses. For plain English, the above probably works, but if you expect accented characters, make sure you add them to the list.

Tomalak
Indeed, thanks!Unfortunately this is not 'clean' at all... :((it will complicate even more some of our already-complicated DSL definitions in GenericFixture for Fitnesse).Anyone has any idea of when selenium RC or Firefox (I don't which one is the responsible) will adopt XPath 2.0?
Aristotelis
I'm sorry, but I have no idea. I know it's not clean, but it's the best you will get with XPath 1.0.
Tomalak
@Aristotelis: Yes, this seems to be not clear, but it has its reason behind. XML is Unicode, not ASCII/English looked. So, for capitalization it needs to know about collations. Collations knowledge was added to XPath 2.0.
Alejandro
A: 

If you are going to need upper case in multiple places in your xslt, you can define variables for the lower case and upper case and then use them in your translate function everywhere. It should make your xslt much cleaner.

Example at XSL/XPATH : No upper-case function in MSXML 4.0 ?

Rashmi Pandit
A: 

It's good to note that for the people working on XSL documents, using CSS' text properties solves transformation problems like capitalizing.

To get more info: http://www.w3schools.com/css/pr_text_text-transform.asp

sid3k