Is there any XPath expression for String Padding in wso2 ESB?

后端 未结 2 2048
予麋鹿
予麋鹿 2020-12-21 05:55

I have enabled XPath 2.0 configuration synapse.xpath.dom.failover.enabled=true in synapse.properties but still unable to get string padding done. I

2条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-21 06:16

    This can be achieved using XPath 1.0 like so, assuming that "WSO2" will be replaced by dynamic input string in the actual implementation :

    substring(concat('WSO2', '%%%%%%%%%%'), 1, 10)
    

    The above XPath basically works by concatenating string of 10 specific for-padding characters to the original input string, and then substring the result to get only the first 10 characters. Found this trick in the following XSL question : XSL left-right justification with Padding

    To put this in a more generic formula :

    substring(concat('input_string', '%%%%....'), 1, n)
    
    • input_string : string to which padding operation will applied
    • % : character used for padding, repeated n times
    • n : fixed number of characters expected in the output string

提交回复
热议问题