Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Matt Taylor 873 posts 2086 karma points
    Jul 04, 2011 @ 14:17
    Matt Taylor
    0

    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.

     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?

    Does anyone have any pointers?

    Thanks,

    Matt

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Jul 04, 2011 @ 23:46
    Chriztian Steinmeier
    0

    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

      

  • Matt Taylor 873 posts 2086 karma points
    Jul 05, 2011 @ 11:04
    Matt Taylor
    0

    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

Please Sign in or register to post replies

Write your reply to:

Draft