This documentation is for WSO2 Enterprise Service Bus version 4.8.0 . View documentation for the latest release.

All docs This doc

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

The Filter Mediator can be used for filtering messages based on an XPath or JSON PathJSONPath. There are two modes of operation.

  1. If the user only specifies the XPath or JSON PathJSONPath, it will be evaluated as true or false.
  2. If the user specifies a regular expression as well, the string returned from evaluating the XPath or JSON Path JSONPath will be matched against the regular expression.

...

Code Block
XML
XML
<filter (source="[XPath|json-eval(JSON PathJSONPath)]" regex="string") | xpath="[XPath|json-eval(JSON PathJSONPath)]">
   mediator+
</filter>

The Filter Mediator either tests the given XPath/JSON Path JSONPath expression as a Boolean expression, or matches the evaluation result of a source XPath/JSON Path JSONPath expression as a string against the given regular expression. If the test succeeds, the Filter Mediator will execute the enclosed mediators in sequence.

...

Code Block
XML
XML
<filter (source="[XPath|json-eval(JSON PathJSONPath)]" regex="string") | xpath="[XPath|json-eval(JSON PathJSONPath)]">
   <then [sequence="string"]>
     mediator+
   </then>
   <else [sequence="string"]>
     mediator+
   </else>
</filter>

...

  • Specify As - Specifies whether you give the condition as an XPath or a Regular expression.
  • XPath - XPath or JSON Path JSONPath expression if you selected "XPath" for "Specify As". When specifying a JSON PathJSONPath, use the format json-eval(<JSON_PATH>), such as json-eval(getQuote.request.symbol). For more information on using JSON with the ESB, see JSON Support.
  • Source- Expression to locate the value that matches the regular expression that you can define below.

    Info
    titleTip

    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 or JSON Path JSONPath expression.

  • Regex - Regular expression to match the source value.

...