Layer7 API Management

  • 1.  how to transform case (uppercase/lowercase) of a value in variable context ?

    Posted Dec 08, 2016 11:33 AM

    Hi,

    my problem is really simple for a basic feature.

     

    In variable context "foo" contains "bAr", I will transform case of value like this :

    1) "BAR" (toupper)

    2) "bar" ( tolower)

    3) "Bar"( tocapitalize)

     

    I try with "Evaluate Regular Expression" assertion but unsuccess

     

    Regular Expression : ([a-zA-Z])(.*)

    Replacement :

    1) \U$1$2  -> result : UbAr

    2) \L$1$2 -> result : LbAr

    3) \u$1\L$2 -> result : ubLAr

     

    Do you know the solution ? with or without "Evaluate Regular Expression"  assertion

     

    Regards

    David



  • 2.  Re: how to transform case (uppercase/lowercase) of a value in variable context ?
    Best Answer

    Broadcom Employee
    Posted Dec 08, 2016 11:39 AM

    Hi APIMGTEtudes18000094,

     

    You may find this document useful. It provides a sample policy for transforming characters to upper and lower case using XSLT.

     

    Knowledge Base Articles 

     

    As for capitalizing the first letter, this should help:

    xml - XSL - How do you capitalize first letter - Stack Overflow 

     

    Regards,

    Joe



  • 3.  Re: how to transform case (uppercase/lowercase) of a value in variable context ?

    Posted Dec 08, 2016 11:52 AM

    Thanks Joe

    XSL ? is it the best optimized solution for convert "bAr" to "Bar" ?

    Regards,

    David



  • 4.  Re: how to transform case (uppercase/lowercase) of a value in variable context ?

    Broadcom Employee
    Posted Dec 08, 2016 01:22 PM

    For camel case in particular this seems to be a good solution.

     

    Camel case conversion for special case also in XSLT - Stack Overflow 

     

    As for optimized, XSLT seems to be an ideal way of handling this. I am not positive if it is the most optimized choice, but if used sparingly I can't imagine too big of a performance hit in policy.

     

    Regards,

    Joe



  • 5.  Re: how to transform case (uppercase/lowercase) of a value in variable context ?

    Posted Dec 09, 2016 05:14 AM

    Thanks Joe 

     

    Regards,

    David