Page 1 of 1

case insensitive search using XPath queries

PostPosted:Tue Apr 21, 2009 7:21 am
by bragarwal
Since XPath is case sensitive, I was not able to search the files with different case. I tried little modification in the XPath queries to search documents irrespective of the case, but it did not worked. Please have a look and let me know if I am doing anything wrong.

1.) Normal way to search file using XPath query (case sensitive) :
/jcr:root/okm:root//element(*,okm:document)[@okm:name = \'ExcelFile.xls\']

2.) Alternate way to search file using XPath query (case insensitive) :
/jcr:root/okm:root//element(*,okm:document)[translate(@okm:name, \'ABCDEFGHIJKLMNOPQRSTUVWXYZ\', \'abcdefghijklmnopqrstuvwxyz\') = ExcelFile.xls.ToLower()]

3.) Another way to search files (case insensitive) :
/jcr:root/okm:root//element(*,okm:document)[lower-case(@okm:name) = lower-case(\'ExcelFile.xls\')]

4.) Another way to search files (case insensitive) :
/jcr:root/okm:root//element(*,okm:document)[translate(@okm:name, \'ABCDEFGHIJKLMNOPQRSTUVWXYZ\', \'abcdefghijklmnopqrstuvwxyz\') = translate(\'ExcelFile.xls\', \'ABCDEFGHIJKLMNOPQRSTUVWXYZ\', \'abcdefghijklmnopqrstuvwxyz\')]

Pavilla/Jillort can u shed some light on it, let me know if i am doing anything wrong.