The Switch Mediator is an XPath filter. The XPath is evaluated and return a string. This string is matched against the regular expression in each case statement, in the specified order. If a matching case is found, it will be executed. Once the match is found, further processing of the case statements won't happen. If none of the case statements are matching and a default case is specified, it will be executed.
The Switch Mediator will evaluate the given source XPath expression into its string value and match it against the given regular expressions. If the specified cases do not match and a default case exists, it will be executed.
Following Mediators are available:
Here are the options to configure the Switch Mediator:
- Source XPath - Here you can specify the source XPath to be evaluated.
- Number of cases - The number of cases specified. You can add cases by clicking the "Add Case" link.
- Specify default case - The link to add the default case. (This case is to be executed when all the other cases are not matching.)
You can click the Namespaces link to add namespaces if you are providing an expression. You will be provided another panel named "Namespace Editor," where you can provide any number of namespace prefixes and URL that you have used in the XPath expression.
The option to configure the Switch Case Mediator:
- Case Value (Regular Expression) - A regular expression to match with switching value.
The Switch Default Mediator will be a child mediator for the Switch Mediator. It is used to define a default case for the current routing switch. If all the cases were not matched with the switch value, the sequence defined as children to the default mediator will be taken as the route of the message.
You can configure the Mediator using XML. Click on "switch to source view" in the "Mediator" window.
In this scenario, it will get the text of symbol element and match it against values MSFT and IBM.