diff --git a/en/docs/reference/mediators/switch-mediator.md b/en/docs/reference/mediators/switch-mediator.md index 453e1a2b2..108f4155a 100644 --- a/en/docs/reference/mediators/switch-mediator.md +++ b/en/docs/reference/mediators/switch-mediator.md @@ -1,11 +1,11 @@ # Switch Mediator -The **Switch Mediator** is an XPath or JSONPath filter. The XPath or JSONPath expression is evaluated and returns a string. This string is matched against the regular expression in each switch case, in the specified order. If a matching case is found, it is executed, and the remaining cases are not processed. If none of the case statements match and a default case is specified, the default case will be executed. +The **Switch Mediator** evaluates a Synapse expression and returns a result. This result is then matched against the regular expressions defined in each switch case, in the specified order. If a matching case is found, it is executed, and the remaining cases are not processed. If none of the case statements match the default case will be executed. ## Syntax ```xml - + mediator+ + @@ -28,44 +28,40 @@ The parameters available to configure the Switch mediator are as follows. -Source XPath -The source XPath or JSONPath to be evaluated. When specifying a JSONPath, use the format json-eval(<JSON_PATH>) , such as json-eval(getQuote.request.symbol) . If you use namespaces in the expression, click the edit icon, then click Add Namespace to map the namespace prefix to the correct URI. +Expression +The Synapse expression to be evaluated which should return a string. -Number of cases -

This parameter displays the number of cases currently added to the Switch mediator configuration.

+Cases +

This section displays the number of cases currently added to the switch mediator and option to add a new case.


- -Specify default case -Adding a default case is optional. If it is specified, it will be executed if no matching case is identified. - -## Switch-case mediator +### Adding a new case -1. To add a case, go to edit the switch and click **Add parameter** under **Case Branches**. -2. It will open a form where a regular expression can be added in the **Case Regex** parameter. By submitting, it will add an empty case under the switch mediator as a child. -3. Click on the `+` mark under a chase to add the mediator(s) you want to execute when this case matches the switching value. +1. To add a case, click on the Switch mediator to open the **Edit Switch Mediator** panel. Then click **Add new case** under the **Cases** section. +2. It will open a form where a regular expression can be added in the **Regex Pattern** parameter. Once submitted, it will add an empty case under the switch mediator as a child. +3. Click on the + mark under a case to add the mediator(s) you want to execute when this case matches the switching value. ## Examples -In this example, the [Property mediator]({{base_path}}/reference/mediators/property-mediator) sets the local property named `symbol` on the current message depending on the evaluation of the string. It will get the text of the symbol element and match it against the values `MSFT` and `IBM`. If the text does not match either of these symbols, the default case will be executed. +In this example, the [Variable mediator]({{base_path}}/reference/mediators/variable-mediator) sets the variable named `symbol` on the current message depending on the evaluation of the expression. The expression will get the symbol value and match it against the values `MSFT` and `IBM`. If the symbol value does not match either of these symbols, the default case will be executed. ```xml - + - - + + - + - - + + ```