0

I fail to use functx:substring-before-match in one of my mediation sequences

<property expression="functx:substring-before-match($trp:FILE_URI, 'CMDE[a-zA-Z0-9_]*\.zip')" name="baseFolder"/>
[2020-03-27 12:26:56,647] []  INFO - ApplicationManager Successfully Deployed Carbon Application : rsa2wayzz_CA_1.0.0 {super-tenant}
[2020-03-27 12:27:06,742] [] ERROR - SynapseXPath Evaluation of the XPath expression functx:substring-before-match($trp:FILE_URI, 'CMDE[a-zA-Z0-9_]*\.zip') resulted in an error
org.jaxen.UnresolvableException: No Such Function substring-before-match
        at org.jaxen.SimpleFunctionContext.getFunction(SimpleFunctionContext.java:127)
        at org.apache.synapse.util.xpath.SynapseXPathFunctionContext.getFunction(SynapseXPathFunctionContext.java:101)
        at org.jaxen.ContextSupport.getFunction(ContextSupport.java:242)
        at org.jaxen.Context.getFunction(Context.java:216)
        at org.jaxen.expr.DefaultFunctionCallExpr.evaluate(DefaultFunctionCallExpr.java:176)
        at org.jaxen.expr.DefaultXPathExpr.asList(DefaultXPathExpr.java:102)
        at org.jaxen.BaseXPath.selectNodesForContext(BaseXPath.java:677)
        at org.jaxen.BaseXPath.selectNodes(BaseXPath.java:216)
        at org.jaxen.BaseXPath.evaluate(BaseXPath.java:175)

Do you know where I could find a list of the Xquery function supported by what looks like a custom synapse engine?

environment

  • wso2ei 6.5.0
  • synapse 2.1.7-wso2v111 (I think based on the sources)
zar3bski
  • 2,773
  • 7
  • 25
  • 58
  • Could this possibly work (support multiple ".zip" in a sequence but rely upon it ends with '.zip') : `susbtring($trp:FILE_URI,1,string-length($trp:FILE_URI)-string-length('.zip')+1)` – E.Wiest Mar 27 '20 at 18:07
  • Well, the thing is: I can't know the length of the string *a priory* (which is precisely the reason why I want to use **regular expressions**). Plus I have to make sure that file names satisfy some constraints – zar3bski Mar 27 '20 at 18:10
  • 2
    You could use replace (XPath 2.0) with other nested functions. Something like this should work (and you don't have to know the length of your string) : `substring(yourstring,1,string-length(substring-before(replace(yourstring,regex expression to locate the last group in the sequence, "toto"),"toto")))` First you locate and replace the last group with 'toto' in your sequence with replace. Then you calculate the length of the string (before 'toto') with string-length and substring-before. To finish, you use susbtring to get what you need (from 1 to the length previously computed). – E.Wiest Mar 27 '20 at 19:13

0 Answers0