This seems to be a common issue to which I've been unable to find a satisfactory solution within my web trawling.
As part of some search functionality in my .Net control I'm trying to find all the ProductEvent nodes below a starting node that contain a given value in the productName property. I've hard coded the value as "Code Garden" in the exmples below.
I've seen solutions that make use of 'translate' function and this works fine however I can see there will be problems when a non-english character set is used.
List<umbraco.presentation.nodeFactory.Node> listNodes = uQuery.GetNodesByXPath("//*[@id=1234]/descendant::ProductEvent [@isDoc and string(umbracoNaviHide) != '1' and contains(translate(productName, 'ABCDEFGHIJKLMNOPQRSTUVWXYZ', 'abcdefghijklmnopqrstuvwxyz'),'" + "Code Garden".ToLower() + "')]");
I've also seen people suggesting that the 'lower-case' function can be used in XPath 2.0 which will help on the international side however when I try it with the code below it just errors.
List<umbraco.presentation.nodeFactory.Node> listNodes = uQuery.GetNodesByXPath("//*[@id=1234]/descendant::ProductEvent [@isDoc and string(umbracoNaviHide) != '1' and contains(lower-case(productName), lower-case('Code Garden'))]");
Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function.
Maybe I have done something wrong? Maybe v2.0 is not used by umbraco?
Case insensitive searching
This seems to be a common issue to which I've been unable to find a satisfactory solution within my web trawling.
As part of some search functionality in my .Net control I'm trying to find all the ProductEvent nodes below a starting node that contain a given value in the productName property. I've hard coded the value as "Code Garden" in the exmples below.
I've seen solutions that make use of 'translate' function and this works fine however I can see there will be problems when a non-english character set is used.
I've also seen people suggesting that the 'lower-case' function can be used in XPath 2.0 which will help on the international side however when I try it with the code below it just errors.
Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function.
Maybe I have done something wrong? Maybe v2.0 is not used by umbraco?
Does anyone have any pointers?
Thanks,
Matt
Hi Matt,
You're right - Umbraco (and 95% of all other .NET based aplications) can't use XSLT 2.0 - Microsoft will probably never support that.
Have a look at the extension functions in the EXSLT library for lowercase and uppercase functionallity.
/Chriztian
Ah Chriztian you are right. I meant to refer to the use of the XSLT extentions in my original post but forgot.
I was going to say how I had seen their use in XSLT macros but I cannot see how they could be used in my .Net control XPath expression above?
Regards,
Matt
is working on a reply...